X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fcompile_test_helpers.c;fp=tools%2Fccanlint%2Ftests%2Fcompile_test_helpers.c;h=0ab0cade7e96f427ad5d9f3f4dfdf7d336bf3941;hb=374d3d2eaa1b29dd3f3a940ca472bb209e95155d;hp=0000000000000000000000000000000000000000;hpb=3cd1d24a9e2e578890951d723e0461ed13444650;p=ccan diff --git a/tools/ccanlint/tests/compile_test_helpers.c b/tools/ccanlint/tests/compile_test_helpers.c new file mode 100644 index 00000000..0ab0cade --- /dev/null +++ b/tools/ccanlint/tests/compile_test_helpers.c @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static const char *can_build(struct manifest *m) +{ + if (safe_mode) + return "Safe mode enabled"; + return NULL; +} + +static char *compile(struct manifest *m, + bool keep, + struct ccan_file *cfile) +{ + cfile->compiled = maybe_temp_file(m, ".o", keep, cfile->fullname); + return compile_object(m, cfile->fullname, ccan_dir, "", + cfile->compiled); +} + +static void *do_compile_test_helpers(struct manifest *m, + bool keep, + unsigned int *timeleft) +{ + char *cmdout = NULL; + struct ccan_file *i; + + compile_tests.total_score = 0; + list_for_each(&m->other_test_c_files, i, list) { + compile_tests.total_score++; + cmdout = compile(m, keep, i); + if (cmdout) + return talloc_asprintf(m, + "Failed to compile helper C" + " code file %s:\n%s", + i->name, cmdout); + } + return NULL; +} + +static const char *describe_compile_test_helpers(struct manifest *m, + void *check_result) +{ + return check_result; +} + +struct ccanlint compile_test_helpers = { + .key = "compile-helpers", + .name = "Module test helper objects compile", + .total_score = 1, + .check = do_compile_test_helpers, + .describe = describe_compile_test_helpers, + .can_run = can_build, +}; + +REGISTER_TEST(compile_test_helpers, &depends_built, &has_tests, NULL);