X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Ftest.c;h=0905e13b6fc94562c4303749af6b0c786910212d;hb=28adf7b936c6f5c25b7526ff56ec1256da1246d4;hp=da989b179638bfd95eed8cacefd012fea200b5f7;hpb=faae971a1b825275ed3585c9692be3d84a62ce01;p=awesomized%2Flibmemcached diff --git a/libtest/test.c b/libtest/test.c index da989b17..0905e13b 100644 --- a/libtest/test.c +++ b/libtest/test.c @@ -10,7 +10,7 @@ Sample test application. */ -#include "config.h" +#include #include @@ -24,8 +24,6 @@ #include #include -#include - #include #include @@ -61,10 +59,12 @@ const char *test_strerror(test_return_t code) return "ok"; case TEST_FAILURE: return "failed"; - case TEST_MEMORY_ALLOCATION_FAILURE: - return "memory allocation"; + case TEST_FATAL: + return "failed"; case TEST_SKIPPED: return "skipped"; + case TEST_MEMORY_ALLOCATION_FAILURE: + return "memory allocation"; case TEST_MAXIMUM_RETURN: default: fprintf(stderr, "Unknown return value\n"); @@ -148,7 +148,6 @@ int main(int argc, char *argv[]) char *wildcard= NULL; world_st world; collection_st *collection; - collection_st *next; void *world_ptr; world_stats_st stats; @@ -180,12 +179,23 @@ int main(int argc, char *argv[]) } if (argc > 1) + { collection_to_run= argv[1]; + } + else if (getenv("TEST_COLLECTION")) + { + collection_to_run= getenv("TEST_COLLECTION"); + } + + if (collection_to_run) + printf("Only testing %s\n", collection_to_run); if (argc == 3) + { wildcard= argv[2]; + } - for (next= collection; next->name; next++) + for (collection_st *next= collection; next->name; next++) { test_return_t collection_rc= TEST_SUCCESS; test_st *run; @@ -214,6 +224,10 @@ skip_pre: case TEST_SUCCESS: fprintf(stderr, "\n%s\n\n", next->name); break; + case TEST_FATAL: + fprintf(stderr, "\n%s [ failed ]\n\n", next->name); + stats.collection_failed++; + goto cleanup; case TEST_FAILURE: fprintf(stderr, "\n%s [ failed ]\n\n", next->name); stats.collection_failed++; @@ -298,6 +312,8 @@ skip_pre: fprintf(stderr, "%ld.%03ld ", load_time / 1000, load_time % 1000); stats.success++; break; + + case TEST_FATAL: case TEST_FAILURE: #if 0 push_failed_test(next->name, run->name); @@ -305,13 +321,16 @@ skip_pre: stats.failed++; failed= true; break; + case TEST_SKIPPED: stats.skipped++; skipped= true; break; + case TEST_MEMORY_ALLOCATION_FAILURE: fprintf(stderr, "Exhausted memory, quitting\n"); abort(); + case TEST_MAXIMUM_RETURN: default: assert(0); // Coding error. @@ -328,6 +347,12 @@ skip_pre: if (rc != TEST_SUCCESS) break; } + + // If we get a TEST_FATAL we move onto the next collection + if (return_code == TEST_FATAL) + { + break; + } } if (next->post && world.runner->post) @@ -370,9 +395,5 @@ cleanup: world_stats_print(&stats); -#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT - sasl_done(); -#endif - return stats.failed == 0 ? 0 : 1; }