• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef TEST_H_INCLUDED
2 #define TEST_H_INCLUDED
3 
4 #include <stdio.h>
5 #include <alsa/asoundlib.h>
6 
7 /* XXX this variable definition does not belong in a header file */
8 static int any_test_failed;
9 
10 #define TEST_CHECK(cond) do \
11 		if (!(cond)) { \
12 			fprintf(stderr, "%s:%d: test failed: %s\n", __FILE__, __LINE__, #cond); \
13 			any_test_failed = 1; \
14 		} \
15 	while (0)
16 
17 #define ALSA_CHECK(fn) ({ \
18 		int err = fn; \
19 		if (err < 0) { \
20 			fprintf(stderr, "%s:%d: ALSA function call failed (%s): %s\n", \
21 				__FILE__, __LINE__, snd_strerror(err), #fn); \
22 			any_test_failed = 1; \
23 		} \
24 		err; \
25 	})
26 
27 #define TEST_EXIT_CODE() any_test_failed
28 
29 #endif
30