Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename testsuite to cunit (more sexy name); integrate it properly into SimGrid; use...
[simgrid.git] / include / xbt / cunit.h
1 /* $Id$ */
2
3 /* cunit - A little C Unit facility                                         */
4
5 /* Copyright (c) 2005 Martin Quinson. All rights reserved.                  */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 /* This is partially inspirated from the OSSP ts (Test Suite Library)       */
11
12 #ifndef _XBT_CUNIT_H_
13 #define _XBT_CUNIT_H_
14
15 #include "xbt/sysdep.h"    /* XBT_GNU_PRINTF */
16
17 /* test suite object type */
18 typedef struct s_xbt_test_suite *xbt_test_suite_t;
19
20 /* test object type */
21 typedef struct s_xbt_test_unit *xbt_test_unit_t;
22
23 /* test callback function type */
24 typedef void (*ts_test_cb_t)(xbt_test_unit_t);
25
26 /* test suite operations */
27 xbt_test_suite_t xbt_test_suite_new  (const char *fmt, ...);
28 void             xbt_test_suite_dump (xbt_test_suite_t suite);
29 void             xbt_test_suite_push (xbt_test_suite_t suite, 
30                                       ts_test_cb_t func, const char *fmt, ...);
31
32 int xbt_test_run  (void);
33
34
35 /* test operations */
36 void    _xbt_test(xbt_test_unit_t u, const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(4,5);
37 #define xbt_test0(fmt)           _xbt_test(_unit,__FILE__,__LINE__,fmt)
38 #define xbt_test1(fmt,a)         _xbt_test(_unit,__FILE__,__LINE__,fmt,a)
39 #define xbt_test2(fmt,a,b)       _xbt_test(_unit,__FILE__,__LINE__,fmt,a,b)
40 #define xbt_test3(fmt,a,b,c)     _xbt_test(_unit,__FILE__,__LINE__,fmt,a,b,c)
41 #define xbt_test4(fmt,a,b,c,d)   _xbt_test(_unit,__FILE__,__LINE__,fmt,a,b,c,d)
42 #define xbt_test5(fmt,a,b,c,d,e) _xbt_test(_unit,__FILE__,__LINE__,fmt,a,b,c,d,e)
43
44 void    _xbt_test_fail(xbt_test_unit_t u, const char*file,int line, const char *fmt, ...) _XBT_GNUC_PRINTF(4,5);
45 #define xbt_test_fail0(fmt)           _xbt_test_fail(_unit, __FILE__, __LINE__, fmt)
46 #define xbt_test_fail1(fmt,a)         _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a)
47 #define xbt_test_fail2(fmt,a,b)       _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b)
48 #define xbt_test_fail3(fmt,a,b,c)     _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c)
49 #define xbt_test_fail4(fmt,a,b,c,d)   _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c,d)
50 #define xbt_test_fail5(fmt,a,b,c,d,e) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c,d,e)
51
52 void    _xbt_test_log (xbt_test_unit_t u, const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(4,5);
53 #define xbt_test_log0(fmt)           _xbt_test_log(_unit, __FILE__, __LINE__, fmt)
54 #define xbt_test_log1(fmt,a)         _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a)
55 #define xbt_test_log2(fmt,a,b)       _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b)
56 #define xbt_test_log3(fmt,a,b,c)     _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c)
57 #define xbt_test_log4(fmt,a,b,c,d)   _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c,d)
58 #define xbt_test_log5(fmt,a,b,c,d,e) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c,d,e)
59
60 void _xbt_test_expect_failure(xbt_test_unit_t unit);
61 #define    xbt_test_expect_failure() _xbt_test_expect_failure(_unit)
62
63 void _xbt_test_skip(xbt_test_unit_t unit);
64 #define    xbt_test_skip() _xbt_test_skip(_unit)
65
66 /* test suite short-cut macros */
67 #define XBT_TEST_UNIT(name) \
68     static void name(xbt_test_unit_t _unit)
69
70 #endif /* _TS_H_ */
71