3 #include <ccan/list/list.h>
5 #include "../doc_extract.h"
7 #define REGISTER_TEST(name, ...) extern struct ccanlint name
8 #include "generated-compulsory-tests"
9 #include "generated-normal-tests"
12 #define REGISTER_TEST(name, ...)
14 /* 1 == Describe results for partial failures.
15 2 == Describe gory details.
16 3 == Describe every action. */
17 extern unsigned int verbose;
21 /* The module name, ie. final element of dir name */
23 struct ccan_file *info_file;
25 struct list_head c_files;
26 struct list_head h_files;
28 struct list_head run_tests;
29 struct list_head api_tests;
30 struct list_head compile_ok_tests;
31 struct list_head compile_fail_tests;
32 struct list_head other_test_c_files;
33 struct list_head other_test_files;
35 struct list_head other_files;
37 /* From tests/check_depends_exist.c */
38 struct list_head dep_dirs;
41 struct manifest *get_manifest(const void *ctx, const char *dir);
44 struct list_node list;
46 /* More concise unique name of test. */
49 /* Unique name of test */
52 /* Total score that this test is worth. */
53 unsigned int total_score;
55 /* Can we run this test? Return string explaining why, if not. */
56 const char *(*can_run)(struct manifest *m);
58 /* If this returns non-NULL, it means the check failed.
59 * keep is set if you should keep the results.
60 * If timeleft is set to 0, means it timed out. */
61 void *(*check)(struct manifest *m, bool keep, unsigned int *timeleft);
63 /* The non-NULL return from check is passed to one of these: */
65 /* So, what did this get out of the total_score? (NULL means 0). */
66 unsigned int (*score)(struct manifest *m, void *check_result);
68 /* Verbose description of what was wrong. */
69 const char *(*describe)(struct manifest *m, void *check_result);
71 /* Can we do something about it? (NULL if not) */
72 void (*handle)(struct manifest *m, void *check_result);
74 /* Internal use fields: */
75 /* Who depends on us? */
76 struct list_head dependencies;
77 /* How many things do we (still) depend on? */
78 unsigned int num_depends;
79 /* Did we skip a dependency? If so, must skip this, too. */
81 /* Did we fail a dependency? If so, skip and mark as fail. */
83 /* Did the user want to keep these results? */
87 /* Ask the user a yes/no question: the answer is NO if there's an error. */
88 bool ask(const char *question);
91 PREPROC_LINE, /* Line starts with # */
92 CODE_LINE, /* Code (ie. not pure comment). */
93 DOC_LINE, /* Line with kernel-doc-style comment. */
94 COMMENT_LINE, /* (pure) comment line */
97 /* So far, only do simple #ifdef/#ifndef/#if defined/#if !defined tests,
98 * and #if <SYMBOL>/#if !<SYMBOL> */
99 struct pp_conditions {
100 /* We're inside another ifdef? */
101 struct pp_conditions *parent;
113 /* Preprocessor information about each line. */
115 enum line_info_type type;
117 /* Is this actually a continuation of line above? (which ends in \) */
120 /* Conditions for this line to be compiled. */
121 struct pp_conditions *cond;
125 struct list_node list;
127 /* Name (usually, within m->dir). */
130 /* Full path name. */
133 /* Pristine version of the original file.
134 * Use get_ccan_file_lines to fill this. */
135 const char *contents;
136 size_t contents_size;
138 /* Use get_ccan_file_lines / get_ccan_line_info to fill these. */
139 unsigned int num_lines;
141 struct line_info *line_info;
143 struct list_head *doc_sections;
145 /* If this file gets compiled (eg. .C file to .o file), result here. */
148 /* Compiled with coverage information. */
152 /* A new ccan_file, with the given name (talloc_steal onto returned value). */
153 struct ccan_file *new_ccan_file(const void *ctx, const char *dir, char *name);
155 /* Use this rather than accessing f->lines directly: loads on demand. */
156 char **get_ccan_file_lines(struct ccan_file *f);
158 /* Use this rather than accessing f->lines directly: loads on demand. */
159 struct line_info *get_ccan_line_info(struct ccan_file *f);
167 /* Simple evaluator. If symbols are set this way, is this condition true?
168 * NULL values mean undefined, NULL symbol terminates. */
169 enum line_compiled get_ccan_line_pp(struct pp_conditions *cond,
171 const unsigned int *value, ...);
173 /* Get token if it's equal to token. */
174 bool get_token(const char **line, const char *token);
175 /* Talloc copy of symbol token, or NULL. Increment line. */
176 char *get_symbol_token(void *ctx, const char **line);
178 /* Similarly for ->doc_sections */
179 struct list_head *get_ccan_file_docs(struct ccan_file *f);
182 /* Call the reporting on every line in the file. sofar contains
183 * previous results. */
184 char *report_on_lines(struct list_head *files,
185 char *(*report)(const char *),
189 extern struct ccanlint trailing_whitespace;
193 struct list_node node;
194 struct ccanlint *dependent;
197 /* Are we happy to compile stuff, or just non-intrusive tests? */
198 extern bool safe_mode;
200 /* Where is the ccan dir? Available after first manifest. */
201 extern const char *ccan_dir;
203 #endif /* CCAN_LINT_H */