1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
17 static const char *can_run(struct manifest *m)
20 return "Safe mode enabled";
24 static void *do_run_tests(struct manifest *m)
26 struct list_head *list = talloc(m, struct list_head);
27 char *failures = talloc_strdup(m, "");
32 list_for_each(&m->run_tests, i, list) {
34 run_tests.total_score++;
35 /* FIXME: timeout here */
36 testout = run_command(m, i->compiled);
39 failures = talloc_asprintf_append(failures,
40 "Running %s failed:\n",
42 failures = talloc_append_string(failures, testout);
45 list_for_each(&m->api_tests, i, list) {
47 run_tests.total_score++;
48 /* FIXME: timeout here */
49 testout = run_command(m, i->compiled);
52 failures = talloc_asprintf_append(failures,
53 "Running %s failed:\n",
55 failures = talloc_append_string(failures, testout);
58 if (streq(failures, "")) {
59 talloc_free(failures);
66 static unsigned int score_run_tests(struct manifest *m, void *check_result)
68 /* FIXME: be cleverer here */
72 static const char *describe_run_tests(struct manifest *m,
75 char *descrip = talloc_strdup(check_result, "Running tests failed:\n");
77 return talloc_append_string(descrip, check_result);
80 struct ccanlint run_tests = {
81 .name = "run and api tests run successfully",
82 .score = score_run_tests,
83 .check = do_run_tests,
84 .describe = describe_run_tests,
88 REGISTER_TEST(run_tests, &compile_tests, NULL);