int main ( void ) { CU_pSuite pSuite = NULL; if ( CUE_SUCCESS != CU_initialize_registry() ) return CU_get_error(); pSuite = CU_add_suite( "max_test_suite", init_suite, clean_suite ); if ( NULL == pSuite ) { CU_cleanup_registry(); return CU_get_error(); } if ( (NULL == CU_add_test(pSuite, "max_test_1", max_test_1)) || (NULL == CU_add_test(pSuite, "max_test_2", max_test_2)) || (NULL == CU_add_test(pSuite, "max_test_3", max_test_3)) ) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); CU_cleanup_registry(); return CU_get_error(); }
int main(void) { /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); /* add a suite to the registry */ if (1 == test_mman_suite()) return CU_get_error(); /* Run all tests using the basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); /* Report failures */ printf("\n\nSummary of failures:\n"); CU_basic_show_failures(CU_get_failure_list()); /* Clean up registry and return */ printf("\n\nCleaning ..."); CU_cleanup_registry(); return CU_get_error(); }
void bc_tester_uninit() { /* Redisplay list of failed tests on end */ if (CU_get_number_of_failure_records()){ CU_basic_show_failures(CU_get_failure_list()); } CU_cleanup_registry(); /*add missing final newline*/ bc_tester_printf(bc_printf_verbosity_info,""); if( xml_enabled ){ /*create real xml file only if tester did not crash*/ size_t size = strlen(xml_file) + strlen(".tmp-Results.xml") + 1; char * xml_tmp_file = malloc(sizeof(char) * size); snprintf(xml_tmp_file, size, "%s.tmp-Results.xml", xml_file); rename(xml_tmp_file, xml_file); free(xml_tmp_file); } if (test_suite != NULL) { free(test_suite); test_suite = NULL; nb_test_suites = 0; } if (bc_tester_resource_dir_prefix != NULL) { free(bc_tester_resource_dir_prefix); bc_tester_resource_dir_prefix = NULL; } if (bc_tester_writable_dir_prefix != NULL) { free(bc_tester_writable_dir_prefix); bc_tester_writable_dir_prefix = NULL; } }
int main() { CU_pSuite pSuite = NULL; if ( CUE_SUCCESS != CU_initialize_registry() ) return CU_get_error(); /* add a suite to the registry */ pSuite = CU_add_suite( "max_test_suite", init_suite, clean_suite ); if ( NULL == pSuite ) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ( (NULL == CU_add_test(pSuite, "test_strategy_stand", test_strategy_stand)) || (NULL == CU_add_test(pSuite, "test_strategy_dealer", test_strategy_dealer)) || (NULL == CU_add_test(pSuite, "test_strategy_basic", test_strategy_basic)) ) { CU_cleanup_registry(); return CU_get_error(); } // Run all tests using the basic interface CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); CU_cleanup_registry(); return CU_get_error(); }
int main(int argc, char **argv) { int status; if(CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); if(!(status = setup_object_tests()) || !(status = setup_list_tests())) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); CU_automated_run_tests(); CU_list_tests_to_file(); //CU_console_run_tests(); CU_cleanup_registry(); return CU_get_error(); }
/* MAIN */ int main(void) { CU_pSuite ste = NULL; if (CUE_SUCCESS != CU_initialize_registry()) { return CU_get_error(); } ste = CU_add_suite("sllist_suite", init_sllist_suite, clean_sllist1_suite); if (NULL == ste) { CU_cleanup_registry(); return CU_get_error(); } ADD_TEST(CU_add_test(ste, "Verify insert...", t_insert)); // CU_console_run_tests(); CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_suite(ste); CU_basic_show_failures(CU_get_failure_list()); CU_cleanup_registry(); printf("\n"); return CU_get_error(); }
/* *Function main. *This function builds the suite of tests. *After execution it shows a tabe that records all the tests and *that shows where there is an error. */ int main(){ CU_pSuite pSuite = NULL; if(CUE_SUCCESS != CU_initialize_registry()){ return CU_get_error(); } pSuite = CU_add_suite("Suite de tests pour sender.c et receiver.c", init_suite,clean_suite); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } if( (NULL == CU_add_test(pSuite,"test create socket",test_create_socket))) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_run_tests(); CU_basic_show_failures(CU_get_failure_list()); CU_cleanup_registry(); return CU_get_error(); }
int main(int argc, char const *argv[]) { if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); CU_pSuite pSuite = NULL; pSuite = CU_add_suite("Suite de tests : malloc", setup, teardown); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(pSuite, "Blocks réallouables", test_free_block_reallouable)) || (NULL == CU_add_test(pSuite, "Pointeur non null", test_malloc_pointeur_non_null)) || (NULL == CU_add_test(pSuite, "Deux pointeurs différents", test_malloc_deux_pointeurs_differents)) || (NULL == CU_add_test(pSuite, "Size 0", test_malloc_size_0)) || (NULL == CU_add_test(pSuite, "Pointeur invalide", test_free_malloc)) || (NULL == CU_add_test(pSuite, "Test valeur", test_malloc_ajout)) || (NULL == CU_add_test(pSuite, "Double Free", test_double_free)) || (NULL == CU_add_test(pSuite, "Test Calloc", callocTest))) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); CU_basic_show_failures(CU_get_failure_list()); CU_cleanup_registry(); return 0; }
int main(int argc, char const *argv[]) { if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); CU_pSuite pSuite = NULL; pSuite = CU_add_suite("Suite de tests : libfractal", setup, teardown); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(pSuite, "Name", test_libfractal_ptr_not_null)) || (NULL == CU_add_test(pSuite, "Name", test_libfractal_ptr_value_not_null)) || (NULL == CU_add_test(pSuite, "Name", test_libfractal_get_name)) || (NULL == CU_add_test(pSuite, "Name", test_libfractal_get_width)) || (NULL == CU_add_test(pSuite, "Name", test_libfractal_get_height)) || (NULL == CU_add_test(pSuite, "Name", test_libfractal_get_a)) || (NULL == CU_add_test(pSuite, "Name", test_libfractal_get_b))|| (NULL == CU_add_test(pSuite, "Name", test_libfractal_get_set_value))) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_run_tests(); CU_basic_show_failures(CU_get_failure_list()); CU_cleanup_registry(); return 0; }
int liblinphone_tester_run_tests(const char *suite_name, const char *test_name) { int i; int ret; /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); for (i = 0; i < liblinphone_tester_nb_test_suites(); i++) { run_test_suite(test_suite[i]); } if (suite_name){ CU_pSuite suite; CU_basic_set_mode(CU_BRM_VERBOSE); suite=CU_get_suite(suite_name); if (!suite) { ms_error("Could not find suite '%s'. Available suites are:", suite_name); liblinphone_tester_list_suites(); return -1; } else if (test_name) { CU_pTest test=CU_get_test_by_name(test_name, suite); if (!test) { ms_error("Could not find test '%s' in suite '%s'. Available tests are:", test_name, suite_name); // do not use suite_name here, since this method is case sentisitive liblinphone_tester_list_suite_tests(suite->pName); return -2; } else { CU_ErrorCode err= CU_basic_run_test(suite, test); if (err != CUE_SUCCESS) ms_error("CU_basic_run_test error %d", err); } } else { CU_basic_run_suite(suite); } } else { #if HAVE_CU_CURSES if (curses) { /* Run tests using the CUnit curses interface */ CU_curses_run_tests(); } else #endif { /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); } } ret=CU_get_number_of_tests_failed()!=0; /* Redisplay list of failed tests on end */ if (CU_get_number_of_failure_records()){ CU_basic_show_failures(CU_get_failure_list()); printf("\n"); } CU_cleanup_registry(); return ret; }
void bc_tester_uninit(void) { /* Redisplay list of failed tests on end */ /*BUG: do not display list of failures on mingw, it crashes mysteriously*/ #if !defined(WIN32) && !defined(_MSC_VER) /* Redisplay list of failed tests on end */ if (CU_get_number_of_failure_records()){ CU_basic_show_failures(CU_get_failure_list()); } #endif CU_cleanup_registry(); /*add missing final newline*/ bc_tester_printf(bc_printf_verbosity_info,""); if( xml_enabled ){ /*create real xml file only if tester did not crash*/ char * xml_tmp_file = bc_sprintf("%s.tmp-Results.xml", xml_file); rename(xml_tmp_file, xml_file); free(xml_tmp_file); } if (test_suite != NULL) { free(test_suite); test_suite = NULL; nb_test_suites = 0; } if (bc_tester_resource_dir_prefix != NULL) { free(bc_tester_resource_dir_prefix); bc_tester_resource_dir_prefix = NULL; } if (bc_tester_writable_dir_prefix != NULL) { free(bc_tester_writable_dir_prefix); bc_tester_writable_dir_prefix = NULL; } }
int main(){ CU_pSuite pSuite = NULL; if(CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); pSuite = CU_add_suite("Suite de tests pour my-sem",init_suite1,clean_suite1); if(pSuite == NULL){ CU_cleanup_registry(); return CU_get_error(); } if(CU_add_test(pSuite, "test_wait_bloquant",test_wait_bloquant) == NULL || CU_add_test(pSuite,"test_wait_add_end",test_wait_add_end) == NULL || CU_add_test(pSuite,"test_post_count",test_post_count) == NULL|| //CU_add_test(pSuite,"test_post_take_first",test_post_take_first) == NULL || CU_add_test(pSuite,"test_post_destroy",test_post_destroy) == NULL || CU_add_test(pSuite,"test_post_exceed_capacity",test_post_exceed_capacity) == NULL) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_run_tests(); CU_basic_show_failures(CU_get_failure_list()); CU_cleanup_registry(); return CU_get_error(); }
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( "libcomponent_test_suite", init_suite, clean_suite ); if ( NULL == pSuite ) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ((NULL == CU_add_test(pSuite, "libcomponent_tests", libcomponent_tests)) || (NULL == CU_add_test(pSuite, "power_of_ten_tests", power_of_ten_tests)) || (NULL == CU_add_test(pSuite, "find_nearest_E12_tests", find_nearest_E12_tests))) { CU_cleanup_registry(); return CU_get_error(); } // Run all tests using the basic interface CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); /* Clean up registry and return */ CU_cleanup_registry(); return CU_get_error(); }
/************* Test Runner Code goes here **************/ 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( "authentication_test_suite", init_suite, clean_suite ); if ( NULL == pSuite ) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ( (NULL == CU_add_test(pSuite, "auth_correct_commands_test", authentication_correct_commands_test)) || (NULL == CU_add_test(pSuite, "auth_wrong_commands_test", authentication_wrong_commands_test)) ) { CU_cleanup_registry(); return CU_get_error(); } // Run all tests using the basic interface CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); /* Clean up registry and return */ CU_cleanup_registry(); return CU_get_error(); }
int main() { // Set the library error handler to the custom one gmcmc_error_handler = cu_error_handler; // Initialise the CUnit test registry CU_ErrorCode error; if ((error = CU_initialize_registry()) != CUE_SUCCESS) { fprintf(stderr, "failed to initialise test registry: %s\n", CU_get_error_msg()); return error; } // Create a test suite within the registry CU_pSuite suite; if ((suite = CU_add_suite("prior", NULL, NULL)) == NULL) { fprintf(stderr, "failed to create test suite: %s\n", CU_get_error_msg()); return error; } // Add the tests to the suite if (CU_ADD_TEST(suite, test_prior_create) == NULL) { fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg()); return error; } if (CU_ADD_TEST(suite, test_prior_sample) == NULL) { fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg()); return error; } if (CU_ADD_TEST(suite, test_prior_evaluate) == NULL) { fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg()); return error; } if (CU_ADD_TEST(suite, test_prior_evaluate_1st_order) == NULL) { fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg()); return error; } if (CU_ADD_TEST(suite, test_prior_evaluate_2nd_order) == NULL) { fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg()); return error; } // Run the test suites using the CUnit basic interface if ((error = CU_basic_run_tests()) != CUE_SUCCESS) { fprintf(stderr, "failed to run tests: %s\n", CU_get_error_msg()); return error; } // Display any failures (plus hack for newline afterwards) CU_basic_show_failures(CU_get_failure_list()); if (CU_get_number_of_failure_records() > 0) printf("\n"); // Get the number of tests that failed unsigned int failures = CU_get_number_of_tests_failed(); // Cleanup the test registry CU_cleanup_registry(); // Return the number of test failures return (int)failures; }
int main ( void ) { CU_pSuite suite_consumatorimolteplici_produttorimolteplici_bufferunitario_bloccante = NULL; CU_pSuite suite_consumatorimolteplici_produttorimolteplici_bufferunitario_nonbloccante = NULL; /* initialize the CUnit test registry */ if ( CUE_SUCCESS != CU_initialize_registry() ) return CU_get_error(); /* add suite_consumatorimolteplici_bufferpieno_bloccante to the registry */ suite_consumatorimolteplici_produttorimolteplici_bufferunitario_bloccante = CU_add_suite( "Consumazioni e produzioni concorrenti di molteplici messaggi in un buffer unitario: uso di chiamate bloccanti", init_suite_consumatorimolteplici_produttorimolteplici_bufferunitario, clean_suite_consumatorimolteplici_produttorimolteplici_bufferunitario ); if ( NULL == suite_consumatorimolteplici_produttorimolteplici_bufferunitario_bloccante ) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite suite_consumatorimolteplici_bufferpieno_bloccante */ if ( (NULL == CU_add_test(suite_consumatorimolteplici_produttorimolteplici_bufferunitario_bloccante, "Stato del buffer: Valutazione iniziale dei semafori", test_iniziale_semafori_bloccante_bufferunitario)) || (NULL == CU_add_test(suite_consumatorimolteplici_produttorimolteplici_bufferunitario_bloccante, "Lancio rispettivamente di due produzioni concorrenti prima di due estrazioni concorrenti", test_consumatorimolteplici_produttorimolteplici_bloccante_bufferunitario)) || (NULL == CU_add_test(suite_consumatorimolteplici_produttorimolteplici_bufferunitario_bloccante, "Stato del buffer: Valutazione finale dei semafori", test_finale_semafori_bloccante_bufferunitario)) ) { CU_cleanup_registry(); return CU_get_error(); } /* add suite_consumatorimolteplici_produttorimolteplici_bufferunitario_nonbloccante to the registry */ suite_consumatorimolteplici_produttorimolteplici_bufferunitario_nonbloccante = CU_add_suite( "Consumazioni e produzioni concorrenti di molteplici messaggi in un buffer unitario: uso di chiamate non bloccanti", init_suite_consumatorimolteplici_produttorimolteplici_bufferunitario, clean_suite_consumatorimolteplici_produttorimolteplici_bufferunitario); if ( NULL == suite_consumatorimolteplici_produttorimolteplici_bufferunitario_nonbloccante ) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite suite_consumatorimolteplici_produttorimolteplici_bufferunitario_nonbloccante */ if ( (NULL == CU_add_test(suite_consumatorimolteplici_produttorimolteplici_bufferunitario_nonbloccante, "Stato del buffer: Valutazione iniziale dei semafori", test_iniziale_semafori_nonbloccante_bufferunitario)) || (NULL == CU_add_test(suite_consumatorimolteplici_produttorimolteplici_bufferunitario_nonbloccante, "Lancio rispettivamente di due produzioni concorrenti prima di due estrazioni concorrenti", test_consumatorimolteplici_produttorimolteplici_nonbloccante_bufferunitario)) || (NULL == CU_add_test(suite_consumatorimolteplici_produttorimolteplici_bufferunitario_nonbloccante, "Stato del buffer: Valutazione finale dei semafori", test_finale_semafori_nonbloccante_bufferunitario)) ) { CU_cleanup_registry(); return CU_get_error(); } // Run all tests using the basic interface CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); /* // Run all tests using the automated interface CU_automated_run_tests(); CU_list_tests_to_file(); // Run all tests using the console interface CU_console_run_tests(); */ /* Clean up registry and return */ CU_cleanup_registry(); return CU_get_error(); }
//-------------------------------------------------------------------------------------------------- static void test(void* context) { // Init the test case / test suite data structures CU_TestInfo smstest[] = { { "Test le_sms_SetGetSmsCenterAddress()", Testle_sms_SetGetSmsCenterAddress }, { "Test le_sms_SetGetText()", Testle_sms_SetGetText }, { "Test le_sms_SetGetBinary()", Testle_sms_SetGetBinary }, { "Test le_sms_SetGetPDU()", Testle_sms_SetGetPDU }, { "Test le_sms_ReceivedList()", Testle_sms_ReceivedList }, { "Test le_sms_SendBinary()", Testle_sms_SendBinary }, { "Test le_sms_SendText()", Testle_sms_SendText }, #if 0 { "Test le_sms_SendPdu()", Testle_sms_SendPdu }, #endif CU_TEST_INFO_NULL, }; CU_SuiteInfo suites[] = { { "SMS tests", NULL, NULL, smstest }, CU_SUITE_INFO_NULL, }; fprintf(stderr, "Please ensure that there is enough space on SIM to receive new SMS messages!\n"); #ifndef AUTOMATIC GetTel(); #endif // Initialize the CUnit test registry and register the test suite if (CUE_SUCCESS != CU_initialize_registry()) exit(CU_get_error()); if ( CUE_SUCCESS != CU_register_suites(suites)) { CU_cleanup_registry(); exit(CU_get_error()); } CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); // Output summary of failures, if there were any if ( CU_get_number_of_failures() > 0 ) { fprintf(stdout,"\n [START]List of Failure :\n"); CU_basic_show_failures(CU_get_failure_list()); fprintf(stdout,"\n [STOP]List of Failure\n"); } }
//-------------------------------------------------------------------------------------------------- static void* test(void* context) { // Init the test case / test suite data structures CU_TestInfo audiotest[] = { { "Test pa_audio_EnableCodecInput()" , Test_pa_audio_EnableCodecInput }, { "Test pa_audio_DisableCodecInput()" , Test_pa_audio_DisableCodecInput }, { "Test pa_audio_EnableCodecOutput()" , Test_pa_audio_EnableCodecOutput }, { "Test pa_audio_DisableCodecOutput()" , Test_pa_audio_DisableCodecOutput }, { "Test pa_audio_SetDspAudioPath()" , Test_pa_audio_SetDspAudioPath }, { "Test pa_audio_ResetDspAudioPath()" , Test_pa_audio_ResetDspAudioPath }, { "Test pa_audio_SetGain()" , Test_pa_audio_SetGain }, { "Test pa_audio_GetGain()" , Test_pa_audio_GetGain }, { "Test pa_audio_StartPlayback()" , Test_pa_audio_StartPlayback }, { "Test pa_audio_StopPlayback()" , Test_pa_audio_StopPlayback }, { "Test pa_audio_StartCapture()" , Test_pa_audio_StartCapture }, { "Test pa_audio_StopCapture()" , Test_pa_audio_StopCapture }, CU_TEST_INFO_NULL, }; CU_SuiteInfo suites[] = { { "PA Audio tests", NULL, NULL, audiotest }, CU_SUITE_INFO_NULL, }; // Initialize the CUnit test registry and register the test suite if (CUE_SUCCESS != CU_initialize_registry()) exit(CU_get_error()); if ( CUE_SUCCESS != CU_register_suites(suites)) { CU_cleanup_registry(); exit(CU_get_error()); } CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); // Output summary of failures, if there were any if ( CU_get_number_of_failures() > 0 ) { fprintf(stdout,"\n [START]List of Failure :\n"); CU_basic_show_failures(CU_get_failure_list()); fprintf(stdout,"\n [STOP]List of Failure\n"); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); }
int main() { // Initialise the CUnit test registry CU_ErrorCode error; if ((error = CU_initialize_registry()) != CUE_SUCCESS) { fprintf(stderr, "failed to initialise test registry: %s\n", CU_get_error_msg()); return error; } // Create a test suite within the registry CU_pSuite suite; if ((suite = CU_add_suite("lognormal", test_init, test_cleanup)) == NULL) { fprintf(stderr, "failed to create test suite: %s\n", CU_get_error_msg()); return error; } // Add the tests to the suite if (CU_ADD_TEST(suite, test_params) == NULL) { fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg()); return error; } if (CU_ADD_TEST(suite, test_evaluation) == NULL) { fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg()); return error; } if (CU_ADD_TEST(suite, test_statistics) == NULL) { fprintf(stderr, "failed to add test: %s\n", CU_get_error_msg()); return error; } // Run the test suites using the CUnit basic interface if ((error = CU_basic_run_tests()) != CUE_SUCCESS) { fprintf(stderr, "failed to run tests: %s\n", CU_get_error_msg()); return error; } // Display any failures (plus hack for newline afterwards) CU_basic_show_failures(CU_get_failure_list()); if (CU_get_number_of_failure_records() > 0) printf("\n"); // Get the number of tests that failed unsigned int failures = CU_get_number_of_tests_failed(); // Cleanup the test registry CU_cleanup_registry(); // Return the number of test failures return (int)failures; }
/* MAIN */ int main(void) { fprintf(stderr, "I'm here!\n"); CU_pSuite ste = NULL; if (CUE_SUCCESS != CU_initialize_registry()) { return CU_get_error(); } ste = CU_add_suite("mutable_string_suite", init_mutable_string_suite, clean_mutable_string_suite); if (NULL == ste) { CU_cleanup_registry(); return CU_get_error(); } if (CU_get_error() != CUE_SUCCESS) { fprintf(stderr, "Error creating suite: (%d)%s\n", CU_get_error(), CU_get_error_msg()); } ADD_TEST(CU_add_test(ste, "Verify mutable_string_init()...", t_mutable_string_init)); ADD_TEST(CU_add_test(ste, "Verify mutable_string_init_with_value()...", t_mutable_string_init_with_value)); ADD_TEST(CU_add_test(ste, "Verify mutable_string_resize()...", t_mutable_string_resize)); ADD_TEST(CU_add_test(ste, "Verify mutable_string_assign()...", t_mutable_string_assign)); ADD_TEST(CU_add_test(ste, "Verify mutable_string_append()...", t_mutable_string_append)); ADD_TEST(CU_add_test(ste, "Verify mutable_string_copy()...", t_mutable_string_copy)); ADD_TEST(CU_add_test(ste, "Verify mutable_string_append_mutable_string()...", t_mutable_string_append_mutable_string)); ADD_TEST(CU_add_test(ste, "Verify mutable_string_append_char()...", t_mutable_string_append_char)); ADD_TEST(CU_add_test(ste, "Verify mutable_string_char_at()...", t_mutable_string_char_at)); ADD_TEST(CU_add_test(ste, "Verify mutable_string_substring()...", t_mutable_string_substring)); ADD_TEST(CU_add_test(ste, "Verify mutable_string_int64/32/16()...", t_mutable_string_parse_int)); // if (CU_get_error() != CUE_SUCCESS) { fprintf(stderr, "Error creating suite: (%d)%s\n", CU_get_error(), CU_get_error_msg()); // } // CU_console_run_tests(); CU_basic_set_mode(CU_BRM_VERBOSE); CU_ErrorCode run_errors = CU_basic_run_suite(ste); if (run_errors != CUE_SUCCESS) { fprintf(stderr, "Error running tests: (%d)%s\n", run_errors, CU_get_error_msg()); } CU_basic_show_failures(CU_get_failure_list()); CU_cleanup_registry(); printf("\n"); printf("I'm done!\n"); return CU_get_error(); }
int main ( void ){ inicializaArvore(); //deve funcionar para as proximas funções funcionarem. createHeader(); //para as funçoes funcionarem o header deve ser criado, se o header foi criado então a função está correta 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( "max_test_suite", init_suite, clean_suite ); if ( NULL == pSuite ) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ( (NULL == CU_add_test(pSuite, "Inserir", test_insere)) || (NULL == CU_add_test(pSuite, "atualizar", test_atualiza)) || (NULL == CU_add_test(pSuite, "excluir", test_exclui)) ) { CU_cleanup_registry(); return CU_get_error(); } // Run all tests using the basic interface CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); /* // Run all tests using the automated interface CU_automated_run_tests(); CU_list_tests_to_file(); // Run all tests using the console interface CU_console_run_tests(); */ /* Clean up registry and return */ CU_cleanup_registry(); return CU_get_error(); }
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( "revcomp_test_suite", init_suite, clean_suite ); if ( NULL == pSuite ) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ( (NULL == CU_add_test(pSuite, "test_initseq", test_initseq)) || (NULL == CU_add_test(pSuite, "test_growseq", test_growseq)) || (NULL == CU_add_test(pSuite, "test_reverse_str", test_reverse_str)) || (NULL == CU_add_test(pSuite, "test_complement", test_complement)) ) { CU_cleanup_registry(); return CU_get_error(); } // Run all tests using the basic interface CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_suite(pSuite); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); /* // Run all tests using the automated interface CU_automated_run_tests(); CU_list_tests_to_file(); // Run all tests using the console interface CU_console_run_tests(); */ /* Clean up registry and return */ CU_cleanup_registry(); return CU_get_error(); }
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( "test_suite", init_suite, clean_suite ); if ( NULL == pSuite ) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ( (NULL == CU_add_test(pSuite, "generate_payload_test", generate_payload_test)) || (NULL == CU_add_test(pSuite, "draw_message_test", draw_message_test)) || (NULL == CU_add_test(pSuite, "init_generator_test", init_generator_test)) ) { CU_cleanup_registry(); return CU_get_error(); } // Run all tests using the basic interface CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); /* // Run all tests using the automated interface CU_automated_run_tests(); CU_list_tests_to_file(); // Run all tests using the console interface CU_console_run_tests(); */ /* Clean up registry and return */ CU_cleanup_registry(); return CU_get_error(); }
//-------------------------------------------------------------------------------------------------- static void* test(void* context) { // Init the test case / test suite data structures CU_TestInfo simtestInteractive[] = { { "Test Interactive le_sim_Authentication()", TestInteractivele_sim_Authentication }, { "Test le_sim_Create()", Testle_sim_Create }, { "Test le_sim_States()", Testle_sim_States }, CU_TEST_INFO_NULL, }; CU_SuiteInfo suites[] = { { "SIM tests Interactive", NULL, NULL, simtestInteractive }, CU_SUITE_INFO_NULL, }; // Initialize the CUnit test registry and register the test suite if (CUE_SUCCESS != CU_initialize_registry()) exit(CU_get_error()); if ( CUE_SUCCESS != CU_register_suites(suites)) { CU_cleanup_registry(); exit(CU_get_error()); } CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); // Output summary of failures, if there were any if ( CU_get_number_of_failures() > 0 ) { fprintf(stdout,"\n [START]List of Failure :\n"); CU_basic_show_failures(CU_get_failure_list()); fprintf(stdout,"\n [STOP]List of Failure\n"); } le_event_RunLoop(); }
int main() { CU_pSuite pSuite = NULL; if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); pSuite = CU_add_suite("Poly-Test-Suite", setup, teardown); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(pSuite, "Eval Func 1",test_eval_1)) || (NULL == CU_add_test(pSuite, "Eval Func 2",test_eval_2)) || (NULL == CU_add_test(pSuite, "Eval Func 3",test_eval_3)) || (NULL == CU_add_test(pSuite, "Eval Func 4",test_eval_4)) || (NULL == CU_add_test(pSuite, "Derivee Func 1",test_derivee_1)) || (NULL == CU_add_test(pSuite, "Derivee Func 2",test_derivee_2)) || (NULL == CU_add_test(pSuite, "Derivee Func 3",test_derivee_3)) || (NULL == CU_add_test(pSuite, "Derivee Func 4",test_derivee_4)) || (NULL == CU_add_test(pSuite, "Racine Func 1",test_racine_1)) || (NULL == CU_add_test(pSuite, "Racine Func 2",test_racine_2)) || (NULL == CU_add_test(pSuite, "Racine Func 3",test_racine_3)) || (NULL == CU_add_test(pSuite, "Racine Func 4",test_racine_4)) ) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); CU_cleanup_registry(); return CU_get_error(); }
int main (int argc, char** argv) { if(CUE_SUCCESS != CU_initialize_registry()) {return CU_get_error();} CU_pSuite suitePushPop = CU_add_suite("Tests de Push et Pop",NULL,NULL); if(NULL== suitePushPop) { CU_cleanup_registry(); return CU_get_error(); } if(NULL==CU_add_test(suitePushPop, "Test si push incrémente bien stack_height", pushTest1)||NULL==CU_add_test(suitePushPop, "Test si push place bien le double passé en paramètre sur la pile", pushTest2)||NULL==CU_add_test(suitePushPop, "Test pop décrémente stack_height", popTest1)||NULL==CU_add_test(suitePushPop, "Test valeur pop", popTest2)) {CU_cleanup_registry(); return CU_get_error();} CU_pSuite suiteSimple = CU_add_suite("Simple Tests",NULL,NULL); if(NULL== suiteSimple) { CU_cleanup_registry(); return CU_get_error(); } if(NULL==CU_add_test(suiteSimple, "Test addition", simpleAdd)||NULL==CU_add_test(suiteSimple, "Test difference", simpleDiff)||NULL==CU_add_test(suiteSimple, "Test multiplication", simpleMult)||NULL==CU_add_test(suiteSimple, "Test division", simpleDiv)) {CU_cleanup_registry(); return CU_get_error();} CU_pSuite suiteDouble = CU_add_suite("Double Tests",NULL,NULL); if(NULL== suiteDouble) { CU_cleanup_registry(); return CU_get_error(); } if(NULL==CU_add_test(suiteDouble, "Test addition then division", addDiv)||NULL==CU_add_test(suiteDouble, "Test division then substraction", divMinus)||NULL==CU_add_test(suiteDouble, "Test substraction then multiplication", minusTimes)||NULL==CU_add_test(suiteDouble, "Test multiplication then addition", timesAdd)) {CU_cleanup_registry(); return CU_get_error();} CU_basic_run_tests(); CU_basic_show_failures(CU_get_failure_list()); }
int main(int argc, char** argv) { CU_pSuite suite_test_lab = NULL; argc = 0; argv = NULL; /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); if (NULL == (suite_test_lab = CU_add_suite("lab", initTestLab, cleanTestLab))) { CU_cleanup_registry(); return CU_get_error(); } if ( (NULL == CU_add_test(suite_test_lab, "test1 ", test_lab)) ) { CU_cleanup_registry(); return CU_get_error(); } /* * Run all tests using the basic interface * * CU_basic_run_tests(); -> Runs all tests in all registered suites * CU_basic_run_suite(CU_pSuite pSuite); -> Runs all tests in single specified suite * CU_basic_run_test(CU_pSuite pSuite, CU_pTest pTest); -> Runs a single test in a specified suite */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf("\n"); CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); /* * Run all tests using the automated interface */ /* CU_automated_run_tests(); CU_list_tests_to_file(); */ /* * Run all tests using the console interface */ /* CU_console_run_tests(); */ /* * Run all tests using the curses interface * (only on systems having curses) */ /* CU_curses_run_tests(); */ /* Clean up registry and return */ CU_cleanup_registry(); return CU_get_error(); return (EXIT_SUCCESS); }
int liblinphone_tester_run_tests(const char *suite_name, const char *test_name) { int i; int ret; /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); for (i = 0; i < liblinphone_tester_nb_test_suites(); i++) { run_test_suite(test_suite[i]); } CU_set_test_start_handler(test_start_message_handler); CU_set_test_complete_handler(test_complete_message_handler); CU_set_all_test_complete_handler(test_all_tests_complete_message_handler); CU_set_suite_init_failure_handler(test_suite_init_failure_message_handler); CU_set_suite_cleanup_failure_handler(test_suite_cleanup_failure_message_handler); CU_set_suite_start_handler(test_suite_start_message_handler); if( liblinphone_tester_xml_file != NULL ){ CU_set_output_filename(liblinphone_tester_xml_file); } if( liblinphone_tester_xml_enabled != 0 ){ CU_automated_run_tests(); } else { #if !HAVE_CU_GET_SUITE if( suite_name ){ ms_warning("Tester compiled without CU_get_suite() function, running all tests instead of suite '%s'\n", suite_name); } #else if (suite_name){ CU_pSuite suite; suite=CU_get_suite(suite_name); if (!suite) { ms_error("Could not find suite '%s'. Available suites are:", suite_name); liblinphone_tester_list_suites(); return -1; } else if (test_name) { CU_pTest test=CU_get_test_by_name(test_name, suite); if (!test) { ms_error("Could not find test '%s' in suite '%s'. Available tests are:", test_name, suite_name); // do not use suite_name here, since this method is case sensitive liblinphone_tester_list_suite_tests(suite->pName); return -2; } else { CU_ErrorCode err= CU_run_test(suite, test); if (err != CUE_SUCCESS) ms_error("CU_basic_run_test error %d", err); } } else { CU_run_suite(suite); } } else #endif { #if HAVE_CU_CURSES if (curses) { /* Run tests using the CUnit curses interface */ CU_curses_run_tests(); } else #endif { /* Run all tests using the CUnit Basic interface */ CU_run_all_tests(); } } } ret=CU_get_number_of_tests_failed()!=0; /* Redisplay list of failed tests on end */ if (CU_get_number_of_failure_records()){ CU_basic_show_failures(CU_get_failure_list()); liblinphone_tester_fprintf(stdout,"\n"); } CU_cleanup_registry(); if( liblinphone_tester_keep_accounts_flag == 0){ liblinphone_tester_clear_accounts(); } return ret; }
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("Suite_success", init_suite_success, clean_suite_success); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ((NULL == CU_add_test(pSuite, "successful_test_1", test_success1)) || (NULL == CU_add_test(pSuite, "successful_test_2", test_success2)) || (NULL == CU_add_test(pSuite, "successful_test_3", test_success3))) { CU_cleanup_registry(); return CU_get_error(); } /* add a suite to the registry */ pSuite = CU_add_suite("Suite_init_failure", init_suite_failure, NULL); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ((NULL == CU_add_test(pSuite, "successful_test_1", test_success1)) || (NULL == CU_add_test(pSuite, "successful_test_2", test_success2)) || (NULL == CU_add_test(pSuite, "successful_test_3", test_success3))) { CU_cleanup_registry(); return CU_get_error(); } /* add a suite to the registry */ pSuite = CU_add_suite("Suite_clean_failure", NULL, clean_suite_failure); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ((NULL == CU_add_test(pSuite, "successful_test_4", test_success1)) || (NULL == CU_add_test(pSuite, "failed_test_2", test_failure2)) || (NULL == CU_add_test(pSuite, "successful_test_1", test_success1))) { CU_cleanup_registry(); return CU_get_error(); } /* add a suite to the registry */ pSuite = CU_add_suite("Suite_mixed", NULL, NULL); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ((NULL == CU_add_test(pSuite, "successful_test_2", test_success2)) || (NULL == CU_add_test(pSuite, "failed_test_4", test_failure4)) || (NULL == CU_add_test(pSuite, "failed_test_2", test_failure2)) || (NULL == CU_add_test(pSuite, "successful_test_4", test_success4))) { CU_cleanup_registry(); return CU_get_error(); } /* Run all tests using the basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); LOG_printf("\n"); CU_basic_show_failures(CU_get_failure_list()); LOG_printf("\n\n"); /* Clean up registry and return */ CU_cleanup_registry(); return CU_get_error(); }
/* ** 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 index; char *suite_name; CU_pSuite suite_to_run; char *test_name; CU_pTest test_to_run; CU_ErrorCode errCode = 0; CU_pTestRegistry registry; int num_run; int num_failed; PG_SuiteSetup *setupfunc = setupfuncs; /* Install the custom error handler */ lwgeom_set_handlers(0, 0, 0, cu_errorreporter, 0); /* Initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) { errCode = CU_get_error(); printf(" Error attempting to initialize registry: %d. See CUError.h for error code list.\n", errCode); return errCode; } /* Register all the test suites. */ while ( *setupfunc ) { (*setupfunc)(); setupfunc++; } /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); if (argc <= 1) { errCode = CU_basic_run_tests(); } else { /* NOTE: The cunit functions used here (CU_get_registry, CU_get_suite_by_name, and CU_get_test_by_name) are * listed with the following warning: "Internal CUnit system functions. Should not be routinely called by users." * However, there didn't seem to be any other way to get tests by name, so we're calling them. */ registry = CU_get_registry(); for (index = 1; index < argc; index++) { suite_name = argv[index]; test_name = NULL; suite_to_run = CU_get_suite_by_name(suite_name, registry); if (NULL == suite_to_run) { /* See if it's a test name instead of a suite name. */ suite_to_run = registry->pSuite; while (suite_to_run != NULL) { test_to_run = CU_get_test_by_name(suite_name, suite_to_run); if (test_to_run != NULL) { /* It was a test name. */ test_name = suite_name; suite_name = suite_to_run->pName; break; } suite_to_run = suite_to_run->pNext; } } if (suite_to_run == NULL) { printf("\n'%s' does not appear to be either a suite name or a test name.\n\n", suite_name); } else { if (test_name != NULL) { /* Run only this test. */ printf("\nRunning test '%s' in suite '%s'.\n", test_name, suite_name); /* This should be CU_basic_run_test, but that method is broken, see: * https://sourceforge.net/tracker/?func=detail&aid=2851925&group_id=32992&atid=407088 * This one doesn't output anything for success, so we have to do it manually. */ errCode = CU_run_test(suite_to_run, test_to_run); if (errCode != CUE_SUCCESS) { printf(" Error attempting to run tests: %d. See CUError.h for error code list.\n", errCode); } else { num_run = CU_get_number_of_asserts(); num_failed = CU_get_number_of_failures(); printf("\n %s - asserts - %3d passed, %3d failed, %3d total.\n\n", (0 == num_failed ? "PASSED" : "FAILED"), (num_run - num_failed), num_failed, num_run); } } else { /* Run all the tests in the suite. */ printf("\nRunning all tests in suite '%s'.\n", suite_name); /* This should be CU_basic_run_suite, but that method is broken, see: * https://sourceforge.net/tracker/?func=detail&aid=2851925&group_id=32992&atid=407088 * This one doesn't output anything for success, so we have to do it manually. */ errCode = CU_run_suite(suite_to_run); if (errCode != CUE_SUCCESS) { printf(" Error attempting to run tests: %d. See CUError.h for error code list.\n", errCode); } else { num_run = CU_get_number_of_tests_run(); num_failed = CU_get_number_of_tests_failed(); printf("\n %s - tests - %3d passed, %3d failed, %3d total.\n", (0 == num_failed ? "PASSED" : "FAILED"), (num_run - num_failed), num_failed, num_run); num_run = CU_get_number_of_asserts(); num_failed = CU_get_number_of_failures(); printf(" - asserts - %3d passed, %3d failed, %3d total.\n\n", (num_run - num_failed), num_failed, num_run); } } } } /* Presumably if the CU_basic_run_[test|suite] functions worked, we wouldn't have to do this. */ CU_basic_show_failures(CU_get_failure_list()); printf("\n\n"); /* basic_show_failures leaves off line breaks. */ } num_failed = CU_get_number_of_failures(); CU_cleanup_registry(); return num_failed; }