File: common.h

package info (click to toggle)
eztrace 2.0%2Brepack-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,132 kB
  • sloc: ansic: 23,501; perl: 910; sh: 857; cpp: 771; makefile: 696; fortran: 327; f90: 320; python: 57
file content (68 lines) | stat: -rw-r--r-- 2,116 bytes parent folder | download | duplicates (12)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* -*- c-file-style: "GNU" -*- */
/*
 * Copyright (C) CNRS, INRIA, Université Bordeaux 1, Télécom SudParis
 * See COPYING in top-level directory.
 *
 *
 * common.h - common basis for several tests
 *
 *  Created on: 3 sep. 2012
 *      Author: Damien Martin-Guillerez <damien.martin-guillerez@inria.fr>
 */

#include <stdlib.h>
#include <stdio.h>

int debug;

// Common parts
#define DEBUG(x) if(debug > 1) fprintf(stderr, "\tDEBUG %s: " x "\n", __method__)
#define DEBUG1(x, p1) if(debug > 1) fprintf(stderr, "\tDEBUG %s: " x "\n", __method__, p1)
#define DEBUG2(x, p1, p2) if(debug > 1) fprintf(stderr, "\tDEBUG %s: " x "\n", __method__, p1, p2)
#define BEGIN_TEST(method) \
	 int do_run_test_##method; \
     int test_##method() { static const char *__method__ = #method; if(debug > 0) fprintf(stderr, "%s\n", __method__);
#define END_TEST(method) return 0; }
#define RUN_TEST(x) do { \
	if(runall || do_run_test_##x) { \
		r = test_##x(); \
		if(r < 0) { \
			return r; \
		} \
	} \
	} while(0)
#define PARSE_TEST(x) do { \
		if(strcmp(av[i], #x) == 0) { \
			do_run_test_##x = 1; \
			runall = 0; \
		} \
	} while(0)
#define TEST0(test, testname, msg) do { \
		if(!(test)) { \
			fprintf(stderr, "FAIL %s for test `" #testname "` with message: " msg "\n", __method__); \
			return -__LINE__; \
		} \
		DEBUG(#testname " succeeded"); \
	} while(0)
#define TEST1(test, testname, msg, p1) do { \
		if(!(test)) { \
			fprintf(stderr, "FAIL %s for test `" #testname "` with message: " msg "\n", __method__, p1); \
			return -__LINE__; \
		} \
		DEBUG(#testname " succeeded"); \
	} while(0)
#define TEST2(test, testname, msg, p1, p2) do { \
		if(!(test)) { \
			fprintf(stderr, "FAIL %s for test `" #testname "` with message: " msg "\n", __method__, p1, p2); \
			return -__LINE__; \
		} \
		DEBUG(#testname " succeeded"); \
	} while(0)
#define TEST3(test, testname, msg, p1, p2, p3) do { \
		if(!(test)) { \
			fprintf(stderr, "FAIL %s for test `" #testname "` with message: " msg "\n", __method__, p1, p2, p3); \
			return -__LINE__; \
		} \
		DEBUG(#testname " succeeded"); \
	} while(0)
// End of common parts