void TcuExecute(void) { if (TestGetAutomatic()) { if (TestGetFilename()) { CU_set_output_filename(TestGetFilename()); } CU_automated_run_tests(); } else if (TestGetBasic()) { CU_basic_set_mode(CU_BRM_VERBOSE); (void) CU_basic_run_tests(); } else if (TestGetConsole()) { CU_console_run_tests(); } else if (TestGetList()) { if (TestGetFilename()) { CU_set_output_filename(TestGetFilename()); } (void) CU_list_tests_to_file(); } if (CU_get_number_of_tests_failed()) { return; } /* Clean up the registry */ CU_cleanup_registry(); }
int main(int argc, char *argv[]) { CU_pSuite parsersuite = NULL; if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); parsersuite = CU_add_suite("Session C parser", setup_parsersuite, teardown_parsersuite); if (NULL == parsersuite) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(parsersuite, "Empty Global protocol", &test_empty_global)) || (NULL == CU_add_test(parsersuite, "Empty Local protocol", &test_empty_local))) { CU_cleanup_registry(); return CU_get_error(); } CU_console_run_tests(); CU_cleanup_registry(); return CU_get_error(); }
int main(int argc, char* argv[]) { int i; n = 10; x = (double *)malloc(sizeof(double) * n); y = (double *)malloc(sizeof(double) * n); a = (double **)malloc(sizeof(double *) * n); *a = (double *)malloc(sizeof(double) * n * n); for (i = 1; i < n; ++i) a[i] = a[i - 1] + n; CU_pSuite testSuite; CU_initialize_registry(); testSuite = CU_add_suite("mymath.c TestSuite", NULL, NULL); CU_add_test(testSuite, "dot_product Test", test_dot_product); CU_add_test(testSuite, "update_step_vector Test", test_update_step_vector); CU_add_test(testSuite, "manhattan_norm Test", test_manhattan_norm); CU_add_test(testSuite, "euclidean_norm Test", test_euclidean_norm); CU_add_test(testSuite, "infinity_norm Test", test_infinity_norm); CU_add_test(testSuite, "gauss_seidel Test", test_gauss_seidel); CU_add_test(testSuite, "successive_over_relaxation Test", test_successive_over_relaxation); CU_console_run_tests(); CU_cleanup_registry(); free(x); free(y); free(*a); free(a); return 0; }
int main(int argc, char *argv[]) { int basic; int console; int automated; /* parse the command line options */ while ((c = getopt(argc, argv, "abc")) != -1) { switch (c) { case 'a': /* basic mode */ basic = 1; break; case 'b': /* basic mode */ basic = 1; break; case 'c': /* run from command line */ console = 1; break; default: /* error, print usage */ usage(argv[0]); return -1; } } if (CU_initialize_registry()) { fprintf(stderr, "\nInitialization of Test Registry failed.\n"); exit(EXIT_FAILURE); } else { AddTests(); // set up the run mode and run the tests if (automated) { CU_set_output_filename("TestOutput.xml"); CU_list_tests_to_file(); CU_automated_run_tests(); } else if (basic) { CU_BasicRunMode mode = CU_BRM_VERBOSE; CU_ErrorAction error_action = CUEA_IGNORE; CU_basic_set_mode(mode); CU_set_error_action(error_action); CU_basic_run_tests(); } else if (console) { CU_console_run_tests(); } CU_cleanup_registry(); } return 0; }
int main(int argc, char** argv) { CU_pSuite suite; CU_initialize_registry(); suite = CU_add_suite("all", NULL, NULL); CU_add_test(suite, "test_001", test_message_1); CU_add_test(suite, "test_002", test_message_2); CU_console_run_tests(); CU_cleanup_registry(); return 0; }
int main (void) { CU_pSuite pSuite = NULL; /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); /* add a suite to the registry */ pSuite = CU_add_suite("Suite1", init_suite1, clean_suite1); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ((NULL == CU_add_test(pSuite, " 1: Requesting a single record in a compressed warc file", test1)) || (NULL == CU_add_test(pSuite, " 2: Requesting a whole warc file", test2)) || (NULL == CU_add_test(pSuite, " 3: sending a bad request", test3)) || (NULL == CU_add_test(pSuite," 4: sending a filter request", test4)) || (NULL == CU_add_test(pSuite," 5: sending a List request with severral output format", test5))) { CU_cleanup_registry(); return CU_get_error(); } /* Run all tests using the automated interface*/ switch (menu()) { case 1: {CU_console_run_tests(); break;} case 2: { case 21: {CU_basic_set_mode(CU_BRM_NORMAL); CU_basic_run_tests(); break;} case 22:{CU_basic_set_mode(CU_BRM_VERBOSE ); CU_basic_run_tests(); break;} case 23:{CU_basic_set_mode(CU_BRM_SILENT); CU_basic_run_tests(); break;} } case 3:{ CU_set_output_filename("./utest/outputs/client"); CU_set_output_filename("./utest/outputs/client" ); CU_automated_run_tests(); CU_list_tests_to_file(); break;} } CU_cleanup_registry(); return CU_get_error(); }
int main() { CU_pSuite base_suite; CU_initialize_registry(); base_suite = CU_add_suite("Base functions", NULL, NULL); CU_add_test(base_suite, "func01_OK", test_func01_OK); CU_add_test(base_suite, "func02_OK", test_func02_OK); CU_console_run_tests(); CU_cleanup_registry(); return 0; }
int consoleTest(int argc, char* argv[]) { CU_BOOL Run = CU_FALSE ; setvbuf(stdout, NULL, _IONBF, 0); if (argc > 1) { if (!strcmp("-i", argv[1])) { Run = CU_TRUE ; CU_set_error_action(CUEA_IGNORE); } else if (!strcmp("-f", argv[1])) { Run = CU_TRUE ; CU_set_error_action(CUEA_FAIL); } else if (!strcmp("-A", argv[1])) { Run = CU_TRUE ; CU_set_error_action(CUEA_ABORT); } // else if (!strcmp("-e", argv[1])) { // print_example_results(); // } else { printf("\nUsage: ConsoleTest [option]\n\n" "Options: -i Run, ignoring framework errors [default].\n" " -f Run, failing on framework error.\n" " -A run, aborting on framework error.\n" // " -e Print expected test results and exit.\n" " -h Print this message.\n\n"); } } else { Run = CU_TRUE; CU_set_error_action(CUEA_IGNORE); } if (CU_TRUE == Run) { if (CU_initialize_registry()) { printf("\nInitialization of Test Registry failed."); } else { AddTests(); CU_console_run_tests(); CU_cleanup_registry(); } } return 0; }
int main() { CU_ErrorCode err; err = CU_initialize_registry(); if(err != CUE_SUCCESS) { return CU_get_error(); } CU_SuiteInfo suites[] = { /* Basic component test */ {"Log Test", InitSuiteDefault, EndSuiteDefault, NULL, NULL, LogTest}, {"Module Test", InitSuiteDefault, EndSuiteDefault, NULL, NULL, ModuleTest}, {"VBM Test", InitSuiteDefault, EndSuiteDefault, NULL, NULL, VBMTest}, /* Emulator test */ {"Emulator Test", InitSuiteDefault, EndSuiteDefault, NULL, NULL, EmulatorTest}, /* Actual modules test */ {"FrameSource Test", InitSuiteDefault, EndSuiteDefault, NULL, NULL, FrameSourceTest}, {"Encoder Test", InitSuiteDefault, EndSuiteDefault, NULL, NULL, EncoderTest}, /* Integrated test */ {"Entire Test", InitSuiteDefault, EndSuiteDefault, NULL, NULL, EntireTest}, {"Error Test", InitSuiteDefault, EndSuiteDefault, NULL, NULL, ErrorTest}, CU_SUITE_INFO_NULL, }; err = CU_register_suites(suites); if(err != CUE_SUCCESS) { CU_cleanup_registry(); return CU_get_error(); } #ifdef RUN_DIRECTLY CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); #else CU_console_run_tests(); #endif CU_cleanup_registry(); return 0; }
int main(int argc, char **argv) { /* 初始化CUnit框架 */ if(CU_initialize_registry()){ fprintf(stderr, " Initialization of Test Registry failed\n"); exit(EXIT_FAILURE); } /* 添加测试suite和test */ /* ------------------ 需要添加修改 ------------------------ */ test_maxi_AddSuites(); test_mini_AddSuites(); /* -------------------------------------------------------- */ /* 设置输出模式 start */ #if 0 // Automated CU_set_output_filename("TestMax"); CU_list_tests_to_file(); CU_automated_run_tests(); #endif #if 1 //basic CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); #endif #if 0 //Console CU_console_run_tests(); #endif #if 0 // Curses CU_curses_run_tests(); #endif /* 设置输出接口 end */ /* 清理CUnit框架 */ CU_cleanup_registry(); return 0; }
int main (int argc, char **argv) { CU_ErrorCode cuError; cuError = CU_initialize_registry(); if (cuError == CUE_NOMEMORY) { DbgLog(__FILE__, "%d CU_initialize_registry failed\n", __LINE__); return 1; } if (AddTests() != 0) { DbgLog(__FILE__, "line:%d AddTests failed\n", __LINE__); return 1; } CU_console_run_tests(); CU_cleanup_registry(); return 0; }
int main(int argc){ CU_ErrorCode erc = CU_initialize_registry(); if(erc == CUE_SUCCESS){ fprintf(stdout,"\ntest register initialized successfully!\n"); } else{ fprintf(stdout, "failed to initialize test register"); return; } /* add test for the states */ CU_pSuite generate_value_Con_motor = CU_add_suite("Extract states", NULL, NULL); test_check("Suite extract_states"); CU_add_test(generate_value_Con_motor, "Test motors", test_motors); test_check("Test test_motors"); CU_console_run_tests(); CU_cleanup_registry(); }
int main(void) { CU_pSuite _tSuite_insertSort; CU_pSuite _tSuite__insertSort; CU_initialize_registry(); // テストスイート _tSuite_insertSort = CU_add_suite("test_insertSort", NULL, NULL); _tSuite__insertSort = CU_add_suite("test__insertSort", NULL, NULL); // テストケース CU_add_test( _tSuite__insertSort, "test__insertSort01", test__insertSort01 ); CU_add_test( _tSuite__insertSort, "test__insertSort02", test__insertSort02 ); CU_add_test( _tSuite__insertSort, "test__insertSort03", test__insertSort03 ); CU_add_test( _tSuite_insertSort, "test_insertSort01", test_insertSort01 ); CU_add_test( _tSuite_insertSort, "test_insertSort02", test_insertSort02 ); // テスト実行 CU_console_run_tests(); // テストレジストリ削除 CU_cleanup_registry(); return 0; }
int main(int argc, char** argv) { CU_pSuite pSuite; CU_initialize_registry(); pSuite = CU_add_suite("TestHello", TestInit, TestClean); CU_add_test(pSuite, "testAssertTrue", testAssertTrue); CU_console_run_tests(); CU_cleanup_registry(); DArray* darray = (DArray*) malloc( sizeof( DArray )); memset( darray, 0x00 ,sizeof(DArray)); char* name = (char*) malloc( sizeof(char)*100); sprintf( name, "kakasi"); darray_append( darray, sizeof(char)*strlen(name), name); darray_for_each( darray, print_content_char, NULL ); darray_destory( darray ); return 0; }
/* The main() function for setting up and running the tests. * Returns a CUE_SUCCESS on successful running, another * CUnit error code on failure. */ int main(int argc, char *argv[]) { #ifdef HAVE_CUNIT int xml = 0; int con = 0; CU_pFailureRecord fr; int size; int i; int rv; if (argc >= 2 && !strcmp(argv[1], "-xml")) { xml = 1; } else if (argc >= 2 && !strcmp(argv[1], "-con")) { con = 1; } est_apps_startup(); est_set_log_source(EST_CLIENT); /* * Install thread locking mechanism for OpenSSL */ size = sizeof(pthread_mutex_t) * CRYPTO_num_locks(); if ((ssl_mutexes = (pthread_mutex_t*)malloc((size_t)size)) == NULL) { printf("Cannot allocate mutexes"); exit(1); } for (i = 0; i < CRYPTO_num_locks(); i++) { pthread_mutex_init(&ssl_mutexes[i], NULL); } CRYPTO_set_locking_callback(&ssl_locking_callback); CRYPTO_set_id_callback(&ssl_id_callback); /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) { return CU_get_error(); } #define ADD(N) { extern int N##_add_suite(void); rv = N##_add_suite(); \ if (rv != CUE_SUCCESS) { fprintf(stderr, "Failed "#N"_add_suite (%d)\n", rv); exit(1); } } ADD(us748); ADD(us893); ADD(us894); ADD(us895); ADD(us896); ADD(us897); ADD(us898); ADD(us899); ADD(us900); ADD(us901); ADD(us902); ADD(us903); ADD(us1005); ADD(us1060); ADD(us1159); ADD(us1864); ADD(us1883); ADD(us1884); ADD(us2174); if (xml) { /* Run all test using automated interface, which * generates XML output */ CU_list_tests_to_file(); CU_automated_run_tests(); } else if (con) { CU_console_run_tests(); } else { /* Run all tests using the CUnit Basic interface, * which generates text output */ #if 0 CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); #else CU_set_test_start_handler (test_start); CU_set_test_complete_handler(test_complete); CU_run_all_tests(); #endif fr = CU_get_failure_list(); if (fr) { fprintf(stderr, "\nHere is a summary of the failed test cases:\n"); print_failures(fr); } else { fprintf(stderr, "\nAll enabled tests passed.\n"); } } /* * Tear down the mutexes used by OpenSSL */ CRYPTO_set_locking_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) { pthread_mutex_destroy(&ssl_mutexes[i]); } CRYPTO_set_locking_callback(NULL); CRYPTO_set_id_callback(NULL); free(ssl_mutexes); CU_cleanup_registry(); est_apps_shutdown(); return CU_get_error(); #else printf("\nlibcunit not installed, unit tests are not enabled\n"); return 255; #endif }
/* The main() function for setting up and running the tests. * Returns a CUE_SUCCESS on successful running, another * CUnit error code on failure. */ int main(int argc, char *argv[]) { int xml = 0; int con = 0; CU_pFailureRecord fr; int i; if (argc >= 2 && !strcmp(argv[1], "-xml")) { xml = 1; } else if (argc >= 2 && !strcmp(argv[1], "-con")) { con = 1; } #ifdef HAVE_CUNIT int rv; #ifndef WIN32 struct sigaction sig_act; /* * Indicate that the broken pipe signal during writes should be * ignored */ memset(&sig_act, 0, sizeof(struct sigaction)); sig_act.sa_handler = SIG_IGN; sigemptyset(&sig_act.sa_mask); if (sigaction(SIGPIPE, &sig_act, NULL) == -1) { printf("\nCannot set ignore action for SIGPIPE\n"); } #endif est_apps_startup(); /* * Install thread locking mechanism for OpenSSL */ mutex_buf = malloc(CRYPTO_num_locks() * sizeof(MUTEX_TYPE)); if (!mutex_buf) { printf("Cannot allocate mutexes"); exit(1); } for (i = 0; i < CRYPTO_num_locks(); i++) MUTEX_SETUP(mutex_buf[i]); CRYPTO_set_id_callback(id_function); CRYPTO_set_locking_callback(locking_function); /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) { return CU_get_error(); } #ifdef ENABLE_ALL_SUITES rv = us748_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US748 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us893_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US893 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us894_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US894 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us895_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US895 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us896_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US896 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us897_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US897 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us898_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US898 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us899_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US899 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us900_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US900 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us901_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US901 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us902_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US902 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us903_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US903 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1005_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1005 (%d)", rv); exit(1); } #endif #if (DISABLE_SUITE != 0) rv = us1060_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1060 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1060c_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1060c (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1159_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1159 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1190_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1190 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1864_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1864 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1883_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1883 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us1884_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US1884 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us2174_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US2174 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us3496_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US3496 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us3512_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US3512 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us3612_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US3612 (%d)", rv); exit(1); } #endif #ifdef ENABLE_ALL_SUITES rv = us4020_add_suite(); if (rv != CUE_SUCCESS) { printf("\nFailed to add test suite for US4020 (%d)", rv); exit(1); } #endif if (xml) { /* Run all test using automated interface, which * generates XML output */ CU_list_tests_to_file(); CU_automated_run_tests(); } else if (con) { CU_console_run_tests(); } else { /* Run all tests using the CUnit Basic interface, * which generates text output */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); fr = CU_get_failure_list(); if (fr) { printf("\n\nHere is a summary of the failed test cases:\n"); CU_basic_show_failures(fr); } } /* * Tear down the mutexes used by OpenSSL */ if (!mutex_buf) return 0; CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) MUTEX_CLEANUP(mutex_buf[i]); free(mutex_buf); mutex_buf = NULL; CU_cleanup_registry(); est_apps_shutdown(); return CU_get_error(); #else printf("\nlibcunit not installed, unit test are not enabled\n"); #endif }