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, ...)
16 /* The module name, ie. final element of dir name */
18 struct ccan_file *info_file;
20 struct list_head c_files;
21 struct list_head h_files;
23 struct list_head run_tests;
24 struct list_head api_tests;
25 struct list_head compile_ok_tests;
26 struct list_head compile_fail_tests;
27 struct list_head other_test_c_files;
28 struct list_head other_test_files;
30 struct list_head other_files;
32 /* From tests/check_depends_exist.c */
33 struct list_head dep_dirs;
36 struct manifest *get_manifest(const void *ctx, const char *dir);
39 struct list_node list;
41 /* More concise unique name of test. */
44 /* Unique name of test */
47 /* Total score that this test is worth. */
48 unsigned int total_score;
50 /* Can we run this test? Return string explaining why, if not. */
51 const char *(*can_run)(struct manifest *m);
53 /* If this returns non-NULL, it means the check failed.
54 * If timeleft is set to 0, means it timed out. */
55 void *(*check)(struct manifest *m, unsigned int *timeleft);
57 /* The non-NULL return from check is passed to one of these: */
59 /* So, what did this get out of the total_score? (NULL means 0). */
60 unsigned int (*score)(struct manifest *m, void *check_result);
62 /* Verbose description of what was wrong. */
63 const char *(*describe)(struct manifest *m, void *check_result);
65 /* Can we do something about it? (NULL if not) */
66 void (*handle)(struct manifest *m, void *check_result);
68 /* Internal use fields: */
69 /* Who depends on us? */
70 struct list_head dependencies;
71 /* How many things do we (still) depend on? */
72 unsigned int num_depends;
73 /* Did we skip a dependency? If so, must skip this, too. */
75 /* Did we fail a dependency? If so, skip and mark as fail. */
79 /* Ask the user a yes/no question: the answer is NO if there's an error. */
80 bool ask(const char *question);
83 PREPROC_LINE, /* Line starts with # */
84 CODE_LINE, /* Code (ie. not pure comment). */
85 DOC_LINE, /* Line with kernel-doc-style comment. */
86 COMMENT_LINE, /* (pure) comment line */
89 /* So far, only do simple #ifdef/#ifndef/#if defined/#if !defined tests,
90 * and #if <SYMBOL>/#if !<SYMBOL> */
91 struct pp_conditions {
92 /* We're inside another ifdef? */
93 struct pp_conditions *parent;
105 /* Preprocessor information about each line. */
107 enum line_info_type type;
109 /* Is this actually a continuation of line above? (which ends in \) */
112 /* Conditions for this line to be compiled. */
113 struct pp_conditions *cond;
117 struct list_node list;
119 /* Name (usually, within m->dir). */
122 /* Full path name. */
125 /* Pristine version of the original file.
126 * Use get_ccan_file_lines to fill this. */
127 const char *contents;
128 size_t contents_size;
130 /* Use get_ccan_file_lines / get_ccan_line_info to fill these. */
131 unsigned int num_lines;
133 struct line_info *line_info;
135 struct list_head *doc_sections;
137 /* If this file gets compiled (eg. .C file to .o file), result here. */
141 /* A new ccan_file, with the given name (talloc_steal onto returned value). */
142 struct ccan_file *new_ccan_file(const void *ctx, const char *dir, char *name);
144 /* Use this rather than accessing f->lines directly: loads on demand. */
145 char **get_ccan_file_lines(struct ccan_file *f);
147 /* Use this rather than accessing f->lines directly: loads on demand. */
148 struct line_info *get_ccan_line_info(struct ccan_file *f);
156 /* Simple evaluator. If symbols are set this way, is this condition true?
157 * NULL values mean undefined, NULL symbol terminates. */
158 enum line_compiled get_ccan_line_pp(struct pp_conditions *cond,
160 const unsigned int *value, ...);
162 /* Get token if it's equal to token. */
163 bool get_token(const char **line, const char *token);
164 /* Talloc copy of symbol token, or NULL. Increment line. */
165 char *get_symbol_token(void *ctx, const char **line);
167 /* Similarly for ->doc_sections */
168 struct list_head *get_ccan_file_docs(struct ccan_file *f);
171 /* Call the reporting on every line in the file. sofar contains
172 * previous results. */
173 char *report_on_lines(struct list_head *files,
174 char *(*report)(const char *),
178 extern struct ccanlint trailing_whitespace;
182 struct list_node node;
183 struct ccanlint *dependent;
186 /* Are we happy to compile stuff, or just non-intrusive tests? */
187 extern bool safe_mode;
189 /* Where is the ccan dir? Available after first manifest. */
190 extern const char *ccan_dir;
192 #endif /* CCAN_LINT_H */