[LTP] [PATCH 06/13] mem/ksm05: Add proper runtime support

Cyril Hrubis chrubis@suse.cz
Wed Jun 24 11:18:53 CEST 2026


The test was executed with -I 10 in all instances. It's cleaner to
define the min_runtime in the test and loop the test function until it's
exhausted.

One of the bonuses we get from this conversion is that the TPASS message
is printed once at the end of the test and we do not flood the logs.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 runtest/cve                      |  2 +-
 runtest/mm                       |  2 +-
 testcases/kernel/mem/ksm/ksm05.c | 27 ++++++++++++++++-----------
 3 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/runtest/cve b/runtest/cve
index cc664bb93..789e16aac 100644
--- a/runtest/cve
+++ b/runtest/cve
@@ -1,6 +1,6 @@
 # Tests which check for vulnerabilities by CVE number
 cve-2011-0999 thp01 -I 120
-cve-2011-2183 ksm05 -I 10
+cve-2011-2183 ksm05
 cve-2011-2496 vma03
 cve-2012-0957 uname04
 cve-2014-0196 cve-2014-0196
diff --git a/runtest/mm b/runtest/mm
index 7d75b65c8..98ec0a4c4 100644
--- a/runtest/mm
+++ b/runtest/mm
@@ -60,7 +60,7 @@ ksm03 ksm03
 ksm03_1 ksm03 -u 128
 ksm04 ksm04
 ksm04_1 ksm04 -u 128
-ksm05 ksm05 -I 10
+ksm05 ksm05
 ksm06 ksm06
 ksm06_1 ksm06 -n 10
 ksm06_2 ksm06 -n 8000
diff --git a/testcases/kernel/mem/ksm/ksm05.c b/testcases/kernel/mem/ksm/ksm05.c
index 35197914e..0faba54b6 100644
--- a/testcases/kernel/mem/ksm/ksm05.c
+++ b/testcases/kernel/mem/ksm/ksm05.c
@@ -57,15 +57,6 @@ static void test_ksm(void)
 	long ps;
 	pid_t pid;
 	void *ptr;
-	struct sigaction sa;
-
-	memset (&sa, '\0', sizeof(sa));
-	sa.sa_handler = sighandler;
-	sa.sa_flags = 0;
-	TEST(sigaction(SIGSEGV, &sa, NULL));
-	if (TST_RET == -1)
-		tst_brk(TBROK | TRERRNO,
-				"SIGSEGV signal setup failed");
 
 	ps = sysconf(_SC_PAGESIZE);
 
@@ -80,7 +71,20 @@ static void test_ksm(void)
 	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
 		tst_brk(TBROK, "invalid signal received: %d", status);
 
-	tst_res(TPASS, "still alive.");
+}
+
+static void run(void)
+{
+	struct sigaction sa = {
+		.sa_handler = sighandler
+	};
+
+	SAFE_SIGACTION(SIGSEGV, &sa, NULL);
+
+	while (tst_remaining_runtime())
+		test_ksm();
+
+	tst_res(TPASS, "Still alive");
 }
 
 static void sighandler(int sig)
@@ -91,7 +95,8 @@ static void sighandler(int sig)
 static struct tst_test test = {
 	.needs_root = 1,
 	.forks_child = 1,
-	.test_all = test_ksm,
+	.test_all = run,
+	.min_runtime = 10,
 	.save_restore = (const struct tst_path_val[]) {
 		{PATH_MM_KSM_RUN, "1", TST_SR_TBROK},
 		{PATH_MM_KSM_SMART_SCAN, "0",
-- 
2.53.0



More information about the ltp mailing list