xapian-core
1.4.26
|
The test driver. This class takes care of running the tests. More...
#include <testsuite.h>
Classes | |
struct | result |
A structure used to report the summary of tests passed and failed. More... | |
Public Member Functions | |
test_driver (const test_desc *tests_) | |
The constructor, which sets up the test driver. More... | |
result | run_tests () |
Run all the tests supplied and return the results. More... | |
result | run_tests (std::vector< std::string >::const_iterator b, std::vector< std::string >::const_iterator e) |
Run the tests in the list and return the results. More... | |
Static Public Member Functions | |
static void | add_command_line_option (const std::string &l, char s, std::string *arg) |
Add a test-specific command line option. More... | |
static void | parse_command_line (int argc, char **argv) |
Parse the command line arguments. More... | |
static void | usage () |
static int | run (const test_desc *tests) |
static std::string | get_srcdir () |
Read srcdir from environment and if not present, make a valiant attempt to guess a value. More... | |
static void | report (const test_driver::result &r, const std::string &desc) |
Print summary of tests passed, failed, and skipped. More... | |
Static Public Attributes | |
static result | subtotal |
static result | total |
Private Types | |
enum | test_result { XPASS = 3, XFAIL = 2, PASS = 1, FAIL = 0, SKIP = -1 } |
Private Member Functions | |
void | write_and_clear_tout () |
Write out anything in tout and clear it. More... | |
test_driver (const test_driver &) | |
Prevent copying. More... | |
test_driver & | operator= (const test_driver &) |
test_result | runtest (const test_desc *test) |
Runs the test function and returns its result. More... | |
result | do_run_tests (std::vector< std::string >::const_iterator b, std::vector< std::string >::const_iterator e) |
The implementation used by run_tests. More... | |
Private Attributes | |
std::ostream | out |
const test_desc * | tests |
Static Private Attributes | |
static std::map< int, std::string * > | short_opts |
static std::string | opt_help |
static std::vector< std::string > | test_names |
static bool | abort_on_error = false |
static int | runs = 0 |
static std::string | argv0 |
static std::string | col_red |
static std::string | col_green |
static std::string | col_yellow |
static std::string | col_reset |
static bool | use_cr = false |
The test driver. This class takes care of running the tests.
Definition at line 108 of file testsuite.h.
|
private |
Enumerator | |
---|---|
XPASS | |
XFAIL | |
PASS | |
FAIL | |
SKIP |
Definition at line 212 of file testsuite.h.
test_driver::test_driver | ( | const test_desc * | tests_ | ) |
The constructor, which sets up the test driver.
tests | The zero-terminated array of tests to run. |
Definition at line 170 of file testsuite.cc.
References tout.
|
private |
Prevent copying.
|
static |
Add a test-specific command line option.
The recognised option will be described as:
-<s> <l>
And any value set will be put into arg.
Definition at line 817 of file testsuite.cc.
References opt_help, and short_opts.
Referenced by main(), PerfTestRunner::PerfTestRunner(), TestRunner::run_tests(), and SoakTestRunner::SoakTestRunner().
|
private |
The implementation used by run_tests.
it runs test(s) (with runtest()), prints out messages for the user, and tracks the successes and failures.
b,e | If b != e, a vector of the test(s) to run. If b == e, all tests will be run. |
Definition at line 694 of file testsuite.cc.
References abort_on_error, backendmanager, BackendManager::clean_up(), col_green, col_reset, FAIL, test_driver::result::failed, test_desc::name, out, PASS, runtest(), SKIP, test_driver::result::skipped, test_driver::result::succeeded, tests, use_cr, verbose, XFAIL, test_driver::result::xfailed, XPASS, and test_driver::result::xpassed.
Referenced by run_tests().
|
static |
Read srcdir from environment and if not present, make a valiant attempt to guess a value.
Definition at line 129 of file testsuite.cc.
References DIR_SEPS, endswith(), file_exists(), srcdir, and startswith().
Referenced by DEFINE_TESTCASE(), main(), make_tg_db(), and TestRunner::run_tests().
|
private |
|
static |
Parse the command line arguments.
Definition at line 828 of file testsuite.cc.
References abort_on_error, argv0, col_green, col_red, col_reset, col_yellow, gnu_getopt_long(), no_argument, O_CLOEXEC, Xapian::InMemory::open(), optarg, optind, opts, short_opts, Xapian::Internal::str(), test_names, usage(), use_cr, and verbose.
Referenced by main(), and TestRunner::run_tests().
|
static |
Print summary of tests passed, failed, and skipped.
Definition at line 783 of file testsuite.cc.
References argv0, col_green, col_red, col_reset, col_yellow, test_driver::result::failed, report_totals(), runs, test_driver::result::skipped, test_driver::result::succeeded, test_driver::result::xfailed, and test_driver::result::xpassed.
Referenced by report_totals(), and ApiTestRunner::run().
|
static |
Definition at line 913 of file testsuite.cc.
References test_driver::result::failed, run_tests(), subtotal, test_names, and test_driver::result::xpassed.
test_driver::result test_driver::run_tests | ( | ) |
Run all the tests supplied and return the results.
Definition at line 687 of file testsuite.cc.
References do_run_tests().
Referenced by run().
test_driver::result test_driver::run_tests | ( | std::vector< std::string >::const_iterator | b, |
std::vector< std::string >::const_iterator | e | ||
) |
Run the tests in the list and return the results.
Definition at line 680 of file testsuite.cc.
References do_run_tests().
|
private |
Runs the test function and returns its result.
It will also trap exceptions and some memory leaks and force a failure in those cases.
test | A description of the test to run. |
Definition at line 327 of file testsuite.cc.
References SignalRedirector::activate(), backendmanager, FDTracker::check(), BackendManager::clean_up(), col_red, col_reset, col_yellow, dummy, errno_to_string(), expected_exception, expected_failure, FAIL, Xapian::Error::get_description(), Xapian::Error::get_error_string(), FDTracker::get_message(), Xapian::Error::get_type(), FDTracker::init(), jb, name, out, PASS, test_desc::run, sigaddr, signum, SIGSETJMP, SKIP, tout, verbose, write_and_clear_tout(), XFAIL, and XPASS.
Referenced by do_run_tests().
|
static |
Definition at line 764 of file testsuite.cc.
References argv0, and opt_help.
Referenced by parse_command_line().
|
private |
Write out anything in tout and clear it.
Definition at line 119 of file testsuite.cc.
References tout.
Referenced by runtest().
|
staticprivate |
Definition at line 241 of file testsuite.h.
Referenced by do_run_tests(), and parse_command_line().
|
staticprivate |
Definition at line 253 of file testsuite.h.
Referenced by parse_command_line(), report(), and usage().
|
staticprivate |
Definition at line 256 of file testsuite.h.
Referenced by do_run_tests(), parse_command_line(), and report().
|
staticprivate |
Definition at line 256 of file testsuite.h.
Referenced by parse_command_line(), report(), and runtest().
|
staticprivate |
Definition at line 256 of file testsuite.h.
Referenced by do_run_tests(), parse_command_line(), report(), and runtest().
|
staticprivate |
Definition at line 256 of file testsuite.h.
Referenced by parse_command_line(), report(), and runtest().
|
staticprivate |
Definition at line 218 of file testsuite.h.
Referenced by add_command_line_option(), and usage().
|
private |
Definition at line 244 of file testsuite.h.
Referenced by do_run_tests(), and runtest().
|
staticprivate |
Definition at line 250 of file testsuite.h.
Referenced by report().
|
staticprivate |
Definition at line 216 of file testsuite.h.
Referenced by add_command_line_option(), and parse_command_line().
|
static |
Definition at line 199 of file testsuite.h.
Referenced by ApiTestRunner::run(), and run().
|
staticprivate |
Definition at line 220 of file testsuite.h.
Referenced by parse_command_line(), and run().
|
private |
Definition at line 247 of file testsuite.h.
Referenced by do_run_tests().
|
static |
Definition at line 202 of file testsuite.h.
Referenced by ApiTestRunner::run().
|
staticprivate |
Definition at line 260 of file testsuite.h.
Referenced by do_run_tests(), and parse_command_line().