Absorb test bits into anonymous structure.
authorBrian Aker <brian@gaz>
Mon, 11 Jan 2010 21:07:36 +0000 (13:07 -0800)
committerBrian Aker <brian@gaz>
Mon, 11 Jan 2010 21:07:36 +0000 (13:07 -0800)
tests/atomsmasher.c
tests/function.c
tests/plus.cpp
tests/test.c
tests/test.h
tests/udp.c

index b0abc4ed38190668459445681969f870f44360db..3e759767c9b74c16e6c5bd5352feebec82e69869 100644 (file)
@@ -235,12 +235,15 @@ collection_st collection[] ={
 void get_world(world_st *world)
 {
   world->collections= collection;
-  world->test_startup= (test_callback_fn)world_test_startup;
-  world->flush= (test_callback_fn)world_flush;
-  world->pre_run= (test_callback_fn)world_pre_run;
+
   world->create= (test_callback_create_fn)world_create;
-  world->post_run= (test_callback_fn)world_post_run;
-  world->on_error= (test_callback_error_fn)world_on_error;
   world->destroy= (test_callback_fn)world_destroy;
+
+  world->test.startup= (test_callback_fn)world_test_startup;
+  world->test.flush= (test_callback_fn)world_flush;
+  world->test.pre_run= (test_callback_fn)world_pre_run;
+  world->test.post_run= (test_callback_fn)world_post_run;
+  world->test.on_error= (test_callback_error_fn)world_on_error;
+
   world->runner= &defualt_libmemcached_runner;
 }
index dc3436b17c4fa6173bc4276cb95006ca8fe9c324..f0b10af07cf0d5f6c91f90311c851a7cf2902011 100644 (file)
@@ -5814,12 +5814,15 @@ collection_st collection[] ={
 void get_world(world_st *world)
 {
   world->collections= collection;
-  world->test_startup= (test_callback_fn)world_test_startup;
-  world->flush= (test_callback_fn)world_flush;
-  world->pre_run= (test_callback_fn)world_pre_run;
+
   world->create= (test_callback_create_fn)world_create;
-  world->post_run= (test_callback_fn)world_post_run;
-  world->on_error= (test_callback_error_fn)world_on_error;
   world->destroy= (test_callback_fn)world_destroy;
+
+  world->test.startup= (test_callback_fn)world_test_startup;
+  world->test.flush= (test_callback_fn)world_flush;
+  world->test.pre_run= (test_callback_fn)world_pre_run;
+  world->test.post_run= (test_callback_fn)world_post_run;
+  world->test.on_error= (test_callback_error_fn)world_on_error;
+
   world->runner= &defualt_libmemcached_runner;
 }
index eba08c08d56460a7ae71cec10c72906fc76bb9c9..7a37ee17faeceb0d26623d975de3b14f7a4b28ec 100644 (file)
@@ -299,12 +299,15 @@ collection_st collection[] ={
 void get_world(world_st *world)
 {
   world->collections= collection;
-  world->test_startup= reinterpret_cast<test_callback_fn>(world_test_startup);
-  world->flush= reinterpret_cast<test_callback_fn>(world_flush);
-  world->pre_run= reinterpret_cast<test_callback_fn>(world_pre_run);
+
   world->create= reinterpret_cast<test_callback_create_fn>(world_create);
-  world->post_run= reinterpret_cast<test_callback_fn>(world_post_run);
-  world->on_error= reinterpret_cast<test_callback_error_fn>(world_on_error);
   world->destroy= reinterpret_cast<test_callback_fn>(world_destroy);
+
+  world->test.startup= reinterpret_cast<test_callback_fn>(world_test_startup);
+  world->test.flush= reinterpret_cast<test_callback_fn>(world_flush);
+  world->test.pre_run= reinterpret_cast<test_callback_fn>(world_pre_run);
+  world->test.post_run= reinterpret_cast<test_callback_fn>(world_post_run);
+  world->test.on_error= reinterpret_cast<test_callback_error_fn>(world_on_error);
+
   world->runner= &defualt_libmemcached_runner;
 }
index ff6bca680966e1125041e57a6efa737ba415a1b8..27f7f1b0d32f6c507fccb5743b508617cfbd0161 100644 (file)
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
 
     if (world.collection_startup)
     {
-      collection_rc= world.test_startup(world_ptr);
+      collection_rc= world.collection_startup(world_ptr);
     }
 
     switch (collection_rc)
@@ -196,45 +196,48 @@ int main(int argc, char *argv[])
 
       fprintf(stderr, "Testing %s", run->name);
 
-      if (world.test_startup)
+      if (world.test.startup)
       {
-        world.test_startup(world_ptr);
+        world.test.startup(world_ptr);
       }
 
-      if (run->requires_flush && world.flush)
+      if (run->requires_flush && world.test.flush)
       {
-        world.flush(world_ptr);
+        world.test.flush(world_ptr);
       }
 
-      if (world.pre_run)
+      if (world.test.pre_run)
       {
-        world.pre_run(world_ptr);
+        world.test.pre_run(world_ptr);
       }
 
 
-      if (next->pre && world.runner->pre)
+      // Runner code
       {
-        return_code= world.runner->pre(next->pre, world_ptr);
-
-        if (return_code != TEST_SUCCESS)
+        if (next->pre && world.runner->pre)
         {
-          goto error;
+          return_code= world.runner->pre(next->pre, world_ptr);
+
+          if (return_code != TEST_SUCCESS)
+          {
+            goto error;
+          }
         }
-      }
 
-      gettimeofday(&start_time, NULL);
-      return_code= world.runner->run(run->test_fn, world_ptr);
-      gettimeofday(&end_time, NULL);
-      load_time= timedif(end_time, start_time);
+        gettimeofday(&start_time, NULL);
+        return_code= world.runner->run(run->test_fn, world_ptr);
+        gettimeofday(&end_time, NULL);
+        load_time= timedif(end_time, start_time);
 
-      if (next->post && world.runner->post)
-      {
-        (void) world.runner->post(next->post, world_ptr);
+        if (next->post && world.runner->post)
+        {
+          (void) world.runner->post(next->post, world_ptr);
+        }
       }
 
-      if (world.post_run)
+      if (world.test.post_run)
       {
-        world.post_run(world_ptr);
+        world.test.post_run(world_ptr);
       }
 
 error:
@@ -267,10 +270,10 @@ error:
 
       fprintf(stderr, "[ %s ]\n", test_strerror(return_code));
 
-      if (world.on_error)
+      if (world.test.on_error)
       {
         test_return_t rc;
-        rc= world.on_error(return_code, world_ptr);
+        rc= world.test.on_error(return_code, world_ptr);
 
         if (rc != TEST_SUCCESS)
           break;
index d5be8c3024cd5cc12f787013926904d91308a4e3..39b141250ad7d76fc10caa9c190caff9a611cd37 100644 (file)
@@ -82,8 +82,25 @@ struct world_st {
   test_callback_create_fn create;
   test_callback_fn destroy;
 
-  /* This is called a the beginning of any test run. */
-  test_callback_fn test_startup;
+  struct {
+    /* This is called a the beginning of any test run. */
+    test_callback_fn startup;
+
+    /* This called on a test if the test requires a flush call (the bool is from test_st) */
+    test_callback_fn flush;
+
+    /**
+      These are run before/after the test. If implemented. Their execution is not controlled
+      by the test.
+    */
+    test_callback_fn pre_run;
+    test_callback_fn post_run;
+
+    /**
+      If an error occurs during the test, this is called.
+    */
+    test_callback_error_fn on_error;
+  } test;
 
   /* This is called a the beginning of any collection run. */
   test_callback_fn collection_startup;
@@ -91,20 +108,6 @@ struct world_st {
   /* This is called a the beginning of any collection run. */
   test_callback_fn collection_shutdown;
 
-  /* This called on a test if the test requires a flush call (the bool is from test_st) */
-  test_callback_fn flush;
-
-  /**
-    These are run before/after the test. If implemented. Their execution is not controlled
-    by the test.
-  */
-  test_callback_fn pre_run;
-  test_callback_fn post_run;
-
-  /**
-    If an error occurs during the test, this is called.
-  */
-  test_callback_error_fn on_error;
 
   /**
     Runner represents the callers for the tests. If not implemented we will use
index c66f10853349a72979f17673a03b1c212a2aed7f..232d6b6444e212288416eb350da29757ffecc631 100644 (file)
@@ -59,12 +59,15 @@ collection_st collection[] ={
 void get_world(world_st *world)
 {
   world->collections= collection;
-  world->test_startup= (test_callback_fn)world_test_startup;
-  world->flush= (test_callback_fn)world_flush;
-  world->pre_run= (test_callback_fn)world_pre_run;
+
   world->create= (test_callback_create_fn)world_create;
-  world->post_run= (test_callback_fn)world_post_run;
-  world->on_error= (test_callback_error_fn)world_on_error;
   world->destroy= (test_callback_fn)world_destroy;
+
+  world->test.startup= (test_callback_fn)world_test_startup;
+  world->test.flush= (test_callback_fn)world_flush;
+  world->test.pre_run= (test_callback_fn)world_pre_run;
+  world->test.post_run= (test_callback_fn)world_post_run;
+  world->test.on_error= (test_callback_error_fn)world_on_error;
+
   world->runner= &defualt_libmemcached_runner;
 }