From: Brian Aker Date: Fri, 20 Apr 2012 06:37:24 +0000 (-0700) Subject: Refactor out portion of Item X-Git-Tag: 1.0.7~6^2^2^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=45c3622634f42187dcf66f3fe37d8285e91ae701;p=awesomized%2Flibmemcached Refactor out portion of Item --- diff --git a/libtest/main.cc b/libtest/main.cc index dcbc50eb..697cce1c 100644 --- a/libtest/main.cc +++ b/libtest/main.cc @@ -308,7 +308,12 @@ int main(int argc, char *argv[]) try { if (test_success(return_code= world.item.startup(creators_ptr))) { - if (test_success(return_code= world.item.flush(creators_ptr, run))) + if (run->requires_flush) + { + return_code= world.runner()->flush(creators_ptr); + } + + if (test_success(return_code)) { { // Runner Code gettimeofday(&start_time, NULL); diff --git a/libtest/runner.cc b/libtest/runner.cc index 6b8d0d48..d58aea17 100644 --- a/libtest/runner.cc +++ b/libtest/runner.cc @@ -29,6 +29,11 @@ Runner::Runner() { } +test_return_t Runner::flush(void*) +{ + return TEST_SUCCESS; +} + test_return_t Runner::run(test_callback_fn* func, void *object) { if (func) diff --git a/libtest/runner.h b/libtest/runner.h index ea42c260..5ee87ff7 100644 --- a/libtest/runner.h +++ b/libtest/runner.h @@ -31,6 +31,7 @@ namespace libtest { */ class Runner { public: + virtual test_return_t flush(void*); virtual test_return_t run(test_callback_fn* func, void *object); virtual test_return_t pre(test_callback_fn* func, void *object); virtual test_return_t post(test_callback_fn* func, void *object); diff --git a/tests/runner.h b/tests/runner.h index deb685af..6c7eaaff 100644 --- a/tests/runner.h +++ b/tests/runner.h @@ -47,6 +47,20 @@ public: return _runner_default(libmemcached_test_callback_fn(func), (libmemcached_test_container_st*)object); } + test_return_t flush(void* arg) + { + return flush((libmemcached_test_container_st*)arg); + } + + test_return_t flush(libmemcached_test_container_st *container) + { + test_true(container->memc); + memcached_flush(container->memc, 0); + memcached_quit(container->memc); + + return TEST_SUCCESS; + } + test_return_t pre(test_callback_fn* func, void *object) { return _pre_runner_default(libmemcached_test_callback_fn(func), (libmemcached_test_container_st*)object);