test: abort if we have a test that doesn't run for any devices
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 1 Dec 2015 23:27:22 +0000 (09:27 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 2 Dec 2015 21:33:44 +0000 (07:33 +1000)
If the test is filtered out and we never run it generates a false positive.
Though it isn't listed in the "Checks" summary this is a bit hard to tell when
you're running >700 tests.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
test/litest.c

index 65be6b5a7dcfdbf93c9d2d4c664c84209bfc4ee4..e235bc937921a38216aeac7cf13da6472f434787 100644 (file)
@@ -590,6 +590,7 @@ litest_add_tcase(const char *suite_name,
 {
        struct litest_test_device **dev = devices;
        struct suite *suite;
+       bool added = false;
 
        assert(required >= LITEST_DISABLE_DEVICE);
        assert(excluded >= LITEST_DISABLE_DEVICE);
@@ -607,6 +608,7 @@ litest_add_tcase(const char *suite_name,
        if (required == LITEST_DISABLE_DEVICE &&
            excluded == LITEST_DISABLE_DEVICE) {
                litest_add_tcase_no_device(suite, func, range);
+               added = true;
        } else if (required != LITEST_ANY || excluded != LITEST_ANY) {
                for (; *dev; dev++) {
                        if (filter_device &&
@@ -621,6 +623,7 @@ litest_add_tcase(const char *suite_name,
                                                    func,
                                                    *dev,
                                                    range);
+                       added = true;
                }
        } else {
                for (; *dev; dev++) {
@@ -633,8 +636,14 @@ litest_add_tcase(const char *suite_name,
                                                    func,
                                                    *dev,
                                                    range);
+                       added = true;
                }
        }
+
+       if (!added) {
+               fprintf(stderr, "Test '%s' does not match any devices. Aborting.\n", funcname);
+               abort();
+       }
 }
 
 void