X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Frun_tests.c;h=278b65227a3bdeddbe9631c116c5e31a8b643cd5;hp=3ae752373de1b0e9c55e61647f82c43bbfcb2271;hb=504c6dab8d2c94575f14ccb542af7433936e7af2;hpb=9965fc25fcc92dc76d1cd4cf9595dc3dc9ebc586 diff --git a/tools/run_tests.c b/tools/run_tests.c index 3ae75237..278b6522 100644 --- a/tools/run_tests.c +++ b/tools/run_tests.c @@ -4,14 +4,14 @@ #include #include #include +#include +#include #include "ccan/tap/tap.h" #include "ccan/talloc/talloc.h" #include "ccan/str/str.h" +#include "ccan/array_size/array_size.h" #include "tools.h" -/* FIXME: Use build bug later. */ -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) - static struct test *tests = NULL; static struct obj *objs = NULL; static int verbose; @@ -103,20 +103,10 @@ static int build(const char *dir, const char *name, int fail) { const char *cmd; int ret; - char *externals = talloc_strdup(name, ""); - char **deps; - - for (deps = get_deps(talloc_autofree_context(), dir); *deps; deps++) { - if (!strstarts(*deps, "ccan/")) - continue; - - /* ccan/foo -> ccan/foo.o */ - externals = talloc_asprintf_append(externals, " %s.o", *deps); - } - cmd = talloc_asprintf(name, "gcc " CFLAGS " %s -o %s %s %s%s%s", + cmd = talloc_asprintf(name, "gcc " CFLAGS " %s -o %s %s %s -L. -lccan %s", fail ? "-DFAIL" : "", - output_name(name), name, obj_list(), externals, + output_name(name), name, obj_list(), verbose ? "" : "> /dev/null 2>&1"); if (verbose) @@ -148,8 +138,8 @@ static void no_run(const char *name) static void run(const char *name) { - if (system(output_name(name)) == -1) - fail("running %s had error %m", name); + if (system(output_name(name)) != 0) + fail("running %s had error", name); } static void cleanup(const char *name)