1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/take/take.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 = tal_strdup(score, "");
41 for (i = 0; bits[i]; i++) {
43 ret = tal_strcat(score, take(ret), " ");
44 ret = tal_strcat(score, take(ret), bits[i]);
49 static void run_test(void *ctx,
51 unsigned int *timeleft,
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 = tal_fmt(m,
65 i->compiled[COMPILE_NORMAL]);
67 run_command_async(i, *timeleft,
73 i->compiled[COMPILE_NORMAL],
79 run_command_async(i, *timeleft, "%s",
80 i->compiled[COMPILE_NORMAL]);
83 static void do_run_tests(struct manifest *m,
84 unsigned int *timeleft,
87 struct list_head *list;
93 foreach_ptr(list, &m->run_tests, &m->api_tests) {
94 list_for_each(list, i, list) {
97 printf(" %s...\n", i->name);
98 run_test(score, m, timeleft, i);
102 while ((i = collect_command(&ok, &cmdout)) != NULL) {
104 score_file_error(score, i, 0, "%s", cmdout);
108 printf(" ...%s\n", i->name);
111 if (score->score == score->total)
116 /* Gcc's warn_unused_result is fascist bullshit. */
117 #define doesnt_matter()
119 static void run_under_debugger(struct manifest *m, struct score *score)
122 struct file_error *first;
124 first = list_top(&score->per_file_errors, struct file_error, list);
126 if (!ask("Should I run the first failing test under the debugger?"))
129 command = tal_fmt(m, "gdb -ex 'break tap.c:139' -ex 'run' %s",
130 first->file->compiled[COMPILE_NORMAL]);
135 struct ccanlint tests_pass = {
137 .name = "Module's run and api tests pass",
138 .check = do_run_tests,
139 .handle = run_under_debugger,
141 .needs = "tests_compile"
144 REGISTER_TEST(tests_pass);