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 run_tests.total_score = 0;
33 list_for_each(&m->run_tests, i, list) {
35 run_tests.total_score++;
36 /* FIXME: timeout here */
37 testout = run_command(m, i->compiled);
40 failures = talloc_asprintf_append(failures,
41 "Running %s failed:\n",
43 failures = talloc_append_string(failures, testout);
46 list_for_each(&m->api_tests, i, list) {
48 run_tests.total_score++;
49 /* FIXME: timeout here */
50 testout = run_command(m, i->compiled);
53 failures = talloc_asprintf_append(failures,
54 "Running %s failed:\n",
56 failures = talloc_append_string(failures, testout);
59 if (streq(failures, "")) {
60 talloc_free(failures);
67 static unsigned int score_run_tests(struct manifest *m, void *check_result)
69 /* FIXME: be cleverer here */
73 static const char *describe_run_tests(struct manifest *m,
76 char *descrip = talloc_strdup(check_result, "Running tests failed:\n");
78 return talloc_append_string(descrip, check_result);
81 struct ccanlint run_tests = {
82 .name = "run and api tests run successfully",
84 .score = score_run_tests,
85 .check = do_run_tests,
86 .describe = describe_run_tests,
90 REGISTER_TEST(run_tests, &compile_tests, NULL);