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;
24 if (!run_command(m, &timeleft, &output,
25 "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 if (run_command(score, timeleft, &cmdout,
45 "valgrind -q --error-exitcode=100%s %s",
46 run_tests_vg.options ?
47 run_tests_vg.options : "",
51 score_file_error(score, i, 0, cmdout);
56 if (score->score == score->total)
60 /* Gcc's warn_unused_result is fascist bullshit. */
61 #define doesnt_matter()
63 static void run_under_debugger_vg(struct manifest *m, struct score *score)
65 struct file_error *first;
68 if (!ask("Should I run the first failing test under the debugger?"))
71 first = list_top(&score->per_file_errors, struct file_error, list);
72 command = talloc_asprintf(m, "valgrind --db-attach=yes %s",
73 first->file->compiled);
78 struct ccanlint run_tests_vg = {
79 .key = "valgrind-tests",
80 .name = "Module's run and api tests succeed under valgrind",
81 .can_run = can_run_vg,
82 .check = do_run_tests_vg,
83 .handle = run_under_debugger_vg,
87 REGISTER_TEST(run_tests_vg, &run_tests, NULL);