X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Ftest.c;h=215218c5f068e5a3f9bfc26c26a419d03bf9cd72;hb=8984944bbc4a973dd26ea48120240ef86698266d;hp=903ad4ee9e87610741a56bb9f1590fc16969405d;hpb=c67da677fe0944d3d2d3ff46e65fc3bc775404ae;p=m6w6%2Flibmemcached diff --git a/tests/test.c b/tests/test.c index 903ad4ee..215218c5 100644 --- a/tests/test.c +++ b/tests/test.c @@ -9,6 +9,9 @@ /* Sample test application. */ + +#include "config.h" + #include #include #include @@ -21,6 +24,7 @@ #include #include +#include "libmemcached/memcached.h" #include "test.h" static void world_stats_print(world_stats_st *stats) @@ -37,7 +41,7 @@ static void world_stats_print(world_stats_st *stats) fprintf(stderr, "\tSucceeded\t\t%u\n", stats->success); } -static long int timedif(struct timeval a, struct timeval b) +long int timedif(struct timeval a, struct timeval b) { long us, s; @@ -147,6 +151,14 @@ int main(int argc, char *argv[]) world_stats_st stats; +#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT + if (sasl_client_init(NULL) != SASL_OK) + { + fprintf(stderr, "Failed to initialize sasl library!\n"); + return 1; + } +#endif + memset(&stats, 0, sizeof(stats)); memset(&world, 0, sizeof(world)); get_world(&world); @@ -186,6 +198,15 @@ int main(int argc, char *argv[]) collection_rc= world.collection.startup(world_ptr); + if (collection_rc != TEST_SUCCESS) + goto skip_pre; + + if (next->pre) + { + collection_rc= world.runner->pre(next->pre, world_ptr); + } + +skip_pre: switch (collection_rc) { case TEST_SUCCESS: @@ -193,12 +214,12 @@ int main(int argc, char *argv[]) break; case TEST_FAILURE: fprintf(stderr, "\n%s [ failed ]\n\n", next->name); - stats.failed++; - continue; + stats.collection_failed++; + goto cleanup; case TEST_SKIPPED: fprintf(stderr, "\n%s [ skipping ]\n\n", next->name); - stats.skipped++; - continue; + stats.collection_skipped++; + goto cleanup; case TEST_MEMORY_ALLOCATION_FAILURE: case TEST_MAXIMUM_RETURN: default: @@ -206,6 +227,7 @@ int main(int argc, char *argv[]) break; } + for (x= 0; run->name; run++) { struct timeval start_time, end_time; @@ -234,6 +256,7 @@ int main(int argc, char *argv[]) // Runner code { +#if 0 if (next->pre && world.runner->pre) { return_code= world.runner->pre(next->pre, world_ptr); @@ -243,16 +266,19 @@ int main(int argc, char *argv[]) goto error; } } +#endif 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 0 if (next->post && world.runner->post) { (void) world.runner->post(next->post, world_ptr); } +#endif } if (world.test.post_run) @@ -260,7 +286,6 @@ int main(int argc, char *argv[]) world.test.post_run(world_ptr); } -error: stats.total++; fprintf(stderr, "\t\t\t\t\t"); @@ -300,20 +325,16 @@ error: } } - if (failed) + if (next->post && world.runner->post) { - stats.collection_failed++; - } - - if (skipped) - { - stats.collection_skipped++; + (void) world.runner->post(next->post, world_ptr); } if (! failed && ! skipped) { stats.collection_success++; } +cleanup: world.collection.shutdown(world_ptr); } @@ -341,5 +362,9 @@ error: world_stats_print(&stats); +#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT + sasl_done(); +#endif + return stats.failed == 0 ? 0 : 1; }