X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Frunner.cc;h=2f94ad37b870602333f6966389e7eee2f9bdf578;hb=770d4f6b4cc99bff87d27f4cbe52b2c6a2f2fbd2;hp=01cb99a8d690d80d6c8324af878c26e1b18deec0;hpb=9139975f5fe7895259645117b1e0e9a6cb9c27cc;p=awesomized%2Flibmemcached diff --git a/libtest/runner.cc b/libtest/runner.cc index 01cb99a8..2f94ad37 100644 --- a/libtest/runner.cc +++ b/libtest/runner.cc @@ -34,15 +34,127 @@ * */ -#include +#include "libtest/yatlcon.h" #include namespace libtest { -Runner::Runner() +Runner::Runner() : + _servers(NULL) { } +test_return_t Runner::main(test_callback_fn* func, void *object) +{ + test_return_t ret; + try { + ret= run(func, object); + } + catch (const libtest::__skipped& e) + { + ret= TEST_SKIPPED; + } + catch (const libtest::__failure& e) + { + libtest::stream::make_cerr(e.file(), e.line(), e.func()) << e.what(); + ret= TEST_FAILURE; + } + catch (const libtest::__success&) + { + ret= TEST_SUCCESS; + } + catch (const libtest::fatal&) + { + throw; + } + catch (const std::exception& e) + { + libtest::stream::make_cerr(LIBYATL_DEFAULT_PARAM) << e.what(); + throw; + } + catch (...) + { + libtest::stream::make_cerr(LIBYATL_DEFAULT_PARAM) << "Unknown exception thrown"; + throw; + } + + return ret; +} + +test_return_t Runner::setup(test_callback_fn* func, void *object) +{ + test_return_t ret; + try { + ret= pre(func, object); + } + catch (const libtest::__skipped& e) + { + ret= TEST_SKIPPED; + } + catch (const libtest::__failure& e) + { + libtest::stream::make_cout(e.file(), e.line(), e.func()) << e.what(); + ret= TEST_FAILURE; + } + catch (const libtest::__success&) + { + ret= TEST_SUCCESS; + } + catch (const libtest::fatal& e) + { + throw; + } + catch (const std::exception& e) + { + libtest::stream::make_cerr(LIBYATL_DEFAULT_PARAM) << e.what(); + throw; + } + catch (...) + { + libtest::stream::make_cerr(LIBYATL_DEFAULT_PARAM) << "Unknown exception thrown"; + throw; + } + + return ret; +} + +test_return_t Runner::teardown(test_callback_fn* func, void *object) +{ + test_return_t ret; + try { + ret= post(func, object); + } + catch (const libtest::__skipped& e) + { + ret= TEST_SKIPPED; + } + catch (const libtest::__failure& e) + { + libtest::stream::make_cerr(LIBYATL_DEFAULT_PARAM) << e.what(); + ret= TEST_FAILURE; + } + catch (const libtest::__success&) + { + ret= TEST_SUCCESS; + } + catch (const libtest::fatal& e) + { + throw; + } + catch (const std::exception& e) + { + libtest::stream::make_cerr(LIBYATL_DEFAULT_PARAM) << e.what(); + throw; + } + catch (...) + { + libtest::stream::make_cerr(LIBYATL_DEFAULT_PARAM) << "Unknown exception thrown"; + throw; + } + + return ret; +} + test_return_t Runner::flush(void*) { return TEST_SUCCESS; @@ -78,4 +190,14 @@ test_return_t Runner::post(test_callback_fn* func, void *object) return TEST_SUCCESS; } +void Runner::set_servers(libtest::server_startup_st& arg) +{ + _servers= &arg; +} + +bool Runner::check() +{ + return _servers ? _servers->check() : true; +} + } // namespace libtest