Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a tool to automatically extract the test units from the source code of the librar...
[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 *name,const char *fmt, ...);
28 xbt_test_suite_t xbt_test_suite_by_name(const char *name,const char *fmt, ...);
29 void             xbt_test_suite_dump (xbt_test_suite_t suite);
30 void             xbt_test_suite_push (xbt_test_suite_t suite, 
31                                       ts_test_cb_t func, const char *fmt, ...);
32
33 int xbt_test_run  (void);
34
35
36 /* test operations */
37 void    _xbt_test_add(xbt_test_unit_t u, const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(4,5);
38 #define xbt_test_add0(fmt)           _xbt_test_add(_unit,__FILE__,__LINE__,fmt)
39 #define xbt_test_add1(fmt,a)         _xbt_test_add(_unit,__FILE__,__LINE__,fmt,a)
40 #define xbt_test_add2(fmt,a,b)       _xbt_test_add(_unit,__FILE__,__LINE__,fmt,a,b)
41 #define xbt_test_add3(fmt,a,b,c)     _xbt_test_add(_unit,__FILE__,__LINE__,fmt,a,b,c)
42 #define xbt_test_add4(fmt,a,b,c,d)   _xbt_test_add(_unit,__FILE__,__LINE__,fmt,a,b,c,d)
43 #define xbt_test_add5(fmt,a,b,c,d,e) _xbt_test_add(_unit,__FILE__,__LINE__,fmt,a,b,c,d,e)
44
45 void    _xbt_test_fail(xbt_test_unit_t u, const char*file,int line, const char *fmt, ...) _XBT_GNUC_PRINTF(4,5);
46 #define xbt_test_fail0(fmt)           _xbt_test_fail(_unit, __FILE__, __LINE__, fmt)
47 #define xbt_test_fail1(fmt,a)         _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a)
48 #define xbt_test_fail2(fmt,a,b)       _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b)
49 #define xbt_test_fail3(fmt,a,b,c)     _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c)
50 #define xbt_test_fail4(fmt,a,b,c,d)   _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c,d)
51 #define xbt_test_fail5(fmt,a,b,c,d,e) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c,d,e)
52
53 void    _xbt_test_log (xbt_test_unit_t u, const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(4,5);
54 #define xbt_test_log0(fmt)           _xbt_test_log(_unit, __FILE__, __LINE__, fmt)
55 #define xbt_test_log1(fmt,a)         _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a)
56 #define xbt_test_log2(fmt,a,b)       _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b)
57 #define xbt_test_log3(fmt,a,b,c)     _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c)
58 #define xbt_test_log4(fmt,a,b,c,d)   _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c,d)
59 #define xbt_test_log5(fmt,a,b,c,d,e) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c,d,e)
60
61 void _xbt_test_expect_failure(xbt_test_unit_t unit);
62 #define    xbt_test_expect_failure() _xbt_test_expect_failure(_unit)
63
64 void _xbt_test_skip(xbt_test_unit_t unit);
65 #define    xbt_test_skip() _xbt_test_skip(_unit)
66
67 /* test suite short-cut macros */
68 #define XBT_TEST_UNIT(name,func,title)               \
69     void func(xbt_test_unit_t _unit);  /*prototype*/ \
70     void func(xbt_test_unit_t _unit) 
71
72 #endif /* _TS_H_ */
73