1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LIBPERF_INTERNAL_TESTS_H
3 #define __LIBPERF_INTERNAL_TESTS_H
4 
5 #include <stdio.h>
6 
7 int tests_failed;
8 
9 #define __T_START					\
10 do {							\
11 	fprintf(stdout, "- running %s...", __FILE__);	\
12 	fflush(NULL);					\
13 	tests_failed = 0;				\
14 } while (0)
15 
16 #define __T_END								\
17 do {									\
18 	if (tests_failed)						\
19 		fprintf(stdout, "  FAILED (%d)\n", tests_failed);	\
20 	else								\
21 		fprintf(stdout, "OK\n");				\
22 } while (0)
23 
24 #define __T(text, cond)                                                          \
25 do {                                                                             \
26 	if (!(cond)) {                                                           \
27 		fprintf(stderr, "FAILED %s:%d %s\n", __FILE__, __LINE__, text);  \
28 		tests_failed++;                                                  \
29 		return -1;                                                       \
30 	}                                                                        \
31 } while (0)
32 
33 #endif /* __LIBPERF_INTERNAL_TESTS_H */
34