int main(int argc, char *argv[]) { if (argc < 2) fail("To few arguments for test case"); #ifndef ETHR_NO_THREAD_LIB { char *testcase; send_my_pid(); testcase = argv[1]; if (ethr_init(NULL) != 0 || ethr_late_init(NULL) != 0) fail("Failed to initialize the ethread library"); if (strcmp(testcase, "create_join_thread") == 0) create_join_thread_test(); else if (strcmp(testcase, "equal_tids") == 0) equal_tids_test(); else if (strcmp(testcase, "mutex") == 0) mutex_test(); else if (strcmp(testcase, "try_lock_mutex") == 0) try_lock_mutex_test(); else if (strcmp(testcase, "cond_wait") == 0) cond_wait_test(); else if (strcmp(testcase, "broadcast") == 0) broadcast_test(); else if (strcmp(testcase, "detached_thread") == 0) detached_thread_test(); else if (strcmp(testcase, "max_threads") == 0) max_threads_test(); else if (strcmp(testcase, "tsd") == 0) tsd_test(); else if (strcmp(testcase, "spinlock") == 0) spinlock_test(); else if (strcmp(testcase, "rwspinlock") == 0) rwspinlock_test(); else if (strcmp(testcase, "rwmutex") == 0) rwmutex_test(); else if (strcmp(testcase, "atomic") == 0) atomic_test(); else if (strcmp(testcase, "dw_atomic_massage") == 0) dw_atomic_massage_test(); else skip("Test case \"%s\" not implemented yet", testcase); succeed(NULL); } #else /* #ifndef ETHR_NO_THREAD_LIB */ skip("No ethread library to test"); #endif /* #ifndef ETHR_NO_THREAD_LIB */ return 0; }
int main(int argc, char *argv[]) { if (argc < 2) fail("To few arguments for test case"); { char *testcase; int save_xres = 0; int i; send_my_pid(); testcase = argv[1]; #ifdef THREAD_SAFE { int res = ethr_init(NULL); if (res != 0) fail("Failed to initialize the ethread library"); } #endif for (i = 2; i < argc; i++) { if (strcmp(argv[i], "save_expected_result") == 0) { save_xres = 1; break; } } if (save_xres) { char filename[100]; sprintf(filename, "%s%s_test.h", testcase, sizeof(void *) == 8 ? "_64" : ""); printf("Saving expected result to %s\n", filename); outfile = fopen(filename, "w"); ASSERT(outfile); fprintf(outfile, "/*\n" " * %%CopyrightBegin%%\n" " * Copyright Ericsson AB 1996-2009. All Rights Reserved.\n" " * \n" " * The contents of this file are subject to the Erlang Public License,\n" " * Version 1.1, (the \"License\"); you may not use this file except in\n" " * compliance with the License. You should have received a copy of the\n" " * Erlang Public License along with this software. If not, it can be\n" " * retrieved online at http://www.erlang.org/.\n" " * \n" " * Software distributed under the License is distributed on an \"AS IS\"\n" " * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See\n" " * the License for the specific language governing rights and limitations\n" " * under the License.\n" " * %%CopyrightEnd%%\n" " */\n" "\n"); fprintf(outfile, "/* \n" " * This file has been automatically generated. Do NOT edit it; instead,\n" " * run '%s %s save_expected_result'%s.\n" " */\n" "\n", argv[0], testcase, sizeof(void *) == 8 ? " on a 64-bit machine" : ""); fprintf(outfile, "char *%s%s_expected_result[] = {\n", testcase, sizeof(void *) == 8 ? "_64" : ""); } if (strcmp("integer", testcase) == 0) integer_test(); else if (strcmp("float", testcase) == 0) float_test(); else if (strcmp("string", testcase) == 0) string_test(); else if (strcmp("character", testcase) == 0) character_test(); else if (strcmp("snprintf", testcase) == 0) snprintf_test(); else if (strcmp("quote", testcase) == 0) quote_test(); else if (!save_xres) skip("Test case \"%s\" not implemented yet", testcase); if (save_xres) { fprintf(outfile, "\tNULL};\n"); fclose(outfile); } succeed(NULL); } return 0; }