1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
5 #include <ccan/foreach/foreach.h>
17 #include "tests_pass.h"
19 bool do_valgrind = false;
21 static const char *can_run(struct manifest *m)
23 unsigned int timeleft = default_timeout_ms;
26 return "Safe mode enabled";
28 if (!is_excluded("tests_pass_valgrind")
29 && run_command(m, &timeleft, &output,
36 static const char *concat(struct score *score, char *bits[])
39 char *ret = talloc_strdup(score, "");
41 for (i = 0; bits[i]; i++) {
43 ret = talloc_append_string(ret, " ");
44 ret = talloc_append_string(ret, bits[i]);
49 static bool run_test(void *ctx,
51 unsigned int *timeleft, char **cmdout,
57 per_file_options(&tests_pass_valgrind, i));
59 if (!streq(options, "FAIL")) {
60 /* FIXME: Valgrind's output sucks. XML is
61 * unreadable by humans *and* doesn't support
62 * children reporting. */
63 i->valgrind_log = talloc_asprintf(m,
65 i->compiled[COMPILE_NORMAL]);
66 talloc_set_destructor(i->valgrind_log,
67 unlink_file_destructor);
69 return run_command(ctx, timeleft, cmdout,
75 i->compiled[COMPILE_NORMAL],
80 return run_command(m, timeleft, cmdout, "%s",
81 i->compiled[COMPILE_NORMAL]);
84 static void do_run_tests(struct manifest *m,
86 unsigned int *timeleft,
89 struct list_head *list;
94 foreach_ptr(list, &m->run_tests, &m->api_tests) {
95 list_for_each(list, i, list) {
98 printf(" %s\n", i->name);
99 if (run_test(score, m, timeleft, &cmdout, i))
102 score_file_error(score, i, 0, "%s", cmdout);
106 if (score->score == score->total)
111 /* Gcc's warn_unused_result is fascist bullshit. */
112 #define doesnt_matter()
114 static void run_under_debugger(struct manifest *m, struct score *score)
117 struct file_error *first;
119 first = list_top(&score->per_file_errors, struct file_error, list);
121 if (!ask("Should I run the first failing test under the debugger?"))
124 command = talloc_asprintf(m, "gdb -ex 'break tap.c:139' -ex 'run' %s",
125 first->file->compiled[COMPILE_NORMAL]);
130 struct ccanlint tests_pass = {
132 .name = "Module's run and api tests pass",
133 .check = do_run_tests,
134 .handle = run_under_debugger,
136 .needs = "tests_compile"
139 REGISTER_TEST(tests_pass);