source: tags/svn.1.5.4/UNIT_TESTER/UnitTester.hxx

Last change on this file was 8099, checked in by westram, 13 years ago

merge from ptpan_back [8046] [8047] [8050] [8048] [8057] [8069]

  • fixed several problems with unit-tests (race-condition, blocking, broken error messages, valgrinding)
File size: 2.0 KB
Line 
1// ================================================================ //
2//                                                                  //
3//   File      : UnitTester.hxx                                     //
4//   Purpose   : unit testing - test one unit                       //
5//                                                                  //
6//   Coded by Ralf Westram (coder@reallysoft.de) in February 2010   //
7//   Institute of Microbiology (Technical University Munich)        //
8//   http://www.arb-home.de/                                        //
9//                                                                  //
10// ================================================================ //
11
12#ifndef UNITTESTER_HXX
13#define UNITTESTER_HXX
14
15#ifndef _GLIBCXX_CSTDLIB
16#include <cstdlib>
17#endif
18
19typedef void (*UnitTest_function)();
20
21struct UnitTest_simple {
22    UnitTest_function  fun;
23    const char        *name;
24    const char        *location;
25};
26enum UnitTestResult {
27    TEST_OK,
28    TEST_TRAPPED,
29    TEST_INTERRUPTED, 
30};
31
32struct UnitTester {
33    UnitTester(const char *libname, const UnitTest_simple *simple_tests, int warn_level, size_t skippedTests) __attribute__((noreturn));
34};
35
36UnitTestResult execute_guarded(UnitTest_function fun, long *duration_usec, long max_allowed_duration_ms, bool detect_environment_calls);
37void sleepms(long ms);
38
39// ------------------------------
40//      execution time limits
41
42const long SECONDS = 1000;
43
44const long MAX_EXEC_MS_NORMAL = 6 * SECONDS;        // kill with segfault after time passed
45const long MAX_EXEC_MS_SLOW   = 20 * SECONDS;       // same for slow tests
46const long MAX_EXEC_MS_ENV    = 30 * SECONDS;       // same for environment setup/cleanup
47const long MAX_EXEC_MS_VGSYS  = 60 * SECONDS;       // same for valgrinded system calls (especially pt_server)
48
49const long WARN_SLOW_ABOVE_MS = 1 * SECONDS;        // when too warn about slow test
50
51#define FLAGS_DIR "flags"
52#define FLAGS_EXT "flag"
53
54#else
55#error UnitTester.hxx included twice
56#endif // UNITTESTER_HXX
Note: See TracBrowser for help on using the repository browser.