X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Frunner.cc;h=2f94ad37b870602333f6966389e7eee2f9bdf578;hb=bf2fa8274d569da94a626eea30de612f01ec4a7c;hp=2d78369788b7751d1f9601d1580a4426792ec07b;hpb=25efe3485198149616820ab4e52d2f18f0abe5a7;p=awesomized%2Flibmemcached diff --git a/libtest/runner.cc b/libtest/runner.cc index 2d783697..2f94ad37 100644 --- a/libtest/runner.cc +++ b/libtest/runner.cc @@ -34,7 +34,7 @@ * */ -#include +#include "libtest/yatlcon.h" #include namespace libtest { @@ -44,6 +44,117 @@ Runner::Runner() : { } +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; @@ -79,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