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>
18 /* Note: we already test safe_mode in run_tests.c */
19 static const char *can_run_vg(struct manifest *m)
21 unsigned int timeleft = default_timeout_ms;
22 char *output = run_command(m, &timeleft,
23 "valgrind -q --error-exitcode=0 true");
26 return talloc_asprintf(m, "No valgrind support: %s", output);
30 /* FIXME: Run examples, too! */
31 static void do_run_tests_vg(struct manifest *m,
33 unsigned int *timeleft,
37 struct list_head *list;
41 foreach_ptr(list, &m->run_tests, &m->api_tests) {
42 list_for_each(list, i, list) {
44 cmdout = run_command(m, timeleft,
45 "valgrind -q --error-exitcode=100 %s",
48 score->error = "Running under valgrind";
49 score_file_error(score, i, 0, cmdout);
55 if (score->score == score->total)
59 /* Gcc's warn_unused_result is fascist bullshit. */
60 #define doesnt_matter()
62 static void run_under_debugger_vg(struct manifest *m, struct score *score)
64 struct file_error *first;
67 if (!ask("Should I run the first failing test under the debugger?"))
70 first = list_top(&score->per_file_errors, struct file_error, list);
71 command = talloc_asprintf(m, "valgrind --db-attach=yes %s",
72 first->file->compiled);
77 struct ccanlint run_tests_vg = {
78 .key = "valgrind-tests",
79 .name = "Module's run and api tests succeed under valgrind",
80 .can_run = can_run_vg,
81 .check = do_run_tests_vg,
82 .handle = run_under_debugger_vg
85 REGISTER_TEST(run_tests_vg, &run_tests, NULL);