2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
33 /**********************************************************
35 * OS Test - Silicon Graphics, Inc.
37 * TEST IDENTIFIER : ulimit01
39 * EXECUTED BY : anyone
41 * TEST TITLE : Basic test for ulimit(2)
43 * PARENT DOCUMENT : usctpl01
51 * AUTHOR : William Roske
53 * CO-PILOT : Dave Fenner
55 * DATE STARTED : 03/30/92
57 * INITIAL RELEASE : UNICOS 7.0
61 * 1.) ulimit(2) returns...(See Description)
63 * INPUT SPECIFICATIONS
64 * The standard options for system call tests are accepted.
65 * (See the parse_opts(3) man page).
67 * OUTPUT SPECIFICATIONS
70 * Terminates - with frequency and infinite modes.
73 * Uses SIGUSR1 to pause before test if option set.
74 * (See the parse_opts(3) man page).
80 * The libcuts.a and libsys.a libraries must be included in
81 * the compilation of this test.
83 * SPECIAL PROCEDURAL REQUIREMENTS
86 * INTERCASE DEPENDENCIES
89 * DETAILED DESCRIPTION
90 * This is a Phase I test for the ulimit(2) system call. It is intended
91 * to provide a limited exposure of the system call, for now. It
92 * should/will be extended when full functional tests are written for
96 * Setup signal handling.
97 * Pause for SIGUSR1 if option specified.
100 * Loop if the proper options are given.
101 * Execute system call
102 * Check return code, if system call failed (return=-1)
103 * Log the errno and Issue a FAIL message.
104 * Otherwise, Issue a PASS message.
107 * Print errno log and/or timing stats if options given
110 *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
124 char *TCID="ulimit01"; /* Test program identifier. */
125 int TST_TOTAL=6; /* Total number of test cases. */
126 extern int Tst_count; /* Test Case counter for tst_* routines */
129 long limit; /* saved limit */
134 int nlim_flag; /* special flag for UL_SETFSIZE records */
138 { UL_GETFSIZE, -1, 0, 0 },
139 { UL_SETFSIZE, -1, 0, 1 }, /* negative test */
140 { UL_SETFSIZE, -2, 1, 0 }, /* case case: must be after UL_GETFSIZE */
141 { UL_SETFSIZE, -2, 2, 0 }, /* case case: must be after UL_GETFSIZE */
144 { UL_GMEMLIM, -1, 0, 0 },
147 { UL_GDESLIM, -1, 0, 0 },
150 { UL_GSHMEMLIM, -1, 0, 0 },
156 main(int ac, char **av)
158 int lc; /* loop counter */
159 int i; /* inner loop (test case) counter */
160 char *msg; /* message returned from parse_opts */
163 TST_TOTAL = sizeof(Scenarios)/sizeof(struct limits_t);
165 /***************************************************************
166 * parse standard options
167 ***************************************************************/
168 if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
169 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
173 /***************************************************************
174 * perform global setup for test
175 ***************************************************************/
179 /***************************************************************
180 * check looping state if -c option given
181 ***************************************************************/
182 for (lc=0; TEST_LOOPING(lc); lc++) {
184 /* reset Tst_count in case we are looping. */
187 for ( i=0; i<TST_TOTAL; i++) {
189 cmd=Scenarios[i].cmd;
190 limit=Scenarios[i].newlimit;
195 TEST(ulimit(cmd, limit));
197 /* check return code */
198 if ( TEST_RETURN == -1 ) {
199 if ( Scenarios[i].exp_fail ) {
200 if ( STD_FUNCTIONAL_TEST ) {
201 tst_resm(TPASS, "ulimit(%d, %d) Failed, errno=%d : %s", cmd, limit,
202 TEST_ERRNO, strerror(TEST_ERRNO));
205 tst_resm(TFAIL, "ulimit(%d, %d) Failed, errno=%d : %s", cmd, limit,
206 TEST_ERRNO, strerror(TEST_ERRNO));
209 if ( Scenarios[i].exp_fail ) {
210 tst_resm(TFAIL, "ulimit(%d, %d) returned %d",
211 cmd, limit, TEST_RETURN);
212 } else if ( STD_FUNCTIONAL_TEST ) {
213 tst_resm(TPASS, "ulimit(%d, %d) returned %d",
214 cmd, limit, TEST_RETURN);
218 * Save the UL_GETFSIZE return value in the newlimit field
219 * for UL_SETFSIZE test cases.
221 if ( cmd == UL_GETFSIZE ) {
222 for (tmp=i+1; tmp<TST_TOTAL; tmp++) {
223 if ( Scenarios[tmp].nlim_flag == 1 ) {
224 Scenarios[tmp].newlimit = TEST_RETURN;
226 if ( Scenarios[tmp].nlim_flag == 2 ) {
227 Scenarios[tmp].newlimit = TEST_RETURN-1;
233 } /* End for TEST_LOOPING */
235 /***************************************************************
237 ***************************************************************/
243 /***************************************************************
244 * setup() - performs all ONE TIME setup for this test.
245 ***************************************************************/
250 /* capture signals */
251 tst_sig(NOFORK, DEF_HANDLER, cleanup);
253 /* Pause if that option was specified */
259 /***************************************************************
260 * cleanup() - performs all ONE TIME cleanup for this test at
261 * completion or premature exit.
262 ***************************************************************/
267 * print timing stats if that option was specified.
271 /* exit with return code appropriate for results */
273 } /* End cleanup() */