1 /*
2 * Copyright (c) Wipro Technologies Ltd, 2005. All Rights Reserved.
3 * Author: Prashant P Yendigeri <prashant.yendigeri@wipro.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #include <features.h>
19
20 #include <stdio.h>
21 #include <unistd.h>
22 #include <errno.h>
23 #include <ucontext.h>
24
25 #include "test.h"
26
27 char *TCID = "getcontext01";
28
29 #if !defined(__UCLIBC__)
30
31 static void setup(void);
32 static void cleanup(void);
33
34 int TST_TOTAL = 1;
35
test_getcontext(void)36 static void test_getcontext(void)
37 {
38 ucontext_t ptr;
39
40 TEST(getcontext(&ptr));
41
42 if (TEST_RETURN == -1) {
43 if (errno == ENOSYS)
44 tst_resm(TCONF, "getcontext not implemented in libc");
45 else
46 tst_resm(TFAIL | TTERRNO, "getcontext failed");
47 } else if (TEST_RETURN == 0) {
48 tst_resm(TPASS, "getcontext passed");
49 } else {
50 tst_resm(TFAIL, "Unexpected return value %li", TEST_RETURN);
51 }
52 }
53
main(int ac,char ** av)54 int main(int ac, char **av)
55 {
56 int lc;
57
58 tst_parse_opts(ac, av, NULL, NULL);
59
60 setup();
61
62 for (lc = 0; TEST_LOOPING(lc); lc++) {
63
64 tst_count = 0;
65
66 test_getcontext();
67 }
68
69 cleanup();
70 tst_exit();
71 }
72
setup(void)73 static void setup(void)
74 {
75 tst_sig(NOFORK, DEF_HANDLER, cleanup);
76
77 TEST_PAUSE;
78 }
79
cleanup(void)80 static void cleanup(void)
81 {
82 }
83
84 #else /* systems that dont support obsolete getcontext */
main(void)85 int main(void)
86 {
87 tst_brkm(TCONF, NULL, "system doesn't have getcontext support");
88 }
89 #endif
90