]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: Add facility to skip tests.
authorMarius Bakke <marius@devup.no>
Sat, 1 Aug 2020 16:02:21 +0000 (18:02 +0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Fri, 8 Jan 2021 03:44:20 +0000 (19:44 -0800)
The Makefile helpfully warns that some tests will fail when
--sysconfdir != /etc, but there are no provisions to easily disable
those.  This commit provides an escape hatch.

[ Lucas: add comment detailing the purpose of the field ]

testsuite/testsuite.c
testsuite/testsuite.h

index e46f3d8b215ac5d1718088e48024e8cfd3ad4002..05df5538079a309212110522bf0a9f687ca7d215 100644 (file)
@@ -37,6 +37,7 @@
 #include "testsuite.h"
 
 static const char *ANSI_HIGHLIGHT_GREEN_ON = "\x1B[1;32m";
+static const char *ANSI_HIGHLIGHT_YELLOW_ON = "\x1B[1;33m";
 static const char *ANSI_HIGHLIGHT_RED_ON =  "\x1B[1;31m";
 static const char *ANSI_HIGHLIGHT_OFF = "\x1B[0m";
 
@@ -948,6 +949,14 @@ static inline int test_run_parent(const struct test *t, int fdout[2],
        int err;
        bool matchout, match_modules;
 
+       if (t->skip) {
+               LOG("%sSKIPPED%s: %s\n",
+                       ANSI_HIGHLIGHT_YELLOW_ON, ANSI_HIGHLIGHT_OFF,
+                       t->name);
+               err = EXIT_SUCCESS;
+               goto exit;
+       }
+
        /* Close write-fds */
        if (t->output.out != NULL)
                close(fdout[1]);
index f1902495137a8c03a9066fe0b6e5caa985b85590..c74b648054ab336273ee29632c8cf8c794498f8f 100644 (file)
@@ -109,6 +109,8 @@ struct test {
        const struct keyval *env_vars;
        bool need_spawn;
        bool expected_fail;
+       /* allow to skip tests that don't meet compile-time dependencies */
+       bool skip;
        bool print_outputs;
 } __attribute__((aligned(8)));