testsuite: add missing error handling
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 3 Jan 2018 21:37:59 +0000 (13:37 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 3 Jan 2018 22:22:11 +0000 (14:22 -0800)
If we passed an invalid argument to a test it would segfault rather than
returning an error code.

testsuite/testsuite.h

index bb0eb50..2b31483 100644 (file)
@@ -151,6 +151,8 @@ int test_run(const struct test *t);
                arg = test_init(__start_kmod_tests, __stop_kmod_tests, argc, argv);             \
                if (arg == 0)                                                                   \
                        return 0;                                                               \
+               if (arg < 0)                                                                    \
+                       return EXIT_FAILURE;                                                    \
                                                                                                \
                if (arg < argc) {                                                               \
                        t = test_find(__start_kmod_tests, __stop_kmod_tests, argv[arg]);        \