Skip to contentSkip to conversation

tst_test: Add test multiplex function

RFC PATCH New Cyril Hrubis 2 participants 3 messages Mar 6, 2019 Library code

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/2 tst_test: Add test multiplex function

From: Cyril Hrubis <[email protected]>

The test multiplex function is intended for running the test function in a loop for a different settings. The indended purpose is to run tests for both libc wrapper and raw syscall as well as for different syscall variants.

The commit itself adds a test_multiplex() function into the tst_test structure, if set this function is called in a loop before each test iteration and is responsible for changing the test variant into next one. The iterations continue until the function returns zero.

CC Mark Salyzyn <[email protected]>
CC Steve Muckle <[email protected]>
CC Jan Stancek <[email protected]>
---
 include/tst_test.h | 14 ++++++++++++++
 lib/tst_test.c     | 11 +++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)
include/tst_test.h +14 -0
index da41f776d..b747b24d5 100644
@@ -146,6 +146,20 @@ struct tst_test {
 	 */
 	int all_filesystems:1;
 
+	/*
+	 * If set this function is used to mutiplex between different test
+	 * variants.
+	 *
+	 * Multiplexers are the way how to run the same test for different
+	 * settings. The intended use is to test different syscall
+	 * wrappers/variants but the API is generic and does not limit the
+	 * usage in any way.
+	 *
+	 * Each time the function is called it switches to next test variant,
+	 * returns zero if all variants has been iterated over.
+	 */
+	int (*test_multiplex)(void);
+
 	/* Minimal device size in megabytes */
 	unsigned int dev_min_size;
 
lib/tst_test.c +9 -2
index 7dd890b8d..6b033c879 100644
@@ -1009,8 +1009,15 @@ static void testrun(void)
 		if (!cont)
 			break;
 
-		run_tests();
-		heartbeat();
+		if (tst_test->test_multiplex) {
+			while (tst_test->test_multiplex()) {
+				run_tests();
+				heartbeat();
+			}
+		} else {
+			run_tests();
+			heartbeat();
+		}
 	}
 
 	do_test_cleanup();
Signature · 1 line
2.19.2
#1 lore raw

RFC PATCH 2/2 syscalls/select04: Test four syscall variants

From: Cyril Hrubis <[email protected]>

This commit makes use of the newly added test_multiplex() function to switch between different syscall variants/wrappers at runtime.

CC Mark Salyzyn <[email protected]>
CC Steve Muckle <[email protected]>
CC Jan Stancek <[email protected]>
---
 testcases/kernel/syscalls/select/select04.c   |  5 +-
 testcases/kernel/syscalls/select/select_mpx.h | 79 +++++++++++++++++++
 2 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 testcases/kernel/syscalls/select/select_mpx.h
testcases/kernel/syscalls/select/select04.c +4 -1
index 86bdffcdf..300992233 100644
@@ -27,6 +27,8 @@
 
 #include "tst_timer_test.h"
 
+#include "select_mpx.h"
+
 static int fds[2];
 
 static int sample_fn(int clk_id, long long usec)
@@ -39,7 +41,7 @@ static int sample_fn(int clk_id, long long usec)
 	FD_SET(fds[0], &sfds);
 
 	tst_timer_start(clk_id);
-	TEST(select(1, &sfds, NULL, NULL, &timeout));
+	TEST(do_select(1, &sfds, NULL, NULL, &timeout));
 	tst_timer_stop();
 	tst_timer_sample();
 
@@ -69,5 +71,6 @@ static struct tst_test test = {
 	.scall = "select()",
 	.sample = sample_fn,
 	.setup = setup,
+	.test_multiplex = select_mpx,
 	.cleanup = cleanup,
 };
testcases/kernel/syscalls/select/select_mpx.h new file +79 -0

79 lines not on this page · raw message

Signature · 1 line
2.19.2