diff mbox series

[COMMITTED] syscalls/getcontext01: Increase the test coverage

Message ID 20220309151911.27164-1-chrubis@suse.cz
State Accepted
Headers show
Series [COMMITTED] syscalls/getcontext01: Increase the test coverage | expand

Commit Message

Cyril Hrubis March 9, 2022, 3:19 p.m. UTC
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 mbox series

Patch

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 = {