Commit 5e3987e0 authored by Rusty Russell's avatar Rusty Russell

API tests.

parent 58e2f5cb
...@@ -19,7 +19,8 @@ static int verbose; ...@@ -19,7 +19,8 @@ static int verbose;
struct test_type struct test_type
{ {
const char *name; const char *name;
void (*testfn)(const char *dir, struct test_type *t, const char *name); void (*buildfn)(const char *dir, struct test_type *t, const char *name);
void (*runfn)(const char *name);
}; };
struct test struct test
...@@ -141,6 +142,10 @@ static void compile_fail(const char *dir, struct test_type *t, const char *name) ...@@ -141,6 +142,10 @@ static void compile_fail(const char *dir, struct test_type *t, const char *name)
ok(build(dir, name, 1) > 0, "%s %s", t->name, name); ok(build(dir, name, 1) > 0, "%s %s", t->name, name);
} }
static void no_run(const char *name)
{
}
static void run(const char *name) static void run(const char *name)
{ {
if (system(output_name(name)) == -1) if (system(output_name(name)) == -1)
...@@ -153,9 +158,10 @@ static void cleanup(const char *name) ...@@ -153,9 +158,10 @@ static void cleanup(const char *name)
} }
static struct test_type test_types[] = { static struct test_type test_types[] = {
{ "compile_ok", compile_ok }, { "compile_ok", compile_ok, no_run },
{ "compile_fail", compile_fail }, { "compile_fail", compile_fail, no_run },
{ "run", compile_ok }, { "run", compile_ok, run },
{ "api", compile_ok, run },
}; };
int main(int argc, char *argv[]) int main(int argc, char *argv[])
...@@ -204,14 +210,13 @@ int main(int argc, char *argv[]) ...@@ -204,14 +210,13 @@ int main(int argc, char *argv[])
/* Do all the test compilations. */ /* Do all the test compilations. */
for (test = tests; test; test = test->next) for (test = tests; test; test = test->next)
test->type->testfn(argv[1], test->type, test->name); test->type->buildfn(argv[1], test->type, test->name);
cleanup_objs(); cleanup_objs();
/* Now run all the ones which wanted to run. */ /* Now run all the ones which wanted to run. */
for (test = tests; test; test = test->next) { for (test = tests; test; test = test->next) {
if (streq(test->type->name, "run")) test->type->runfn(test->name);
run(test->name);
cleanup(test->name); cleanup(test->name);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment