X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Fcompulsory_tests%2Fmain_header_exists.c;fp=tools%2Fccanlint%2Fcompulsory_tests%2Fmain_header_exists.c;h=68ea1359581d59dc0fd11e8db3202dc9dfe0d652;hp=0000000000000000000000000000000000000000;hb=051db34fb275491d4d5dfa5bf7970e8e525766d8;hpb=2926cafb52b9d95646d9dafa877d53f2368d8b2c diff --git a/tools/ccanlint/compulsory_tests/main_header_exists.c b/tools/ccanlint/compulsory_tests/main_header_exists.c new file mode 100644 index 00000000..68ea1359 --- /dev/null +++ b/tools/ccanlint/compulsory_tests/main_header_exists.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void check_has_main_header(struct manifest *m, + bool keep, + unsigned int *timeleft, struct score *score) +{ + struct ccan_file *f; + + list_for_each(&m->h_files, f, list) { + if (strstarts(f->name, m->basename) + && strlen(f->name) == strlen(m->basename) + 2) { + score->pass = true; + score->score = score->total; + return; + } + } + score->error = talloc_asprintf(score, + "You have no %s/%s.h header file.\n\n" + "CCAN modules have a name, the same as the directory name. They're\n" + "expected to have an interface in the header of the same name.\n", + m->basename, m->basename); +} + +struct ccanlint main_header_exists = { + .key = "main_header_exists", + .name = "Module has main header file", + .check = check_has_main_header, + .needs = "" +}; + +REGISTER_TEST(main_header_exists);