/* 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() { ks3_global_init(); int ret = load_ak_sk(); if (ret != 0) { printf("[ERROR] load ak, sk failed\n"); return ret; } ret = CreateBucket(host, src_bucket); if (ret != 0) { printf("[ERROR] create src bucket failed\n"); return ret; } ret = CreateBucket(host, dst_bucket); if (ret != 0) { printf("[ERROR] create dst bucket failed\n"); return ret; } 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_1", init_suite1, clean_suite1); if (NULL == pSuite) { CU_cleanup_registry(); ks3_global_destroy(); return CU_get_error(); } /* add the tests to the suite */ if (CU_add_test(pSuite, "test copy object with same bucket\n", TEST_COPY_OBJECT_WITH_SAME_BUCKET) == NULL || CU_add_test(pSuite, "test copy object with same bucket and key \n", TEST_COPY_OBJECT_WITH_SAME_BUCKET_AND_SAME_OBJ_KEY) == NULL || CU_add_test(pSuite, "test copy object with same bucket and diff exist key \n", TEST_COPY_OBJECT_WITH_SAME_BUCKET_AND_DIFF_EXIST_OBJ_KEY) == NULL || CU_add_test(pSuite, "test copy object with diff bucket \n", TEST_COPY_OBJECT_WITH_DIFF_BUCKET) == NULL || CU_add_test(pSuite, "test copy object with diff bucket and exist key\n", TEST_COPY_OBJECT_WITH_DIFF_BUCKET_AND_EXIST_KEY) == NULL || CU_add_test(pSuite, "test copy object with src bucket not exist\n", TEST_COPY_OBJECT_WITH_SRC_BUCKET_NOT_EXIST) == NULL || CU_add_test(pSuite, "test copy object with src object not exist\n", TEST_COPY_OBJECT_WITH_SRC_OBJECT_NOT_EXIST) == NULL || CU_add_test(pSuite, "test copy object with dst bucket not exist\n", TEST_COPY_OBJECT_WITH_DST_BUCKET_NOT_EXIST) == NULL || CU_add_test(pSuite, "test copy object with blank dst bucket name\n", TEST_COPY_OBJECT_WITH_BLANK_DST_BUCKET_NAME) == NULL || CU_add_test(pSuite, "test copy object with blank src bucket name\n", TEST_COPY_OBJECT_WITH_BLANK_SRC_BUCKET_NAME) == NULL || CU_add_test(pSuite, "test copy object with blank src object name\n", TEST_COPY_OBJECT_WITH_BLANK_SRC_OBJECT_NAME) == NULL) { CU_cleanup_registry(); ks3_global_destroy(); return CU_get_error(); } /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); CU_cleanup_registry(); ret = DeleteBucket(host, src_bucket); if (ret != 0) { printf("[ERROR] delete src_bucket failed\n"); } ret = DeleteBucket(host, dst_bucket); if (ret != 0) { printf("[ERROR] delete dst_bucket failed\n"); } ks3_global_destroy(); 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 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 }
/* * Main */ int main(void) { CU_pSuite ptr_suite = NULL; int nr_of_failed_tests = 0; int nr_of_failed_suites = 0; (void)gre_frame; /* Initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); /* add a suite to the registry */ ptr_suite = CU_add_suite("ofp packet input", init_suite, clean_suite); if (NULL == ptr_suite) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_init_packet_input_basic)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_init_ifnet)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_local_hook)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_local_IPv4_hook)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_local_UDPv4_hook)) { CU_cleanup_registry(); return CU_get_error(); } #ifdef SP if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_to_sp)) { CU_cleanup_registry(); return CU_get_error(); } #endif /* SP */ if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_send_arp)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_forwarding_to_output)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_gre_processed_inner_pkt_forwarded)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_gre_orig_pkt_to_sp)) { CU_cleanup_registry(); return CU_get_error(); } ptr_suite = CU_add_suite("test VRF", NULL , NULL); if (NULL == ptr_suite) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_init_packet_input_vrf)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_init_ifnet)) { CU_cleanup_registry(); return CU_get_error(); } #ifdef SP if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_to_sp)) { CU_cleanup_registry(); return CU_get_error(); } #endif /* SP */ if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_send_arp)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_forwarding_to_output)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_gre_processed_inner_pkt_forwarded)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(ptr_suite, test_ofp_packet_input_gre_orig_pkt_to_sp)) { CU_cleanup_registry(); return CU_get_error(); } #if OFP_TESTMODE_AUTO CU_set_output_filename("CUnit-PKT-IN"); CU_automated_run_tests(); #else /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); #endif nr_of_failed_tests = CU_get_number_of_tests_failed(); nr_of_failed_suites = CU_get_number_of_suites_failed(); CU_cleanup_registry(); return (nr_of_failed_suites > 0 ? nr_of_failed_suites : nr_of_failed_tests); }
int bc_tester_run_tests(const char *suite_name, const char *test_name) { int i; /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); for (i = 0; i < nb_test_suites; i++) { bc_tester_run_suite(test_suite[i]); } #ifdef HAVE_CU_GET_SUITE CU_set_suite_start_handler(suite_start_message_handler); CU_set_suite_complete_handler(suite_complete_message_handler); CU_set_test_start_handler(test_start_message_handler); CU_set_test_complete_handler(test_complete_message_handler); #endif CU_set_all_test_complete_handler(all_complete_message_handler); CU_set_suite_init_failure_handler(suite_init_failure_message_handler); CU_set_suite_cleanup_failure_handler(suite_cleanup_failure_message_handler); if( xml_enabled != 0 ){ CU_automated_run_tests(); } else { #ifndef HAVE_CU_GET_SUITE if( suite_name ){ bc_tester_printf(bc_printf_verbosity_info, "Tester compiled without CU_get_suite() function, running all tests instead of suite '%s'", suite_name); } #else if (suite_name){ CU_pSuite suite; suite=CU_get_suite(suite_name); if (!suite) { bc_tester_printf(bc_printf_verbosity_error, "Could not find suite '%s'. Available suites are:", suite_name); bc_tester_list_suites(); return -1; } else if (test_name) { CU_pTest test=CU_get_test_by_name(test_name, suite); if (!test) { bc_tester_printf(bc_printf_verbosity_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 bc_tester_list_tests(suite->pName); return -2; } else { CU_ErrorCode err= CU_run_test(suite, test); if (err != CUE_SUCCESS) bc_tester_printf(bc_printf_verbosity_error, "CU_basic_run_test error %d", err); } } else { CU_run_suite(suite); } } else #endif { #ifdef 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(); } } } #ifdef __linux bc_tester_printf(bc_printf_verbosity_info, "Still %i kilobytes allocated when all tests are finished.", mallinfo().uordblks / 1024); #endif return CU_get_number_of_tests_failed()!=0; }
int main () { if (CUE_SUCCESS != CU_initialize_registry()) { return CU_get_error(); } CU_pSuite psuite = NULL; psuite = CU_add_suite("Tree test", NULL, NULL); if (psuite == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_create", test_tree_create) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_name", test_tree_name) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_count", test_tree_count) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_type", test_tree_type) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_add", test_tree_add) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_dup_check", test_tree_dup_check) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_walk_inorder", test_tree_walk_inorder) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_walk_preorder", test_tree_walk_preorder) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_walk_postorder", test_tree_walk_postorder) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_level", test_tree_level) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_print", test_tree_print) == NULL) { CU_cleanup_registry(); return CU_get_error(); } if (CU_add_test(psuite, "test_tree_data_delete", test_tree_data_delete) == NULL) { CU_cleanup_registry(); return CU_get_error(); } boolvar = 0; if (CU_add_test(psuite, "test_tree_destroy", test_tree_destroy) == NULL) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); handle = NULL; return CU_get_error(); }
int main() { CU_pSuite pSuite = NULL; if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); pSuite = CU_add_suite("clist suite", init_clist_test_suite, clean_clist_test_suite); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(pSuite, test_clist_pop)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(pSuite, test_clist_insert)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(pSuite, test_clist_remove)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(pSuite, test_clist_append)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(pSuite, test_clist_get_by_id)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(pSuite, test_clist_iterator)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(pSuite, test_clist_append_insert_append)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_ADD_TEST(pSuite, test_clist_sort)) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); printf ("running tests\n"); /* CU_automated_run_tests(); */ 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() { /* initialize the CUnit test registry... get this party started */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); /* General avl_tree test. */ CU_TestInfo avl_tree_unit_1_arr[] = { {"Tree insertions 1.", inserts_tree_1} , {"Tree check 1.", check_tree_1} , {"Tree lookups 1.", lookups_tree_1} , {"Tree deletes 1.", deletes_tree_1} , CU_TEST_INFO_NULL, }; CU_TestInfo avl_tree_unit_2_arr[] = { {"Tree insertions 2.", inserts_tree_2} , {"Tree check 2.", check_tree_2} , {"Tree lookups 2.", lookups_tree_2} , {"Tree deletes 2.", deletes_tree_2} , CU_TEST_INFO_NULL, }; CU_TestInfo avl_tree_unit_2r_arr[] = { {"Tree insertions 2.", inserts_tree_2r} , {"Tree check 2.", check_tree_2} , {"Tree lookups 2.", lookups_tree_2} , {"Tree deletes 2.", deletes_tree_2} , CU_TEST_INFO_NULL, }; CU_TestInfo avl_tree_unit_100_arr[] = { {"Tree insertions 100.", inserts_tree_100} , {"Tree check 100.", check_tree_100} , {"Tree lookups 100.", lookups_tree_100} , {"Tree traverse 100.", trav_tree_100} , {"Tree deletes 100.", deletes_tree_100} , CU_TEST_INFO_NULL, }; CU_TestInfo avl_tree_unit_10000_arr[] = { {"Tree insertions 10000.", inserts_tree_10000} , {"Tree lookups 10000.", lookups_tree_10000} , {"Tree check 10000.", check_tree_10000} , {"Tree traverse 10000.", trav_tree_10000} , {"Tree deletes 10000.", deletes_tree_10000} , CU_TEST_INFO_NULL, }; CU_TestInfo avl_tree_unit_min_1_arr[] = { {"Check min after inserts, deletes.", check_min_1} , {"Check lookup after delete.", check_delete_1} , #if 1 /* skews perf */ {"Random min check.", check_min_2} , #endif CU_TEST_INFO_NULL, }; CU_TestInfo avl_tree_unit_supremum[] = { {"Inserts supremum.", inserts_supremum} , {"Checks supremum (and infimum).", checks_supremum} , {"Deletes supremum.", deletes_supremum} , CU_TEST_INFO_NULL, }; CU_SuiteInfo suites[] = { {"Avl operations 1", init_suite1, clean_suite1, avl_tree_unit_1_arr} , {"Avl operations 2", init_suite2, clean_suite2, avl_tree_unit_2_arr} , {"Avl operations 2 R", init_suite2, clean_suite2, avl_tree_unit_2r_arr} , {"Avl operations 100", init_suite100, clean_suite100, avl_tree_unit_100_arr} , {"Avl operations 10000", init_suite10000, clean_suite10000, avl_tree_unit_10000_arr} , {"Check min 1", init_suite1, clean_suite1, avl_tree_unit_min_1_arr} , {"Check supremum", init_supremum, clean_supremum, avl_tree_unit_supremum} , CU_SUITE_INFO_NULL, }; CU_ErrorCode error = CU_register_suites(suites); /* Initialize the avl_tree package */ avl_unit_PkgInit(); /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); CU_cleanup_registry(); return CU_get_error(); }
int main(int argc, char *argv[]) { char configFile[1024], interface[25]; int createflag, unitflag, cleanflag; extern int logflag; int create_f, clean_f, log_f; createflag = unitflag = cleanflag = FALSE; create_f = clean_f, FLAG_NOT_SET; // Begin command line parsing *********************************************** if ( (checkForOption("--help", argc, argv) != FLAG_NOT_SET) || (checkForOption("-h", argc, argv) != FLAG_NOT_SET) || (checkForOption("-help", argc, argv) != FLAG_NOT_SET) ) { print_help(); } get_asf_share_dir_with_argv0(argv[0]); handle_license_and_version_args(argc, argv, ASF_NAME_STRING); // Check which options were provided create_f = checkForOption("-create", argc, argv); clean_f = checkForOption("-clean", argc, argv); log_f = checkForOption("-log", argc, argv); // We need to make sure the user specified the proper number of arguments int needed_args = 1 + REQUIRED_ARGS; // command & REQUIRED_ARGS int num_flags = 0; if (create_f != FLAG_NOT_SET) {needed_args += 1; num_flags++;} // option if (clean_f != FLAG_NOT_SET) {needed_args += 1; num_flags++;} // option if (log_f != FLAG_NOT_SET) {needed_args += 2; num_flags++;} // option & param // Make sure we have the right number of args if (argc != needed_args) { print_usage(); } // Make sure argument for each flag (that requires an arg) is not another // option flag & is not a required argument if (log_f != FLAG_NOT_SET) { if ((argv[log_f+1][0]=='-') || (log_f>=(argc-REQUIRED_ARGS))) { print_usage(); } } // Make sure all options occur before the config file name argument if (num_flags == 1 && (create_f > 1 || log_f > 1)) { print_usage(); } else if (num_flags > 1 && (create_f >= argc - REQUIRED_ARGS - 1 || log_f >= argc - REQUIRED_ARGS - 1)) { print_usage(); } // Do the actual flagging & such for each flag if (create_f != FLAG_NOT_SET) { createflag = TRUE; } if (clean_f != FLAG_NOT_SET) { cleanflag = TRUE; } if (log_f != FLAG_NOT_SET) { strcpy(logFile, argv[log_f+1]); logflag = TRUE; fLog = FOPEN(logFile, "w"); } // Fetch required arguments strcpy(interface, argv[argc-2]); strcpy(configFile, argv[argc-1]); // Report the command line asfSplashScreen(argc, argv); // End command line parsing ************************************************* // Get test information from configuration file test_config *cfg; char line[1024]; // Creating configuration files if (createflag && !fileExists(configFile)) { init_test_config(configFile); return(EXIT_SUCCESS); } else if (createflag && fileExists(configFile)) { cfg = read_test_config(configFile); check_return(write_test_config(configFile, cfg), "Could not update configuration file"); free_test_config(cfg); return(EXIT_SUCCESS); } else if (!fileExists(configFile)) asfPrintError("Could not find config file (%s)\n", configFile); // Unit tests or single configuration file? if (strcmp_case(interface, "basic") == 0 || strcmp_case(interface, "automated") == 0) unitflag = TRUE; if (unitflag) { extern int quietflag; quietflag = 2; if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); int test = FALSE; FILE *fpList = FOPEN(configFile, "r"); while(fgets(line, 1024, fpList)) { if (strcmp_case(trim_spaces(line), "uavsar_metadata") == 0) add_uavsar_metadata_tests(); if (strcmp_case(trim_spaces(line), "uavsar_geotiff") == 0) add_uavsar_geotiff_tests(); if (strcmp_case(trim_spaces(line), "rsat1_map_projections") == 0) add_rsat1_map_projections_tests(); if (strcmp_case(trim_spaces(line), "rsat1_geotiff") == 0) add_rsat1_geotiff_tests(); if (strcmp_case(trim_spaces(line), "alos_browse") == 0) add_alos_browse_tests(); if (strcmp_case(trim_spaces(line), "alos_leader") == 0) add_alos_leader_tests(); if (strcmp_case(trim_spaces(line), "rsat1_overlay") == 0) add_rsat1_overlay_tests(); if (strcmp_case(trim_spaces(line), "alos_calibration") == 0) add_alos_calibration_tests(); test = TRUE; } FCLOSE(fpList); if (test && strcmp_case(interface, "basic") == 0) { asfPrintStatus("Running tests in basic mode ...\n"); CU_basic_set_mode(CU_BRM_VERBOSE); if (CUE_SUCCESS != CU_basic_run_tests()) { CU_cleanup_registry(); return CU_get_error(); } } if (test && strcmp_case(interface, "automated") == 0) { asfPrintStatus("Running tests in automated mode ...\n\n"); CU_set_output_filename("asf_tools"); CU_automated_run_tests(); CU_list_tests_to_file(); } CU_cleanup_registry(); if (cleanflag) cleanup_test_results(configFile); } else { // Configuration file for manual mode cfg = read_test_config(configFile); asfPrintStatus("Running tests in manual mode ...\n\n"); // Run metadata tests if (strcmp_case(cfg->general->type, "metadata") == 0) manual_metadata(configFile); // Run geotiff tests else if (strcmp_case(cfg->general->type, "geotiff") == 0) manual_geotiff(configFile); // Run binary tests else if (strcmp_case(cfg->general->type, "binary") == 0) manual_binary(configFile); // Run library tests else if (strcmp_case(cfg->general->type, "library") == 0) manual_library(configFile); free_test_config(cfg); } return(EXIT_SUCCESS); }
int init_tests_gen() { CU_pSuite genTests = NULL; /* add a suite to the registry */ genTests = CU_add_suite("gen", NULL, NULL); if (NULL == genTests) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT * 1", test_Select_1))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT/WHERE 1", test_Select_2))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT/WHERE 2", test_Select_3))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT/WHERE 3", test_Select_4))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT/WHERE 4", test_Select_5))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT/WHERE/AND 1", test_Select_6))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT/WHERE/AND 2", test_Select_7))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT Multiple Table 1", test_Select_8))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT Multiple Table 2", test_Select_9))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT Multiple Table WHERE 1", test_Select_10))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT Multiple Table WHERE/AND 1", test_Select_11))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT/WHERE Two Columns 1", test_Select_12))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "SELECT Multiple Table 0", test_Select_13))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "INSERT 1", test_Insert_1))) { CU_cleanup_registry(); return CU_get_error(); } if ((NULL == CU_add_test(genTests, "INSERT 2", test_Insert_2))) { CU_cleanup_registry(); return CU_get_error(); } return CU_get_error(); }