[LTP] [COMMITTED] [PATCH] syscalls/getcontext01: Increase the test coverage

Cyril Hrubis chrubis@suse.cz
Wed Mar 9 16:19:11 CET 2022


Acutally use the structure initialized by the getcontext to jump back in
the process execution flow.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 .../kernel/syscalls/getcontext/getcontext01.c  | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/getcontext/getcontext01.c b/testcases/kernel/syscalls/getcontext/getcontext01.c
index 7176a9035..5896c3800 100644
--- a/testcases/kernel/syscalls/getcontext/getcontext01.c
+++ b/testcases/kernel/syscalls/getcontext/getcontext01.c
@@ -8,7 +8,9 @@
 /*\
  * [Description]
  *
- * Test getting user context functionality.
+ * Basic test for getcontext().
+ *
+ * Calls a getcontext() then jumps back with a setcontext().
  */
 
 #include "config.h"
@@ -18,11 +20,23 @@
 
 #include <ucontext.h>
 
+static volatile int flag;
+
 static void run(void)
 {
 	ucontext_t ptr;
 
-	TST_EXP_PASS(getcontext(&ptr));
+	flag = 0;
+
+	TST_EXP_PASS(getcontext(&ptr), "getcontext() flag=%i", flag);
+
+	if (flag)
+		return;
+
+	flag = 1;
+	setcontext(&ptr);
+
+	tst_res(TFAIL, "setcontext() did return");
 }
 
 static struct tst_test test = {
-- 
2.34.1



More information about the ltp mailing list