Commit 0fe2d094 authored by David Gibson's avatar David Gibson

ccanlint: Move ccanlint test options from _info comments to code

Currently, _info files can specify options, or note expected failures, for
ccanlint checks in the _info file with specially structured comments. That
differs from most other things ccanlint gets from _info, where it instead
executes the info file with certain parameters.

This changes ccanlint and existing _info files to use the normal method for
the ccanlint test options as well.  This also has the advantage that an
info file can alter its test options based on things from config.h - in
some cases whether a test can work or not might depend on various things.
Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
parent 25b7406d
......@@ -38,9 +38,6 @@
* Author: Joey Adams <joeyadams3.14159@gmail.com>
* License: MIT
* Version: 0.1
* Ccanlint:
* // We actually depend on the LGPL talloc
* license_depends_compat FAIL
*/
int main(int argc, char *argv[])
{
......@@ -53,5 +50,11 @@ int main(int argc, char *argv[])
return 0;
}
if (strcmp(argv[1], "ccanlint") == 0) {
/* We actually depend on the LGPL talloc */
printf("license_depends_compat FAIL\n");
return 0;
}
return 1;
}
......@@ -82,12 +82,6 @@
* }
*
* License: BSD (3 clause)
*
* Ccanlint:
* // We actually depend on the LGPL dependencies
* license_depends_compat FAIL
* // We don't put the license line in all files.
* license_comment FAIL
*/
int main(int argc, char *argv[])
{
......@@ -101,5 +95,13 @@ int main(int argc, char *argv[])
return 0;
}
if (strcmp(argv[1], "ccanlint") == 0) {
/* We actually depend on the LGPL dependencies */
printf("license_depends_compat FAIL\n");
/* We don't put the license line in all files. */
printf("license_comment FAIL\n");
return 0;
}
return 1;
}
......@@ -14,10 +14,6 @@
*
* Author: David Gibson <david@gibson.dropbear.id.au>
* License: LGPL (v2.1 or any later version)
*
* Ccanlint:
* // Context switching really confuses valgrind
* tests_pass_valgrind FAIL
*/
int main(int argc, char *argv[])
{
......@@ -40,5 +36,11 @@ int main(int argc, char *argv[])
return 0;
}
if (strcmp(argv[1], "ccanlint") == 0) {
/* Context switching really confuses valgrind */
printf("tests_pass_valgrind FAIL\n");
return 0;
}
return 1;
}
......@@ -71,9 +71,6 @@
*
* License: LGPL (v2.1 or any later version)
* Author: Rusty Russell <rusty@rustcorp.com.au>
* Ccanlint:
* // We actually depend on the GPL crc routines, so not really LGPL :(
* license_depends_compat FAIL
*/
int main(int argc, char *argv[])
{
......@@ -88,6 +85,11 @@ int main(int argc, char *argv[])
printf("ccan/array_size\n");
return 0;
}
if (strcmp(argv[1], "ccanlint") == 0) {
/* We actually depend on the GPL crc routines, so not really LGPL :( */
printf("license_depends_compat FAIL\n");
return 0;
}
return 1;
}
......@@ -122,12 +122,6 @@
*
* License: APACHE-2
* Author: Dan Good <dan@dancancode.com>
*
* Ccanlint:
* // uses statement expressions
* // supported by gcc, clang, icc, and some others, but not msvc
* // (see https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html)
* objects_build_without_features FAIL
*/
int main(int argc, char *argv[])
{
......@@ -142,5 +136,13 @@ int main(int argc, char *argv[])
return 0;
}
if (strcmp(argv[1], "ccanlint") == 0) {
/* uses statement expressions
* supported by gcc, clang, icc, and some others, but not msvc
* (see https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html) */
printf("objects_build_without_features FAIL\n");
return 0;
}
return 1;
}
......@@ -43,12 +43,6 @@
*
* Author: David Gibson <david@gibson.dropbear.id.au>
* License: LGPL (v2.1 or any later version)
*
* Ccanlint:
* // We need several gcc extensions
* objects_build_without_features FAIL
* tests_compile_without_features FAIL
* tests_helpers_compile_without_features FAIL
*/
int main(int argc, char *argv[])
{
......@@ -78,5 +72,13 @@ int main(int argc, char *argv[])
return 0;
}
if (strcmp(argv[1], "ccanlint") == 0) {
/* We need several gcc extensions */
printf("objects_build_without_features FAIL\n");
printf("tests_compile_without_features FAIL\n");
printf("tests_helpers_compile_without_features FAIL\n");
return 0;
}
return 1;
}
......@@ -26,10 +26,6 @@
*
* Author: David Gibson <david@gibson.dropbear.id.au>
* License: CC0 (Public domain)
*
* Ccanlint:
* // We need several gcc extensions
* tests_compile_without_features FAIL
*/
int main(int argc, char *argv[])
{
......@@ -42,5 +38,11 @@ int main(int argc, char *argv[])
return 0;
}
if (strcmp(argv[1], "ccanlint") == 0) {
/* We need several gcc extensions */
printf("tests_compile_without_features FAIL\n");
return 0;
}
return 1;
}
......@@ -76,13 +76,8 @@
* // $ tail -c +29 /dev/shm/rszshm_LAsEvt/0 | sed 's/./&\n/g' | sort | uniq -c | tr '\n' '\t'; echo
* // 515532 A 527251 B 512930 C 513062 D 544326 E 545876 F 512936 G 522363 H
*
* Ccanlint: tests_pass_valgrind FAIL
* License: APACHE-2
* Author: Dan Good <dan@dancancode.com>
*
* Ccanlint:
* // tests use optional macros containing statement expressions
* tests_compile_without_features FAIL
*/
int main(int argc, char *argv[])
{
......@@ -93,5 +88,12 @@ int main(int argc, char *argv[])
if (strcmp(argv[1], "depends") == 0)
return 0;
if (strcmp(argv[1], "ccanlint") == 0) {
printf("tests_pass_valgrind FAIL\n");
/* tests use optional macros containing statement expressions */
printf("tests_compile_without_features FAIL\n");
return 0;
}
return 1;
}
......@@ -52,9 +52,6 @@
* Authors: Joey Adams, Anders Magnusson
* License: BSD (3 clause)
* Version: 0.2
* Ccanlint:
* // We actually depend (indirectly) on the LGPL talloc
* license_depends_compat FAIL
*/
int main(int argc, char *argv[])
{
......@@ -67,5 +64,11 @@ int main(int argc, char *argv[])
return 0;
}
if (strcmp(argv[1], "ccanlint") == 0) {
/* We actually depend (indirectly) on the LGPL talloc */
printf("license_depends_compat FAIL\n");
return 0;
}
return 1;
}
......@@ -456,50 +456,43 @@ static void add_options(struct ccanlint *test, char **options,
memcpy(&test->options[num], options, (num_options + 1)*sizeof(char *));
}
void add_info_options(struct ccan_file *info)
void add_info_options(struct manifest *m)
{
struct doc_section *d;
unsigned int i;
struct ccanlint *test;
char **info_options = get_ccanlint(m, m->dir, get_or_compile_info);
list_for_each(get_ccan_file_docs(info), d, list) {
if (!streq(d->type, "ccanlint"))
for (i = 0; info_options[i]; i++) {
char **words = tal_strsplit(m, info_options[i], " \t",
STR_NO_EMPTY);
struct ccanlint *test;
if (!words[0])
continue;
test = find_test(words[0]);
if (!test) {
warnx("%s: unknown ccanlint test '%s'",
m->info_file->fullname, words[0]);
continue;
}
if (!words[1]) {
warnx("%s: no argument to test '%s'",
m->info_file->fullname, words[0]);
continue;
}
for (i = 0; i < d->num_lines; i++) {
char **words = tal_strsplit(d, d->lines[i], " \t",
STR_NO_EMPTY);
if (!words[0])
continue;
if (strncmp(words[0], "//", 2) == 0)
continue;
test = find_test(words[0]);
if (!test) {
warnx("%s: unknown ccanlint test '%s'",
info->fullname, words[0]);
continue;
}
if (!words[1]) {
warnx("%s: no argument to test '%s'",
info->fullname, words[0]);
continue;
}
/* Known failure? */
if (strcasecmp(words[1], "FAIL") == 0) {
if (!targeting)
skip_test_and_deps(test,
"excluded in _info"
" file");
} else {
if (!test->takes_options)
warnx("%s: %s doesn't take options",
info->fullname, words[0]);
add_options(test, words+1, tal_count(words)-1);
}
/* Known failure? */
if (strcasecmp(words[1], "FAIL") == 0) {
if (!targeting)
skip_test_and_deps(test,
"excluded in _info"
" file");
} else {
if (!test->takes_options)
warnx("%s: %s doesn't take options",
m->info_file->fullname, words[0]);
add_options(test, words+1, tal_count(words)-1);
}
}
}
......
......@@ -186,7 +186,7 @@ struct dependent {
bool is_excluded(const char *name);
/* Called to add options from _info, once it's located. */
void add_info_options(struct ccan_file *info);
void add_info_options(struct manifest *m);
/* Are we happy to compile stuff, or just non-intrusive tests? */
extern bool safe_mode;
......
......@@ -20,7 +20,7 @@ static void check_has_info(struct manifest *m,
if (m->info_file) {
score->pass = true;
score->score = score->total;
add_info_options(m->info_file);
add_info_options(m);
} else {
score->error = tal_strdup(score,
"You have no _info file.\n\n"
......
......@@ -253,6 +253,12 @@ static char **get_one_cflags(const void *ctx, const char *dir,
return get_one_prop(ctx, dir, "cflags", get_info);
}
static char **get_one_ccanlint(const void *ctx, const char *dir,
char *(*get_info)(const void *ctx, const char *dir))
{
return get_one_prop(ctx, dir, "ccanlint", get_info);
}
/* O(n^2) but n is small. */
static char **add_deps(char **deps1, char **deps2)
{
......@@ -282,6 +288,18 @@ char **get_cflags(const void *ctx, const char *dir,
return flags;
}
char **get_ccanlint(const void *ctx, const char *dir,
char *(*get_info)(const void *ctx, const char *dir))
{
char **ccanlint;
unsigned int len;
ccanlint = get_one_ccanlint(ctx, dir, get_info);
len = tal_count(ccanlint);
tal_resize(&ccanlint, len + 1);
ccanlint[len] = NULL;
return ccanlint;
}
static char *get_one_ported(const void *ctx, const char *dir,
char *(*get_info)(const void *ctx, const char *dir))
{
......
......@@ -48,6 +48,9 @@ char **get_libs(const void *ctx, const char *dir, const char *style,
char **get_cflags(const void *ctx, const char *dir,
char *(*get_info)(const void *ctx, const char *dir));
char **get_ccanlint(const void *ctx, const char *dir,
char *(*get_info)(const void *ctx, const char *dir));
char *get_ported(const void *ctx, const char *dir, bool recurse,
char *(*get_info)(const void *ctx, const char *dir));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment