blob: 5801401918b43ade6c5abc8312a9aebb9d2274ff [file] [log] [blame]
robbiew544b6042005-05-26 20:38:47 +00001/*
2 * Copyright (c) Wipro Technologies Ltd, 2005. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * You should have received a copy of the GNU General Public License along
13 * with this program; if not, write the Free Software Foundation, Inc., 59
14 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
15 *
16 */
17/**********************************************************
18 *
19 * TEST IDENTIFIER : getcontext01
20 *
21 * EXECUTED BY : root / superuser
22 *
23 * TEST TITLE : Basic tests for getcontext(2)
24 *
25 * TEST CASE TOTAL : 1
26 *
subrata_modak4bb656a2009-02-26 12:02:09 +000027 * AUTHOR : Prashant P Yendigeri
28 * <prashant.yendigeri@wipro.com>
robbiew544b6042005-05-26 20:38:47 +000029 *
30 * DESCRIPTION
31 * This is a Phase I test for the getcontext(2) system call.
32 * It is intended to provide a limited exposure of the system call.
33 *
34 **********************************************************/
35
robbiewf0b51492005-10-03 18:57:05 +000036#include <features.h>
37#if !defined(__UCLIBC__)
38
robbiew544b6042005-05-26 20:38:47 +000039#include <stdio.h>
40#include <unistd.h>
41#include <errno.h>
42#include <ucontext.h>
43
44#include "test.h"
45#include "usctest.h"
46
vapieraa354722006-05-26 06:26:37 +000047void setup();
48void cleanup();
robbiew544b6042005-05-26 20:38:47 +000049
subrata_modak56207ce2009-03-23 13:35:39 +000050char *TCID = "getcontext01"; /* Test program identifier. */
51int TST_TOTAL = 1; /* Total number of test cases. */
52extern int Tst_count; /* Test Case counter for tst_* routines */
robbiew544b6042005-05-26 20:38:47 +000053
subrata_modak56207ce2009-03-23 13:35:39 +000054int exp_enos[] = { 0 }; /* must be a 0 terminated list */
robbiew544b6042005-05-26 20:38:47 +000055
subrata_modak56207ce2009-03-23 13:35:39 +000056int main(int ac, char **av)
robbiew544b6042005-05-26 20:38:47 +000057{
subrata_modak56207ce2009-03-23 13:35:39 +000058 int lc; /* loop counter */
59 char *msg; /* message returned from parse_opts */
robbiew544b6042005-05-26 20:38:47 +000060
robbiew544b6042005-05-26 20:38:47 +000061 ucontext_t ptr;
62 /***************************************************************
63 * parse standard options
64 ***************************************************************/
Garrett Cooper45e285d2010-11-22 12:19:25 -080065 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
Garrett Cooper53740502010-12-16 00:04:01 -080066<<<<<<< HEAD
Garrett Cooper60fa8012010-11-22 13:50:58 -080067 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
Garrett Cooper53740502010-12-16 00:04:01 -080068=======
subrata_modak56207ce2009-03-23 13:35:39 +000069 tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
Garrett Cooper53740502010-12-16 00:04:01 -080070>>>>>>> master
robbiew544b6042005-05-26 20:38:47 +000071
subrata_modak56207ce2009-03-23 13:35:39 +000072 /***************************************************************
robbiew544b6042005-05-26 20:38:47 +000073 * perform global setup for test
74 ***************************************************************/
subrata_modak56207ce2009-03-23 13:35:39 +000075 setup();
robbiew544b6042005-05-26 20:38:47 +000076
subrata_modak56207ce2009-03-23 13:35:39 +000077 /* set the expected errnos... */
78 TEST_EXP_ENOS(exp_enos);
robbiew544b6042005-05-26 20:38:47 +000079
subrata_modak56207ce2009-03-23 13:35:39 +000080 /***************************************************************
robbiew544b6042005-05-26 20:38:47 +000081 * check looping state if -c option given
82 ***************************************************************/
subrata_modak56207ce2009-03-23 13:35:39 +000083 for (lc = 0; TEST_LOOPING(lc); lc++) {
robbiew544b6042005-05-26 20:38:47 +000084
subrata_modak56207ce2009-03-23 13:35:39 +000085 Tst_count = 0;
robbiew544b6042005-05-26 20:38:47 +000086
subrata_modak56207ce2009-03-23 13:35:39 +000087 /*
88 * TEST CASE:
89 * Getcontext
90 */
91 ;
robbiew544b6042005-05-26 20:38:47 +000092
subrata_modak56207ce2009-03-23 13:35:39 +000093 /* Call getcontext(2) */
94 TEST(getcontext(&ptr));
robbiew544b6042005-05-26 20:38:47 +000095
subrata_modak56207ce2009-03-23 13:35:39 +000096 /* check return code */
97 if (TEST_RETURN == -1) {
98 TEST_ERROR_LOG(TEST_ERRNO);
99 tst_resm(TFAIL,
100 "getcontext - Sanity test : Fail errno=%d : %s",
101 TEST_ERRNO, strerror(TEST_ERRNO));
102 } else if (TEST_RETURN >= 0) {
103 TEST_ERROR_LOG(TEST_ERRNO);
104 tst_resm(TPASS, "getcontext - Sanity test : Pass");
105 }
robbiew544b6042005-05-26 20:38:47 +0000106
Garrett Cooper2c282152010-12-16 00:55:50 -0800107 }
robbiew544b6042005-05-26 20:38:47 +0000108
109 /***************************************************************
110 * cleanup and exit
111 ***************************************************************/
subrata_modak56207ce2009-03-23 13:35:39 +0000112 cleanup();
robbiew544b6042005-05-26 20:38:47 +0000113
Garrett Cooper2c282152010-12-16 00:55:50 -0800114}
robbiew544b6042005-05-26 20:38:47 +0000115
116/***************************************************************
117 * setup() - performs all ONE TIME setup for this test.
118 ***************************************************************/
subrata_modak56207ce2009-03-23 13:35:39 +0000119void setup()
robbiew544b6042005-05-26 20:38:47 +0000120{
Garrett Cooper2c282152010-12-16 00:55:50 -0800121
subrata_modak56207ce2009-03-23 13:35:39 +0000122 tst_sig(NOFORK, DEF_HANDLER, cleanup);
robbiew544b6042005-05-26 20:38:47 +0000123
subrata_modak56207ce2009-03-23 13:35:39 +0000124 TEST_PAUSE;
Garrett Cooper2c282152010-12-16 00:55:50 -0800125}
robbiew544b6042005-05-26 20:38:47 +0000126
127/***************************************************************
128 * cleanup() - performs all ONE TIME cleanup for this test at
129 * completion or premature exit.
130 ***************************************************************/
subrata_modak56207ce2009-03-23 13:35:39 +0000131void cleanup()
robbiew544b6042005-05-26 20:38:47 +0000132{
subrata_modak56207ce2009-03-23 13:35:39 +0000133 /*
134 * print timing stats if that option was specified.
135 * print errno log if that option was specified.
136 */
137 TEST_CLEANUP;
robbiew544b6042005-05-26 20:38:47 +0000138
Garrett Cooper2c282152010-12-16 00:55:50 -0800139}
robbiew544b6042005-05-26 20:38:47 +0000140
robbiewf0b51492005-10-03 18:57:05 +0000141#else /* systems that dont support obsolete getcontext */
142int main()
143{
Garrett Cooper2c282152010-12-16 00:55:50 -0800144 tst_exit();
robbiewf0b51492005-10-03 18:57:05 +0000145}
Garrett Cooper2c282152010-12-16 00:55:50 -0800146#endif