Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move OSSP testsuite code out of the testsuite/ dir so that it becomes part of XBT
[simgrid.git] / include / xbt / testsuite.h
1 /*
2 **  OSSP ts - Test Suite Library
3 **  Copyright (c) 2001-2004 Ralf S. Engelschall <rse@engelschall.com>
4 **  Copyright (c) 2001-2004 The OSSP Project <http://www.ossp.org/>
5 **  Copyright (c) 2001-2004 Cable & Wireless <http://www.cw.com/>
6 **
7 **  This file is part of OSSP ts, a small test suite library which
8 **  can be found at http://www.ossp.org/pkg/lib/ts/.
9 **
10 **  Permission to use, copy, modify, and distribute this software for
11 **  any purpose with or without fee is hereby granted, provided that
12 **  the above copyright notice and this permission notice appear in all
13 **  copies.
14 **
15 **  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
16 **  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 **  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 **  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
19 **  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 **  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 **  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
22 **  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 **  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 **  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 **  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 **  SUCH DAMAGE.
27 **
28 **  ts.h: test suite library API
29 */
30
31 #ifndef _TS_H_
32 #define _TS_H_
33
34 /* test suite object type */
35 struct ts_suite_st;
36 typedef struct ts_suite_st ts_suite_t;
37
38 /* test object type */
39 struct ts_test_st;
40 typedef struct ts_test_st ts_test_t;
41
42 /* test callback function type */
43 typedef void (*ts_test_cb_t)(ts_test_t *);
44
45 /* test suite operations */
46 ts_suite_t *ts_suite_new  (const char *fmt, ...);
47 void        ts_suite_test (ts_suite_t *s, ts_test_cb_t func, const char *fmt, ...);
48 int         ts_suite_run  (ts_suite_t *s);
49 void        ts_suite_free (ts_suite_t *s);
50
51 /* test operations */
52 ts_test_t  *ts_test_ctx   (ts_test_t *t, const char *file, int line);
53 void        ts_test_check (ts_test_t *t, const char *fmt, ...);
54 void        ts_test_fail  (ts_test_t *t, const char *fmt, ...);
55 void        ts_test_log   (ts_test_t *t, const char *fmt, ...);
56
57 /* test suite short-cut macros */
58 #define TS_TEST(name) \
59     static void name(ts_test_t *_t)
60 #define TS_CTX \
61     ts_test_ctx(_t, __FILE__, __LINE__)
62
63 #endif /* _TS_H_ */
64