int main(int argc, char **argv) { (void)argc; (void)argv; test_null_alloc(); test_null_malloc(); test_null_free(); test_alloc_overflow(); test_alloc_underflow(); test_malloc_failure(); test_free_null_codec(); test_double_free(); test_foreach(); test_foreach_null_args(); test_decode_null_args(); test_encode_null_args(); test_resize_overflow(); test_limit_null_realloc(); test_limit_realloc_failure(); test_trim_null_realloc(); test_trim_realloc_failure(); test_use_defunct_decoder(); test_use_busy_decoder(); test_limit_null_encoder(); test_limit_decoder(); test_limit_overflow(); test_limit_overflow_no_realloc(); test_limit_between_two_resizes(); test_use_defunct_encoder(); test_use_busy_encoder(); test_resize_null_codec(); test_trim_null_codec(); test_trim_to_limit(); test_resize_realloc_failure(); test_clean_null_field(); test_clean_unknown_field(); test_clean_indexed_field_with_name(); test_clean_indexed_field_with_value(); test_clean_indexed_field_with_indexed_name(); test_strerror(); return (0); }
bool torture_local_replace(struct torture_context *ctx) { bool ret = true; ret &= test_ftruncate(); ret &= test_strlcpy(); ret &= test_strlcat(); ret &= test_mktime(); ret &= test_initgroups(); ret &= test_memmove(); ret &= test_strdup(); ret &= test_setlinebuf(); ret &= test_vsyslog(); ret &= test_timegm(); ret &= test_setenv(); ret &= test_strndup(); ret &= test_strnlen(); ret &= test_waitpid(); ret &= test_seteuid(); ret &= test_setegid(); ret &= test_asprintf(); ret &= test_snprintf(); ret &= test_vasprintf(); ret &= test_vsnprintf(); ret &= test_opendir(); ret &= test_readdir(); ret &= test_telldir(); ret &= test_seekdir(); ret &= test_dlopen(); ret &= test_chroot(); ret &= test_bzero(); ret &= test_strerror(); ret &= test_errno(); ret &= test_mkdtemp(); ret &= test_mkstemp(); ret &= test_pread(); ret &= test_pwrite(); ret &= test_getpass(); ret &= test_inet_ntoa(); ret &= test_strtoll(); ret &= test_strtoull(); ret &= test_va_copy(); ret &= test_FUNCTION(); ret &= test_MIN(); ret &= test_MAX(); ret &= test_socketpair(); ret &= test_strptime(); ret &= test_getifaddrs(); ret &= test_utime(); ret &= test_utimes(); ret &= test_memmem(); return ret; }
void kmo_do_tests() { kmo_error_start(); test_karray(); test_khash(); test_kstr(); test_strerror(); test_knp_msg(); test_mail_parse_addr_field(); test_b64(); test_util_bin_to_hex(); kmo_error_end(); printf("Tests passed.\n"); }
int main(int argc, char *argv[]) { test_return_t return_code; unsigned int x; char *collection_to_run= NULL; char *wildcard= NULL; world_st world; collection_st *collection; collection_st *next; void *world_ptr; 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); collection= init_world(&world); if (world.create) { test_return_t error; world_ptr= world.create(&error); if (error != TEST_SUCCESS) exit(1); } else { world_ptr= NULL; } if (argc > 1) collection_to_run= argv[1]; if (argc == 3) wildcard= argv[2]; for (next= collection; next->name; next++) { test_return_t collection_rc= TEST_SUCCESS; test_st *run; bool failed= false; bool skipped= false; run= next->tests; if (collection_to_run && fnmatch(collection_to_run, next->name, 0)) continue; stats.collection_total++; 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: fprintf(stderr, "\n%s\n\n", next->name); break; case TEST_FAILURE: fprintf(stderr, "\n%s [ failed ]\n\n", next->name); stats.collection_failed++; goto cleanup; case TEST_SKIPPED: fprintf(stderr, "\n%s [ skipping ]\n\n", next->name); stats.collection_skipped++; goto cleanup; case TEST_MEMORY_ALLOCATION_FAILURE: case TEST_MAXIMUM_RETURN: default: assert(0); break; } for (x= 0; run->name; run++) { struct timeval start_time, end_time; long int load_time= 0; if (wildcard && fnmatch(wildcard, run->name, 0)) continue; fprintf(stderr, "Testing %s", run->name); if (world.test.startup) { world.test.startup(world_ptr); } if (run->requires_flush && world.test.flush) { world.test.flush(world_ptr); } if (world.test.pre_run) { world.test.pre_run(world_ptr); } // Runner code { #if 0 if (next->pre && world.runner->pre) { return_code= world.runner->pre(next->pre, world_ptr); if (return_code != TEST_SUCCESS) { 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) { world.test.post_run(world_ptr); } stats.total++; fprintf(stderr, "\t\t\t\t\t"); switch (return_code) { case TEST_SUCCESS: fprintf(stderr, "%ld.%03ld ", load_time / 1000, load_time % 1000); stats.success++; break; case TEST_FAILURE: 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. break; } fprintf(stderr, "[ %s ]\n", test_strerror(return_code)); if (world.test.on_error) { test_return_t rc; rc= world.test.on_error(return_code, world_ptr); if (rc != TEST_SUCCESS) break; } } if (next->post && world.runner->post) { (void) world.runner->post(next->post, world_ptr); } if (! failed && ! skipped) { stats.collection_success++; } cleanup: world.collection.shutdown(world_ptr); } if (stats.collection_failed || stats.collection_skipped) { fprintf(stderr, "Some test failures and/or skipped test occurred.\n\n"); } else { fprintf(stderr, "All tests completed successfully\n\n"); } if (world.destroy) { test_return_t error; error= world.destroy(world_ptr); if (error != TEST_SUCCESS) { fprintf(stderr, "Failure during shutdown.\n"); stats.failed++; // We do this to make our exit code return 1 } } world_stats_print(&stats); #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT sasl_done(); #endif return stats.failed == 0 ? 0 : 1; }