selftests: media_tests: return Kselftest Skip code for skipped tests
authorShuah Khan (Samsung OSG) <shuah@kernel.org>
Fri, 4 May 2018 18:06:46 +0000 (12:06 -0600)
committerShuah Khan (Samsung OSG) <shuah@kernel.org>
Wed, 30 May 2018 21:29:06 +0000 (15:29 -0600)
When media_tests test is skipped because of unmet dependencies and/or
unsupported configuration, it exits with error which is treated as a
fail by the Kselftest framework. This leads to false negative result
even when the test could not be run.

Change it to return kselftest skip code when a test gets skipped to
clearly report that the test could not be run.

Change it to use ksft_exit_skip() when the test is skipped.

Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
tools/testing/selftests/media_tests/Makefile
tools/testing/selftests/media_tests/media_device_open.c
tools/testing/selftests/media_tests/media_device_test.c

index c82cec2497dee80b836aec7e2c5b68675c03df56..60826d7d37d49d3f2aaed26068085ffc2a59246a 100644 (file)
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
+#
+CFLAGS += -I../ -I../../../../usr/include/
 TEST_GEN_PROGS := media_device_test media_device_open video_device_test
-all: $(TEST_GEN_PROGS)
 
 include ../lib.mk
index a5ce5434bafd745313e0abf66cc7f0e0f99b7082..93183a37b13329110134f99ee9191d83808f16c1 100644 (file)
@@ -34,6 +34,8 @@
 #include <sys/stat.h>
 #include <linux/media.h>
 
+#include "../kselftest.h"
+
 int main(int argc, char **argv)
 {
        int opt;
@@ -61,10 +63,8 @@ int main(int argc, char **argv)
                }
        }
 
-       if (getuid() != 0) {
-               printf("Please run the test as root - Exiting.\n");
-               exit(-1);
-       }
+       if (getuid() != 0)
+               ksft_exit_skip("Please run the test as root - Exiting.\n");
 
        /* Open Media device and keep it open */
        fd = open(media_device, O_RDWR);
index d8bb1e15d1d9ecb71094da65b2581a964897738d..4b9953359e40bb793666b78f01ab9a568b2e30cf 100644 (file)
@@ -39,6 +39,8 @@
 #include <time.h>
 #include <linux/media.h>
 
+#include "../kselftest.h"
+
 int main(int argc, char **argv)
 {
        int opt;
@@ -66,10 +68,8 @@ int main(int argc, char **argv)
                }
        }
 
-       if (getuid() != 0) {
-               printf("Please run the test as root - Exiting.\n");
-               exit(-1);
-       }
+       if (getuid() != 0)
+               ksft_exit_skip("Please run the test as root - Exiting.\n");
 
        /* Generate random number of interations */
        srand((unsigned int) time(NULL));