int main(void) { test_fun(TEST_NUM); test_max(MAX(5, 10)); return 0; }
void test_run(int id, const test_ctx_t *ctx, int *status) { if (id < test_max()) (*tests[id].test_function)(ctx, status); else *status = ERANGE; }
void test_get_name(int id, char *buffer, size_t len) { if (id < test_max()) strncpy(buffer, tests[id].name, ((len < strlen(tests[id].name) + 1) ? len : strlen(tests[id].name) + 1)); else buffer = NULL; }
void test(){ test_sum(); test_max(); test_min(); test_second_max(); test_second_min(); test_equal(); test_occurences(); test_countNegatives(); test_indexOf(); test_clearWith(); test_insertElement(); test_removeElement(); test_copy(); test_merge(); test_reverse(); test_sort(); printf("All passed!!!!"); }
int main(int argc, char *argv[]) { log_parse_environment(); log_open(); test_align_power2(); test_max(); test_container_of(); test_div_round_up(); test_u64log2(); test_protect_errno(); test_in_set(); test_log2i(); test_raw_clone(); test_physical_memory(); test_physical_memory_scale(); test_system_tasks_max(); test_system_tasks_max_scale(); return 0; }
int main(int argc, char *argv[]) { test_setup_logging(LOG_INFO); test_align_power2(); test_max(); test_container_of(); test_div_round_up(); test_u64log2(); test_protect_errno(); test_unprotect_errno(); test_in_set(); test_log2i(); test_eqzero(); test_raw_clone(); test_physical_memory(); test_physical_memory_scale(); test_system_tasks_max(); test_system_tasks_max_scale(); return 0; }
void run() { test_zero(); test_zero_white(); test_hundred(); test_minus_hundred(); test_large(); test_max(); fail_minus(); fail_minus_white(); fail_minus_alpha(); fail_too_large(); fail_as_float(); fail_as_string(); test_short(); test_int(); test_long(); test_intmax(); test_unsigned(); fail_unsigned_negative(); }
int main(int argc, char **argv) { int ch, test_cur, test_total, i; int *result; test_ctx_t ctx; char namebuf[100] = { '\0' }; int skip[256] = { -1 }; int skipcount = 0; int skipflag; test_init(&ctx); memset(skip, -1, 256*sizeof(int)); while ((ch = getopt(argc, argv, "hCd:r:z:s:")) != -1) { switch (ch) { case 'h': usage(); return EXIT_SUCCESS; case 'C': ctx.cleanup = 0; break; case 'd': if (NULL != optarg) hlp_path_clean(optarg, ctx.workdir, 2048); else return EXIT_FAILURE; break; case 'r': if (NULL != optarg) hlp_path_clean(optarg, ctx.random_device, 2048); else return EXIT_FAILURE; break; case 's': skip[skipcount] = atoi(optarg); skipcount++; if (skipcount > 255) skipcount--; break; case 'z': if (NULL != optarg) hlp_path_clean(optarg, ctx.zero_device, 2048); else return EXIT_FAILURE; break; default: printf("\n"); usage(); return EXIT_FAILURE; } } if (strlen(ctx.workdir) == 0) hlp_path_clean(DEFAULT_DIR, ctx.workdir, 2048); if (strlen(ctx.random_device) == 0) hlp_path_clean(DEFAULT_RANDOM, ctx.random_device, 2048); if (strlen(ctx.zero_device) == 0) hlp_path_clean(DEFAULT_ZERO, ctx.zero_device, 2048); /* determine total number of tests */ test_total = test_max(); result = (int *)malloc(test_total * sizeof(int)); if (NULL == result) { hlp_report_error(errno); return EXIT_FAILURE; } /* Standard message */ printf("\n=============================\nlibsynctory testing framework\n=============================\n\n"); /* display settings */ printf("Settings for current test run:\n------------------------------\n\n"); printf("Working directory: %s\n", ctx.workdir); printf("Random device: %s\n", ctx.random_device); printf("Zero device: %s\n", ctx.zero_device); printf("Delete temporary files: "); if (ctx.cleanup) printf("YES\n"); else printf("NO\n"); printf("\n\n\n"); /* run tests */ for (test_cur = 0; test_cur < test_total; test_cur++) { memset(namebuf, (int)'\0', 100); test_get_name(test_cur, namebuf, 100); printf("Test %02d of %02d: %s\n---------------", test_cur + 1, test_total, namebuf); for (i = 0; i < (int)strlen(namebuf); i++) printf("-"); printf("\n\n"); skipflag = 0; for (i = 0; i < 256; i++) { if (skip[i] == (test_cur + 1)) { skipflag = 1; break; } } if (skipflag ) { result[test_cur] = 0; printf("\nTest %02d of %02d skipped.\n\n\n", test_cur + 1, test_total); } else { test_run(test_cur, &ctx, &i); printf("\nTest %02d of %02d ", test_cur + 1, test_total); if (i) { printf("failed: "); result[test_cur] = 1; hlp_report_error(i); printf("\n\n"); } else { result[test_cur] = 2; printf("passed.\n\n\n"); } } } printf("\nTest Summary\n============\n\n"); printf("Test No. Description Result\n" "-------- -------------------------------------------------------------- -------\n"); for (test_cur = 0; test_cur < test_total; test_cur++) { memset(namebuf, (int)'\0', 100); test_get_name(test_cur, namebuf, 100); printf("%02d ", test_cur + 1); if (strlen(namebuf) > 62) printf("%62s ", namebuf); else { printf("%s", namebuf); for (i = 0; i < (62 - (int)strlen(namebuf)); i++) printf(" "); printf(" "); } if (result[test_cur] == 1) printf("failed\n"); else if (result[test_cur] == 2) printf("passed\n"); else printf("skipped\n"); } printf("\n"); return EXIT_SUCCESS; }
int main() { res.defi = -1; res.defd = -0.999; res.defl = -123; res.add_int = 0; res.add_real = 0.0; res.add_long = 0; int ints[MAX]; double reals[MAX]; long long longs[MAX]; Value val_ints[MAX]; Value val_reals[MAX]; Value val_longs[MAX]; Tuple *tuples[MAX]; for (int i = 0; i < MAX; ++i) { ints[i] = i + 1; reals[i] = i + 0.5; longs[i] = 0x7000ffffffffffff; val_ints[i] = val_new_int(&ints[i]); val_reals[i] = val_new_real(&reals[i]); val_longs[i] = val_new_long(&longs[i]); if (i == 0 || ints[i] > res.max_int) res.max_int = ints[i]; if (i == 0 || reals[i] > res.max_real) res.max_real = reals[i]; if (i == 0 || longs[i] > res.max_long) res.max_long = longs[i]; if (i == 0 || ints[i] < res.min_int) res.min_int = ints[i]; if (i == 0 || reals[1] < res.min_real) res.min_real = reals[i]; if (i == 0 || longs[i] < res.min_long) res.min_long = longs[i]; res.add_int += ints[i]; res.add_real += reals[i]; res.add_long += longs[i]; } res.avg_int = (double) res.add_int / MAX; res.avg_real = res.add_real / MAX; res.avg_long = (double) res.add_long / MAX; Value vals[3]; for (int i = 0; i < MAX; ++i) { vals[0] = val_ints[i]; vals[1] = val_reals[i]; vals[2] = val_longs[i]; tuples[i] = tuple_new(vals, 3); } test_cnt(tuples); test_min(tuples); test_max(tuples); test_avg(tuples); test_add(tuples); for (int i = 0; i < MAX; ++i) tuple_free(tuples[i]); return 0; }