int main(int argc, char **argv) { cortex_init(); cmd_init(argc, argv); ctx_msg_out = NULL; ctx_tst_out = stdout; test_status("Tests running k=%i..%i...", get_min_kmer_size(), get_max_kmer_size()); test_status("[version] "VERSION_STATUS_STR"\n"); // Binary Kmer tests should work for all values of MAXK test_bkmer_functions(); test_hash_table(); #if MAX_KMER_SIZE == 31 // not kmer dependent test_util(); test_dna_functions(); test_binary_seq_functions(); // only written in k=31 test_db_node(); test_build_graph(); test_supernode(); test_subgraph(); test_cleaning(); test_paths(); // test_path_sets(); // TODO: replace with test_path_subset() test_graph_walker(); test_corrected_aln(); test_repeat_walker(); test_graph_crawler(); test_bubble_caller(); test_kmer_occur(); test_infer_edges_tests(); #endif cmd_destroy(); // Check we free'd all our memory size_t still_alloced = alloc_get_num_allocs() - alloc_get_num_frees(); TASSERT2(still_alloced == 0, "%zu not free'd", still_alloced); // Finished char num_test_str[100], num_passed_str[100]; size_t tests_num_passed = tests_num_run - tests_num_failed; ulong_to_str(tests_num_run, num_test_str); ulong_to_str(tests_num_passed, num_passed_str); test_status("Tests passed: %s / %s (%.1f%%)", num_passed_str, num_test_str, (100.0*tests_num_passed)/tests_num_run); if(tests_num_failed) test_status("%zu tests failed", tests_num_failed); else test_status("All tests passed."); cortex_destroy(); // Return 1 if any tests failed, 0 on success return tests_num_failed ? 1 : 0; }
int main(int argc, char **argv) { time_t start, end; time(&start); ctx_msg_out = stderr; cortex_init(); cmd_init(argc, argv); if(argc == 1) print_help(stderr, NULL); const CtxCmd *cmd = ctx_get_command(argv[1]); if(cmd == NULL) print_help(stderr, "Unrecognised command: %s", argv[1]); // Once we have set cmd_usage, we can call cmd_print_usage() from anywhere cmd_set_usage(cmd->usage); // If no arguments after command, print help if(argc == 2) cmd_print_usage(NULL); // Look for -q, --quiet argument, if given silence output int argi = 1; while(argi < argc && !(!strcmp(argv[argi],"-q") || !strcmp(argv[argi],"--quiet"))) argi++; if(argi < argc) { // Found -q, --quiet argument ctx_msg_out = NULL; // Remove argument for(--argc; argi < argc; argi++) argv[argi] = argv[argi+1]; } // Print status header cmd_print_status_header(); SWAP(argv[1],argv[0]); int ret = cmd->func(argc-1, argv+1); time(&end); cmd_destroy(); // Warn if more allocations than deallocations size_t still_alloced = alloc_get_num_allocs() - alloc_get_num_frees(); if(still_alloced) warn("%zu allocates not free'd.", still_alloced); char nallocs_str[50]; ulong_to_str(alloc_get_num_allocs(), nallocs_str); status("[memory] We made %s allocs", nallocs_str); status(ret == 0 ? "Done." : "Fail."); // Print time taken double diff = difftime(end,start); if(diff < 60) status("[time] %.2lf seconds\n", diff); else { char timestr[100]; seconds_to_str((size_t)diff, timestr); status("[time] %.2lf seconds (%s)\n", diff, timestr); } cortex_destroy(); return ret; }