selftests: media_tests: return Kselftest Skip code for skipped tests

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: default avatarShuah Khan (Samsung OSG) <shuah@kernel.org>
parent f9fedb27
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
#
CFLAGS += -I../ -I../../../../usr/include/
TEST_GEN_PROGS := media_device_test media_device_open video_device_test TEST_GEN_PROGS := media_device_test media_device_open video_device_test
all: $(TEST_GEN_PROGS)
include ../lib.mk include ../lib.mk
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <linux/media.h> #include <linux/media.h>
#include "../kselftest.h"
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int opt; int opt;
...@@ -61,10 +63,8 @@ int main(int argc, char **argv) ...@@ -61,10 +63,8 @@ int main(int argc, char **argv)
} }
} }
if (getuid() != 0) { if (getuid() != 0)
printf("Please run the test as root - Exiting.\n"); ksft_exit_skip("Please run the test as root - Exiting.\n");
exit(-1);
}
/* Open Media device and keep it open */ /* Open Media device and keep it open */
fd = open(media_device, O_RDWR); fd = open(media_device, O_RDWR);
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#include <time.h> #include <time.h>
#include <linux/media.h> #include <linux/media.h>
#include "../kselftest.h"
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int opt; int opt;
...@@ -66,10 +68,8 @@ int main(int argc, char **argv) ...@@ -66,10 +68,8 @@ int main(int argc, char **argv)
} }
} }
if (getuid() != 0) { if (getuid() != 0)
printf("Please run the test as root - Exiting.\n"); ksft_exit_skip("Please run the test as root - Exiting.\n");
exit(-1);
}
/* Generate random number of interations */ /* Generate random number of interations */
srand((unsigned int) time(NULL)); srand((unsigned int) time(NULL));
......
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