File: test.h

package info (click to toggle)
alsa-lib 1.0.23-2.1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 12,688 kB
  • ctags: 10,853
  • sloc: ansic: 72,724; sh: 9,923; makefile: 696
file content (29 lines) | stat: -rw-r--r-- 643 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef TEST_H_INCLUDED
#define TEST_H_INCLUDED

#include <stdio.h>
#include <alsa/asoundlib.h>

/* XXX this variable definition does not belong in a header file */
static int any_test_failed;

#define TEST_CHECK(cond) do \
		if (!(cond)) { \
			fprintf(stderr, "%s:%d: test failed: %s\n", __FILE__, __LINE__, #cond); \
			any_test_failed = 1; \
		} \
	while (0)

#define ALSA_CHECK(fn) ({ \
		int err = fn; \
		if (err < 0) { \
			fprintf(stderr, "%s:%d: ALSA function call failed (%s): %s\n", \
				__FILE__, __LINE__, snd_strerror(err), #fn); \
			any_test_failed = 1; \
		} \
		err; \
	})

#define TEST_EXIT_CODE() any_test_failed

#endif