ccanlint: remove argument to -k/--keep
[ccan] / tools / ccanlint / tests / tests_pass_without_features.c
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>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include <unistd.h>
10 #include <limits.h>
11 #include <errno.h>
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <err.h>
15 #include <string.h>
16 #include <ctype.h>
17
18 /* We don't do these under valgrind: too slow! */
19 static void do_run_tests_no_features(struct manifest *m,
20                                      unsigned int *timeleft,
21                                      struct score *score)
22 {
23         struct list_head *list;
24         struct ccan_file *i;
25         char *cmdout;
26
27         score->total = 0;
28         foreach_ptr(list, &m->run_tests, &m->api_tests) {
29                 list_for_each(list, i, list) {
30                         score->total++;
31                         if (verbose >= 2)
32                                 printf("   %s\n", i->name);
33                         if (run_command(m, timeleft, &cmdout, "%s",
34                                         i->compiled[COMPILE_NOFEAT]))
35                                 score->score++;
36                         else
37                                 score_file_error(score, i, 0, "%s", cmdout);
38                 }
39         }
40
41         if (score->score == score->total)
42                 score->pass = true;
43 }
44
45 /* Gcc's warn_unused_result is fascist bullshit. */
46 #define doesnt_matter()
47
48 static void run_under_debugger(struct manifest *m, struct score *score)
49 {
50         char *command;
51         struct file_error *first;
52
53         first = list_top(&score->per_file_errors, struct file_error, list);
54
55         if (!ask("Should I run the first failing test under the debugger?"))
56                 return;
57
58         command = talloc_asprintf(m, "gdb -ex 'break tap.c:139' -ex 'run' %s",
59                                   first->file->compiled
60                                   [COMPILE_NOFEAT]);
61         if (system(command))
62                 doesnt_matter();
63 }
64
65 struct ccanlint tests_pass_without_features = {
66         .key = "tests_pass_without_features",
67         .name = "Module's run and api tests pass (without features)",
68         .check = do_run_tests_no_features,
69         .handle = run_under_debugger,
70         .needs = "tests_compile_without_features"
71 };
72
73 REGISTER_TEST(tests_pass_without_features);