int main(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: CursesTest [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_curses_run_tests(); CU_cleanup_registry(); } } return 0; }
int main(int argc, char* argv[]) { CU_BasicRunMode mode = CU_BRM_VERBOSE; CU_ErrorAction error_action = CUEA_IGNORE; int i; setvbuf(stdout, NULL, _IONBF, 0); for (i=1 ; i<argc ; i++) { if (!strcmp("-i", argv[i])) { error_action = CUEA_IGNORE; } else if (!strcmp("-f", argv[i])) { error_action = CUEA_FAIL; } else if (!strcmp("-A", argv[i])) { error_action = CUEA_ABORT; } else if (!strcmp("-s", argv[i])) { mode = CU_BRM_SILENT; } else if (!strcmp("-n", argv[i])) { mode = CU_BRM_NORMAL; } else if (!strcmp("-v", argv[i])) { mode = CU_BRM_VERBOSE; } else if (!strcmp("-e", argv[i])) { print_example_results(); return 0; } else { printf("\nUsage: BasicTest [options]\n\n" "Options: -i ignore framework errors [default].\n" " -f fail on framework error.\n" " -A abort on framework error.\n\n" " -s silent mode - no output to screen.\n" " -n normal mode - standard output to screen.\n" " -v verbose mode - max output to screen [default].\n\n" " -e print expected test results and exit.\n" " -h print this message and exit.\n\n"); return 0; } } if (CU_initialize_registry()) { printf("\nInitialization of Test Registry failed."); } else { // add Tests CU_pSuite pSuite = NULL; // First Suite pSuite = CU_add_suite("Dictionary", NULL, NULL); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if (NULL == CU_add_test(pSuite, "NullFree", testFreeNullDict)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Basic dictionary methods", testBasicDict)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Dictionary methods", testDict)) { CU_cleanup_registry(); return CU_get_error(); } // 2nd Suite pSuite = CU_add_suite("List", NULL, NULL); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if (NULL == CU_add_test(pSuite, "NullFree", testFreeNullList)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Basic list methods", testList)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Copy list method", testCreateCopy)) { CU_cleanup_registry(); return CU_get_error(); } // 3rd Suite pSuite = CU_add_suite("Applications", NULL, NULL); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if (NULL == CU_add_test(pSuite, "Simple App", test_simple_app)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Advanced App", test_advanced_app)) { CU_cleanup_registry(); return CU_get_error(); } // 4th Suite pSuite = CU_add_suite("Session Management", NULL, NULL); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if (NULL == CU_add_test(pSuite, "Get Empty Session List", test_empty_jsession_list)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Basic Session Handling", test_basic_session_methods)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Multiple Sessions", test_multiple_sessions)) { CU_cleanup_registry(); return CU_get_error(); } // 5th Suite pSuite = CU_add_suite("Job Session", NULL, NULL); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if (NULL == CU_add_test(pSuite, "Session Invalidation", test_jsession_invalidation)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Getter Methods", test_jsession_getter_methods)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Job Lists", test_job_list)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Job Categories", test_job_categories)) { CU_cleanup_registry(); return CU_get_error(); } // 6th Suite pSuite = CU_add_suite("Monitoring Session", NULL, NULL); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if (NULL == CU_add_test(pSuite, "Reservation Lists", test_reservation_lists)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Job Lists", test_job_lists)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Queue Lists", test_get_queues)) { CU_cleanup_registry(); return CU_get_error(); } // 7th Suite pSuite = CU_add_suite("Reservation Session", NULL, NULL); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if (NULL == CU_add_test(pSuite, "Session Invalidation", test_rsession_invalidation)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Getter Methods", test_rsession_getter_methods)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Get reservation", test_rsession_get_reservation)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Get reservations", test_rsession_get_reservations)) { CU_cleanup_registry(); return CU_get_error(); } // 8th Suite pSuite = CU_add_suite("Reservation", NULL, NULL); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if (NULL == CU_add_test(pSuite, "Get reservation info", test_r_get_info)) { CU_cleanup_registry(); return CU_get_error(); } if (NULL == CU_add_test(pSuite, "Get reservation template", test_r_get_template)) { CU_cleanup_registry(); return CU_get_error(); } CU_basic_set_mode(mode); CU_set_error_action(error_action); printf("\nTests completed with return value %d.\n", CU_basic_run_tests()); CU_cleanup_registry(); } return 0; }