]> git.ozlabs.org Git - ccan/blob - tools/ccanlint/tests/info_summary_single_line.c
configurator: HAVE_PROC_SELF_MAPS
[ccan] / tools / ccanlint / tests / info_summary_single_line.c
1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <stdio.h>
4 #include <ccan/talloc/talloc.h>
5 #include <ccan/str/str.h>
6
7 static void check_info_summary_single_line(struct manifest *m,
8                                            unsigned int *timeleft,
9                                            struct score *score)
10 {
11         struct list_head *infodocs = get_ccan_file_docs(m->info_file);
12         struct doc_section *d;
13
14         score->pass = true;
15         score->score = 1;
16
17         list_for_each(infodocs, d, list) {
18                 const char *after;
19
20                 if (!streq(d->type, "summary"))
21                         continue;
22
23                 /* line following summary line should be empty */
24                 after = m->info_file->lines[d->srcline+1];
25                 if (after && strspn(after, " *") != strlen(after)) {
26                         score->pass = false;
27                         score->score = 0;
28                         score_file_error(score, m->info_file, d->srcline+1,
29                                          "%s\n%s",
30                                          m->info_file->lines[d->srcline],
31                                          m->info_file->lines[d->srcline+1]);
32                 }
33         }
34 }
35
36 struct ccanlint info_summary_single_line = {
37         .key = "info_summary_single_line",
38         .name = "Module has a single line summary in _info",
39         .check = check_info_summary_single_line,
40         .needs = "info_exists"
41 };
42
43 REGISTER_TEST(info_summary_single_line);