[PATCH libevdev 6/6] test: move the kernel test to the same infrastructure

Peter Hutterer peter.hutterer at who-t.net
Fri Jun 15 05:22:53 UTC 2018


We previously had this separate because it tested separate things. Now the
setup is generic enough that we should just re-use it.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/Makefile.am   |  2 ++
 test/test-kernel.c | 24 ++++--------------------
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/test/Makefile.am b/test/Makefile.am
index 78950e9..b3c0c62 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -83,8 +83,10 @@ test_libevdev_LDADD = $(CHECK_LIBS) $(top_builddir)/libevdev/libevdev.la
 test_libevdev_LDFLAGS = -no-install
 
 test_kernel_SOURCES = \
+		      test-main.c \
 		      test-kernel.c \
 		      $(common_sources)
+
 test_kernel_CFLAGS = -I$(top_srcdir)
 test_kernel_LDADD = $(CHECK_LIBS) $(top_builddir)/libevdev/libevdev.la
 
diff --git a/test/test-kernel.c b/test/test-kernel.c
index 411306a..1314d89 100644
--- a/test/test-kernel.c
+++ b/test/test-kernel.c
@@ -160,31 +160,15 @@ out:
 }
 END_TEST
 
-int main(int argc, char **argv)
+TEST_SUITE_ROOT_PRIVILEGES(kernel)
 {
-	SRunner *sr;
-	Suite *s;
-	TCase *tc;
-	int failed;
+	Suite *s = suite_create("kernel");
 
-	if (getuid() != 0) {
-		fprintf(stderr, "This test needs to run as root\n");
-		return 77;
-	}
-
-	s = suite_create("kernel tests");
-
-	tc = tcase_create("EVIOCREVOKE");
+	TCase *tc = tcase_create("EVIOCREVOKE");
 	tcase_add_test(tc, test_revoke);
 	tcase_add_test(tc, test_revoke_invalid);
 	tcase_add_test(tc, test_revoke_fail_after);
 	suite_add_tcase(s, tc);
 
-	sr = srunner_create(s);
-	srunner_run_all(sr, CK_NORMAL);
-
-	failed = srunner_ntests_failed(sr);
-	srunner_free(sr);
-
-	return failed;
+	return s;
 }
-- 
2.14.4



More information about the Input-tools mailing list