blob: fc175855572b867fb61529b96719b464d04b6c63 [file] [log] [blame]
robbiew35c803d2002-12-31 22:53:23 +00001/*
2 *
3 * Copyright (c) International Business Machines Corp., 2002
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20/* 01/02/2003 Port to LTP avenkat@us.ibm.com*/
21/* 06/30/2001 Port to Linux nsharoff@us.ibm.com */
22
23/*
24 * NAME
25 * syscall1.c -- test syscall
26 *
27 * CALLS
28 * syscall
29 *
30 * ALGORITHM
31 * Use syscall to simulate some section 2 calls and make sure
32 * things work as expected. Pretty simple, but if it works
33 * for a few it should work for all.
34 *
35 * RESTRICTIONS
36 * The syscall numbers are system dependent!! They represent
37 * entries in a table and can be changed from kernel to kernel.
38 * They ARE differnet between vax 4.2BSD and our ported system.
39 */
40
41#include <stdio.h> /* needed by testhead.h */
42#include <syscall.h>
43#include <errno.h>
44
45/***** LTP Port *****/
46#include "test.h"
47#include "usctest.h"
48
49#define FAILED 0
50#define PASSED 1
51
52char *TCID = "syscall01";
53int local_flag = PASSED;
54int block_number;
55int errno;
56FILE *temp;
57int TST_TOTAL = 1;
58extern int Tst_count;
59/***** ** ** *****/
60
61//char progname[]= "syscall1()";
62
63#define ITER 500
64
65
66int t_flag;
67int errno;
68
69/***** LTP Port *****/
70void setup();
71int blenter();
72int blexit();
73int anyfail();
74void cleanup();
75void do_setpg();
76void fail_exit();
77/***** ** ** *****/
78
79/*--------------------------------------------------------------*/
80int main (int argc, char *argv[])
81{
82 register int i;
83 int v1, v2;
84
85 setup(); /* temp file is now open */
86/*--------------------------------------------------------------*/
87 blenter();
88
89 for (i=0; i < ITER; i++) {
90 v1 = getpid();
91 v2 = syscall(SYS_getpid);
92 if (v1 != v2) {
93 fprintf(temp, "\tgetpid syscall failed.\n");
94 fprintf(temp, "\t iteration %d\n", i);
95 local_flag = FAILED;
96 break;
97 }
98 }
99
100 blexit();
101/*--------------------------------------------------------------*/
102 blenter();
103
104 for (i=0; i < ITER; i++) {
105 v1 = getuid();
106 v2 = syscall(SYS_getuid);
107 if (v1 != v2) {
108 fprintf(temp, "\tgetuid syscall failed.\n");
109 fprintf(temp, "\t iteration %d\n", i);
110 local_flag = FAILED;
111 break;
112 }
113 }
114
115 blexit();
116/*--------------------------------------------------------------*/
117 blenter();
118
119 for (i=0; i < ITER; i++) {
120 v1 = getgid();
121 v2 = syscall(SYS_getgid);
122 if (v1 != v2) {
123 fprintf(temp, "\tgetgid syscall failed.\n");
124 fprintf(temp, "\t iteration %d\n", i);
125 local_flag = FAILED;
126 break;
127 }
128 }
129
130 blexit();
131/*--------------------------------------------------------------*/
132
133 /***************************************************************
134 * cleanup and exit
135 ***************************************************************/
136 cleanup();
137
138 anyfail(); /* THIS CALL DOES NOT RETURN - EXITS!! */
139 return(0);
140}
141/*--------------------------------------------------------------*/
142
143/***** LTP Port *****/
144/* functions */
145
146
147void cleanup()
148{
149 /*
150 * print timing stats if that option was specified.
151 * print errno log if that option was specified.
152 */
153 TEST_CLEANUP;
154
155 /* exit with return code appropriate for results */
156 tst_exit();
157} /* End cleanup() */
158
159
160void setup()
161{
162
163 temp = stderr;
164
165}
166
167
168int blenter()
169{
170 local_flag = PASSED;
171 return(0);
172}
173
174
175int blexit()
176{
177 (local_flag == PASSED) ?
plars78513a32003-07-08 18:40:00 +0000178 tst_resm(TPASS, "Test passed")
179 : tst_resm(TFAIL, "Test failed");
robbiew35c803d2002-12-31 22:53:23 +0000180 return(0);
181}
182
183int anyfail()
184{
185 tst_exit();
186 return(0);
187}
188
189void fail_exit()
190{
191 local_flag = FAILED;
192 blexit();
193 anyfail();
194}
195
196
197/***** ** ** *****/