2 * Check: a unit test framework for C
3 * Copyright (C) 2001,2002 Arien Malec
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
24 /* This header should be included by any module that needs
25 to know the implementation details of the check structures
26 Include stdio.h, time.h, & list.h before this header
29 #define US_PER_SEC 1000000
30 #define NANOS_PER_SECONDS 1000000000
32 /** calculate the difference in useconds out of two "struct timespec"s */
33 #define DIFF_IN_USEC(begin, end) \
34 ( (((end).tv_sec - (begin).tv_sec) * US_PER_SEC) + \
35 ((end).tv_nsec/1000) - ((begin).tv_nsec/1000) )
44 signed char allowed_exit_value;
50 List *tclst; /* List of test cases */
53 typedef struct Fixture
62 struct timespec timeout;
63 List *tflst; /* list of test functions */
70 typedef struct TestStats
79 enum test_result rtype; /* Type of result */
80 enum ck_result_ctx ctx; /* When the result occurred */
81 char *file; /* File where the test occured */
82 int line; /* Line number where the test occurred */
83 int iter; /* The iteration value for looping tests */
84 int duration; /* duration of this test in microseconds */
85 const char *tcname; /* Test case that generated the result */
86 const char *tname; /* Test that generated the result */
87 char *msg; /* Failure message */
90 TestResult *tr_create (void);
91 void tr_reset (TestResult * tr);
92 void tr_free (TestResult * tr);
96 CLINITLOG_SR, /* Initialize log file */
97 CLENDLOG_SR, /* Tests are complete */
98 CLSTART_SR, /* Suite runner start */
99 CLSTART_S, /* Suite start */
100 CLEND_SR, /* Suite runner end */
101 CLEND_S, /* Suite end */
102 CLSTART_T, /* A test case is about to run */
103 CLEND_T /* Test case end */
106 typedef void (*LFun) (SRunner *, FILE *, enum print_output,
107 void *, enum cl_event);
114 enum print_output mode;
119 List *slst; /* List of Suite objects */
120 TestStats *stats; /* Run statistics */
121 List *resultlst; /* List of unit test results */
122 const char *log_fname; /* name of log file */
123 const char *xml_fname; /* name of xml output file */
124 const char *tap_fname; /* name of tap output file */
125 List *loglst; /* list of Log objects */
126 enum fork_status fstat; /* controls if suites are forked or not
127 NOTE: Don't use this value directly,
128 instead use srunner_fork_status */
132 void set_fork_status (enum fork_status fstat);
133 enum fork_status cur_fork_status (void);
135 clockid_t check_get_clockid (void);
137 #endif /* CHECK_IMPL_H */