Refactor out item specific bits of the testing framework.
authorBrian Aker <brian@tangent.org>
Thu, 19 Apr 2012 14:26:08 +0000 (07:26 -0700)
committerBrian Aker <brian@tangent.org>
Thu, 19 Apr 2012 14:26:08 +0000 (07:26 -0700)
12 files changed:
libtest/framework.cc
libtest/framework.h
libtest/main.cc
tests/failure.cc
tests/libmemcached-1.0/all_tests.cc
tests/libmemcached-1.0/all_tests_socket.cc
tests/libmemcached-1.0/atomsmasher.cc
tests/libmemcached-1.0/plus.cpp
tests/libmemcached-1.0/sasl.cc
tests/libmemcached_world.h
tests/libmemcached_world_socket.h
tests/mem_udp.cc

index 3a4d85d5b9fec36ae4a8aa4a495399397f692c25..8e049e60cfa8acc1bb649c34d9bc95aac0377a2f 100644 (file)
@@ -58,26 +58,6 @@ Framework::~Framework()
   delete _runner;
 }
 
-test_return_t Framework::Item::pre(void *arg)
-{
-  if (pre_run)
-  {
-    return pre_run(arg);
-  }
-
-  return TEST_SUCCESS;
-}
-
-test_return_t Framework::Item::post(void *arg)
-{
-  if (post_run)
-  {
-    return post_run(arg);
-  }
-
-  return TEST_SUCCESS;
-}
-
 test_return_t Framework::Item::flush(void* arg, test_st* run)
 {
   if (run->requires_flush and _flush)
index c7341a725848e3ad98a0c9da86f527a11e65276c..04dc29da89be2ef5a5c93cab75450fa509c4658f 100644 (file)
@@ -80,20 +80,11 @@ public:
     */
     test_callback_fn *_flush;
 
-  private:
-    /*
-       Run before and after the runnner is executed.
-    */
-    test_callback_fn *pre_run;
-    test_callback_fn *post_run;
-
   public:
 
     Item() :
       _startup(NULL),
-      _flush(NULL),
-      pre_run(NULL),
-      post_run(NULL)
+      _flush(NULL)
     { }
 
     void set_startup(test_callback_fn *arg)
@@ -111,19 +102,7 @@ public:
       _flush= arg;
     }
 
-    void set_pre(test_callback_fn *arg)
-    {
-      pre_run= arg;
-    }
-
-    void set_post(test_callback_fn *arg)
-    {
-      pre_run= arg;
-    }
-
-    test_return_t pre(void *arg);
     test_return_t flush(void* arg, test_st* run);
-    test_return_t post(void *arg);
 
   } item;
 
