static void print_help(FILE *out, const char *errfmt, ...) { if(errfmt != NULL) { fprintf(out, "Error: "); va_list argptr; va_start(argptr, errfmt); vfprintf(out, errfmt, argptr); va_end(argptr); } size_t i, j, s, maxlen = 0, n = sizeof(cmdobjs) / sizeof(CtxCmd); qsort(cmdobjs, n, sizeof(CtxCmd), ctxcmd_cmp); for(i = 0; i < n; i++) if(!cmdobjs[i].hide) maxlen = MAX2(maxlen, strlen(cmdobjs[i].cmd)); fprintf(out, "\n" "usage: "CMD" <command> [options] <args>\n" "version: "VERSION_STATUS_STR" k=%i..%i\n" "\n", get_min_kmer_size(), get_max_kmer_size()); fprintf(out, "Commands: "); for(i = 0, j = 0; i < n; i++) { if(!cmdobjs[i].hide) { fprintf(out, "%s%s", j > 0 ? " " : "", cmdobjs[i].cmd); s = maxlen - strlen(cmdobjs[i].cmd) + 2; while(--s != SIZE_MAX) fputc(' ', out); fprintf(out, "%s\n", cmdobjs[i].blurb); j++; } } fprintf(out, "\n%s", options); exit(EXIT_FAILURE); }
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; }