9 void trick_compiler(int *x);
11 static void test_abort(void)
16 static void test_segfault(void)
21 static void test_leak(void)
23 int *p = malloc(sizeof *p);
27 static void test_undefined(void)
33 static void test_undefined_branch(void)
44 static void test_read_after_free(void)
46 int *p = malloc(sizeof *p);
52 static void test_write_after_free(void)
54 int *p = malloc(sizeof *p);
60 typedef void (*test_fun)(void);
67 #define TEST(f) { .name = #f, .fun = test_##f, }
68 static struct test tests[] = {
73 TEST(undefined_branch),
74 TEST(read_after_free),
75 TEST(write_after_free),
77 #define ntests (sizeof tests / sizeof *tests)
79 int main(int argc, char *argv[])
84 fprintf(stderr, "Usage: test_helper <test>\n");
89 for (i = 0; i < ntests; ++i)
90 if (!strcmp(argv[1], tests[i].name)) {
92 printf("Running test: %s\n", tests[i].name);
98 fprintf(stderr, "Unable to find test: %s\n", argv[1]);