index a5d90462582ca3653d73f4cd95aa4fd6e3d96597..dcbc50eb536879392b1bfa6ce9b1a373d299128e 100644 (file)
@@ -310,39 +310,32 @@ int main(int argc, char *argv[])
             {
               if (test_success(return_code= world.item.flush(creators_ptr, run)))
               {
-                // @note pre will fail is SKIPPED is returned
-                if (test_success(return_code= world.item.pre(creators_ptr)))
-                {
-                  { // Runner Code
-                    gettimeofday(&start_time, NULL);
-                    assert(world.runner());
-                    assert(run->test_fn);
-                    try 
+                { // Runner Code
+                  gettimeofday(&start_time, NULL);
+                  assert(world.runner());
+                  assert(run->test_fn);
+                  try 
+                  {
+                    return_code= world.runner()->run(run->test_fn, creators_ptr);
+                  }
+                  // Special case where check for the testing of the exception
+                  // system.
+                  catch (libtest::fatal &e)
+                  {
+                    if (fatal::is_disabled())
                     {
-                      return_code= world.runner()->run(run->test_fn, creators_ptr);
+                      fatal::increment_disabled_counter();
+                      return_code= TEST_SUCCESS;
                     }
-                    // Special case where check for the testing of the exception
-                    // system.
-                    catch (libtest::fatal &e)
+                    else
                     {
-                      if (fatal::is_disabled())
-                      {
-                        fatal::increment_disabled_counter();
-                        return_code= TEST_SUCCESS;
-                      }
-                      else
-                      {
-                        throw;
-                      }
+                      throw;
                     }
-
-                    gettimeofday(&end_time, NULL);
-                    load_time= timedif(end_time, start_time);
                   }
-                }
 
-                // @todo do something if post fails
-                (void)world.item.post(creators_ptr);
+                  gettimeofday(&end_time, NULL);
+                  load_time= timedif(end_time, start_time);
+                }
               }
               else if (return_code == TEST_SKIPPED)
               { }
index 4d81ecd4a9c94724f50814d01302991dfe3015b4..073cd17b862d0b595c451b01ecec4f77112cb86c 100644 (file)
@@ -219,9 +219,7 @@ void get_world(Framework *world)
   world->_destroy= (test_callback_destroy_fn*)world_destroy;
 
   world->item._startup= (test_callback_fn*)world_test_startup;
-  world->item.set_pre((test_callback_fn*)world_pre_run);
   world->item.set_flush((test_callback_fn*)world_flush);
-  world->item.set_post((test_callback_fn*)world_post_run);
   world->_on_error= (test_callback_error_fn*)world_on_error;
 
   world->collection_startup= (test_callback_fn*)world_container_startup;
index 5e2882c6d9d7109f5e015e315741614701454c0f..74c195d24825707b583b2b5a6f1a1352de76d665 100644 (file)
@@ -88,9 +88,7 @@ void get_world(Framework *world)
   world->_destroy= (test_callback_destroy_fn*)world_destroy;
 
   world->item._startup= (test_callback_fn*)world_test_startup;
-  world->item.set_pre((test_callback_fn*)world_pre_run);
   world->item.set_flush((test_callback_fn*)world_flush);
-  world->item.set_post((test_callback_fn*)world_post_run);
   world->_on_error= (test_callback_error_fn*)world_on_error;
 
   world->collection_startup= (test_callback_fn*)world_container_startup;
index 6398c1eba41e4852f4677626412090f99638cd3e..046bd2906d5b797ee6b8eb6830c75eb3f25aa51a 100644 (file)
@@ -77,9 +77,7 @@ void get_world(Framework *world)
   world->_destroy= (test_callback_destroy_fn*)world_destroy;
 
   world->item._startup= (test_callback_fn*)world_test_startup;
-  world->item.set_pre((test_callback_fn*)world_pre_run);
   world->item.set_flush((test_callback_fn*)world_flush);
-  world->item.set_post((test_callback_fn*)world_post_run);
   world->_on_error= (test_callback_error_fn*)world_on_error;
 
   world->collection_startup= (test_callback_fn*)world_container_startup;
index 23d6dd238cdbedefc8b2cc87f6d4fb48a4913986..2b7e9c12a4ab28bccd30e83b231c3e5075ee395a 100644 (file)
@@ -286,8 +286,6 @@ void get_world(Framework *world)
 
   world->item._startup= (test_callback_fn*)world_test_startup;
   world->item._flush= (test_callback_fn*)world_flush;
-  world->item.set_pre((test_callback_fn*)world_pre_run);
-  world->item.set_post((test_callback_fn*)world_post_run);
   world->_on_error= (test_callback_error_fn*)world_on_error;
 
   world->collection_startup= (test_callback_fn*)world_container_startup;
index 5b3f7e8855a9318b27f6d01685fab5be70582756..bd19feb0471c762846f5410be6f135d6e33d2592 100644 (file)
@@ -293,8 +293,6 @@ void get_world(Framework *world)
 
   world->item._startup= reinterpret_cast<test_callback_fn*>(world_test_startup);
   world->item._flush= reinterpret_cast<test_callback_fn*>(world_flush);
-  world->item.set_pre(reinterpret_cast<test_callback_fn*>(world_pre_run));
-  world->item.set_post(reinterpret_cast<test_callback_fn*>(world_post_run));
   world->_on_error= reinterpret_cast<test_callback_error_fn*>(world_on_error);
 
   world->collection_startup= reinterpret_cast<test_callback_fn*>(world_container_startup);
index bbf905d9716bfc5cf4bb232fdaf053dda65920fb..ee421300b0b3060326b69d52324e773b08f2a74f 100644 (file)
@@ -107,9 +107,7 @@ void get_world(Framework *world)
   world->_destroy= (test_callback_destroy_fn*)world_destroy;
 
   world->item._startup= (test_callback_fn*)world_test_startup;
-  world->item.set_pre((test_callback_fn*)world_pre_run);
   world->item.set_flush((test_callback_fn*)world_flush);
-  world->item.set_post((test_callback_fn*)world_post_run);
   world->_on_error= (test_callback_error_fn*)world_on_error;
 
   world->collection_startup= (test_callback_fn*)world_container_startup;
index c31b303fa911fae2221670f62fc5847d6fae0eff..ded47ada1ed66fb604a1ca2ccdde017101cab44c 100644 (file)
@@ -160,28 +160,6 @@ test_return_t world_flush(libmemcached_test_container_st *container)
   return TEST_SUCCESS;
 }
 
-static test_return_t world_pre_run(libmemcached_test_container_st *container)
-{
-  test_true(container->memc);
-  for (uint32_t loop= 0; loop < memcached_server_list_count(container->memc->servers); loop++)
-  {
-    memcached_server_instance_st instance= memcached_server_instance_by_position(container->memc, loop);
-
-    test_compare(-1, instance->fd);
-    test_compare(0U, instance->cursor_active);
-  }
-
-  return TEST_SUCCESS;
-}
-
-
-static test_return_t world_post_run(libmemcached_test_container_st *container)
-{
-  test_true(container->memc);
-
-  return TEST_SUCCESS;
-}
-
 static test_return_t world_on_error(test_return_t , libmemcached_test_container_st *container)
 {
   test_true(container->memc);
index 8016dba4ad6229dcafaf465d3f2b889ee39a42ba..4080a1b075d275a646ae86e0566ba6d73416ad2b 100644 (file)
@@ -141,29 +141,6 @@ test_return_t world_flush(libmemcached_test_container_st *container)
   return TEST_SUCCESS;
 }
 
-static test_return_t world_pre_run(libmemcached_test_container_st *container)
-{
-  test_true(container->memc);
-  for (uint32_t loop= 0; loop < memcached_server_list_count(container->memc->servers); loop++)
-  {
-    memcached_server_instance_st instance=
-      memcached_server_instance_by_position(container->memc, loop);
-
-    test_compare(-1, instance->fd);
-    test_compare(0U, instance->cursor_active);
-  }
-
-  return TEST_SUCCESS;
-}
-
-
-static test_return_t world_post_run(libmemcached_test_container_st *container)
-{
-  test_true(container->memc);
-
-  return TEST_SUCCESS;
-}
-
 static test_return_t world_on_error(test_return_t , libmemcached_test_container_st *container)
 {
   test_true(container->memc);
index 3a97d849c71db8f7e9e7f3fc3d6c8090a27ae0f0..17f9f55f3a515bdd89411f580eeec83720c849c1 100644 (file)
@@ -573,8 +573,6 @@ void get_world(Framework *world)
 
   world->item._startup= (test_callback_fn*)world_test_startup;
   world->item._flush= (test_callback_fn*)world_flush;
-  world->item.set_pre((test_callback_fn*)world_pre_run);
-  world->item.set_post((test_callback_fn*)world_post_run);
   world->_on_error= (test_callback_error_fn*)world_on_error;
 
   world->collection_startup= (test_callback_fn*)world_container_startup;