1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) Wipro Technologies Ltd, 2005. All Rights Reserved. 4 * Author: Prashant P Yendigeri <[email protected]> 5 * Copyright (C) 2022 SUSE LLC Andrea Cervesato <[email protected]> 6 */ 7 8 /*\ 9 * [Description] 10 * 11 * Basic test for getcontext(). 12 * 13 * Calls a getcontext() then jumps back with a setcontext(). 14 */ 15 16 #include "config.h" 17 #include "tst_test.h" 18 19 #ifdef HAVE_GETCONTEXT 20 21 #include <ucontext.h> 22 23 static volatile int flag; 24 run(void)25static void run(void) 26 { 27 ucontext_t ptr; 28 29 flag = 0; 30 31 TST_EXP_PASS(getcontext(&ptr), "getcontext() flag=%i", flag); 32 33 if (flag) 34 return; 35 36 flag = 1; 37 setcontext(&ptr); 38 39 tst_res(TFAIL, "setcontext() did return"); 40 } 41 42 static struct tst_test test = { 43 .test_all = run, 44 }; 45 46 #else 47 TST_TEST_TCONF("system doesn't have getcontext support"); 48 #endif 49