]> git.ozlabs.org Git - ccan/blobdiff - tools/run_tests.c
Teach ccanlint about API tests.
[ccan] / tools / run_tests.c
index eab42add8dfb06a6cf623181d37a30a7b3811298..380055c0259a8bc8d393ba0b4edbfcf11a43597d 100644 (file)
@@ -4,9 +4,11 @@
 #include <dirent.h>
 #include <assert.h>
 #include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
 #include "ccan/tap/tap.h"
 #include "ccan/talloc/talloc.h"
-#include "ccan/string/string.h"
+#include "ccan/str/str.h"
 #include "tools.h"
 
 /* FIXME: Use build bug later. */
@@ -103,20 +105,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(objs, 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 +140,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)