X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fcompile_test_helpers.c;h=de8d4632c9fbea9aa9ff992a2b0a0eb78a879d91;hp=017a5308cbc4b48f6cba5b5f7bb6cae615efbdcc;hb=687cde2a8c561b68f17609b615eb930ea02f5aac;hpb=4e0dfdadf206c74dc9e5f302545b2419cc4798f4 diff --git a/tools/ccanlint/tests/compile_test_helpers.c b/tools/ccanlint/tests/compile_test_helpers.c index 017a5308..de8d4632 100644 --- a/tools/ccanlint/tests/compile_test_helpers.c +++ b/tools/ccanlint/tests/compile_test_helpers.c @@ -21,24 +21,14 @@ static const char *can_build(struct manifest *m) return NULL; } -static int cleanup_testfile(char *testfile) +static char *compile(struct manifest *m, struct ccan_file *cfile) { - unlink(testfile); - return 0; -} - -static char *objname(const void *ctx, const char *cfile) -{ - return talloc_asprintf(ctx, "%.*s.o ", strlen(cfile) - 2, cfile); -} - -static char *compile(struct manifest *m, const char *cfile) -{ - char *obj; + char *err; - obj = objname(m, cfile); - talloc_set_destructor(obj, cleanup_testfile); - return run_command(m, "cc " CFLAGS " -c -o %s %s", obj, cfile); + cfile->compiled = compile_object(m, cfile->name, &err); + if (cfile->compiled) + return NULL; + return err; } static void *do_compile_test_helpers(struct manifest *m) @@ -48,7 +38,7 @@ static void *do_compile_test_helpers(struct manifest *m) list_for_each(&m->other_test_c_files, i, list) { compile_tests.total_score++; - cmdout = compile(m, i->name); + cmdout = compile(m, i); if (cmdout) return talloc_asprintf(m, "Failed to compile helper C"