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 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 = talloc_asprintf(m,
65 i->compiled[COMPILE_NORMAL]);
66 talloc_set_destructor(i->valgrind_log,
67 unlink_file_destructor);
69 run_command_async(i, *timeleft,
75 i->compiled[COMPILE_NORMAL],
81 run_command_async(i, *timeleft, "%s",
82 i->compiled[COMPILE_NORMAL]);
85 static void do_run_tests(struct manifest *m,
87 unsigned int *timeleft,
90 struct list_head *list;
96 foreach_ptr(list, &m->run_tests, &m->api_tests) {
97 list_for_each(list, i, list) {
100 printf(" %s...\n", i->name);
101 run_test(score, m, timeleft, i);
105 while ((i = collect_command(&ok, &cmdout)) != NULL) {
107 score_file_error(score, i, 0, "%s", cmdout);
111 printf(" ...%s\n", i->name);
114 if (score->score == score->total)
119 /* Gcc's warn_unused_result is fascist bullshit. */
120 #define doesnt_matter()
122 static void run_under_debugger(struct manifest *m, struct score *score)
125 struct file_error *first;
127 first = list_top(&score->per_file_errors, struct file_error, list);
129 if (!ask("Should I run the first failing test under the debugger?"))
132 command = talloc_asprintf(m, "gdb -ex 'break tap.c:139' -ex 'run' %s",
133 first->file->compiled[COMPILE_NORMAL]);
138 struct ccanlint tests_pass = {
140 .name = "Module's run and api tests pass",
141 .check = do_run_tests,
142 .handle = run_under_debugger,
144 .needs = "tests_compile"
147 REGISTER_TEST(tests_pass);