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 /* $Id: usctest.h,v 1.1 2003/07/07 06:36:46 nathans Exp $ */
35 /**********************************************************
37 * IRIX/Linux Feature Test and Evaluation - Silicon Graphics, Inc.
39 * FUNCTION NAME : usctest.h
41 * FUNCTION TITLE : System Call Test Macros
44 * See DESCRIPTION below.
46 * AUTHOR : William Roske
48 * INITIAL RELEASE : UNICOS 7.0
51 * TEST(SCALL) - calls a system call
52 * TEST_VOID(SCALL) - same as TEST() but for syscalls with no return value.
53 * TEST_CLEANUP - print the log of errno return counts if STD_ERRNO_LOG
55 * TEST_PAUSEF(HAND) - Pause for SIGUSR1 if the pause flag is set.
56 * Use "hand" as the interrupt handling function
57 * TEST_PAUSE - Pause for SIGUSR1 if the pause flag is set.
58 * Use internal function to do nothing on signal and go on.
59 * TEST_LOOPING(COUNTER) - Conditional to check if test should
60 * loop. Evaluates to TRUE (1) or FALSE (0).
61 * TEST_ERROR_LOG(eno) - log that this errno was received,
62 * if STD_ERRNO_LOG is set.
63 * TEST_EXP_ENOS(array) - set the bits in TEST_VALID_ENO array at
64 * positions specified in integer "array"
67 * TEST(SCALL) - Global Variables set:
68 * int TEST_RETURN=return code from SCALL
69 * int TEST_ERRNO=value of errno at return from SCALL
70 * TEST_VOID(SCALL) - Global Variables set:
71 * int TEST_ERRNO=value of errno at return from SCALL
72 * TEST_CLEANUP - None.
73 * TEST_PAUSEF(HAND) - None.
75 * TEST_LOOPING(COUNTER) - True if COUNTER < STD_LOOP_COUNT or
76 * STD_INFINITE is set.
77 * TEST_ERROR_LOG(eno) - None
78 * TEST_EXP_ENOS(array) - None
81 * If you use the TEST_PAUSE or TEST_LOOPING macros, you must
82 * link in parse_opts.o, which contains the code for those functions.
84 *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
87 #define __USCTEST_H__ 1
93 #include <sys/param.h>
96 * Ensure that PATH_MAX is defined
100 #define PATH_MAX MAXPATHLEN
102 #define PATH_MAX 1024
112 /***********************************************************************
113 * Define option_t structure type.
114 * Entries in this struct are used by the parse_opts routine
115 * to indicate valid options and return option arguments
116 ***********************************************************************/
118 char *option; /* Valid option string (one option only) like "a:" */
119 int *flag; /* pointer to location to set true if option given */
120 char **arg; /* pointer to location to place argument, if needed */
123 /***********************************************************************
124 * The following globals are defined in parse_opts.c but must be
125 * externed here because they are used in the macros defined below.
126 ***********************************************************************/
127 extern int STD_FUNCTIONAL_TEST, /* turned off by -f to not do functional test */
128 STD_TIMING_ON, /* turned on by -t to print timing stats */
129 STD_PAUSE, /* turned on by -p to pause before loop */
130 STD_INFINITE, /* turned on by -i0 to loop forever */
131 STD_LOOP_COUNT, /* changed by -in to set loop count to n */
132 STD_ERRNO_LOG, /* turned on by -e to log errnos returned */
133 STD_ERRNO_LIST[], /* counts of errnos returned. indexed by errno */
137 extern float STD_LOOP_DURATION, /* wall clock time to iterate */
138 STD_LOOP_DELAY; /* delay time after each iteration */
140 #define USC_MAX_ERRNO 2000
142 /**********************************************************************
143 * Prototype for parse_opts routine
144 **********************************************************************/
145 extern char *parse_opts(int ac, char **av, option_t *user_optarr, void (*uhf)());
155 /***********************************************************************
159 **********************************************************************/
162 extern int TEST_RETURN;
163 extern int TEST_ERRNO;
166 /***********************************************************************
167 * Global array of bit masks to indicate errnos that are expected.
168 * Bits set by TEST_EXP_ENOS() macro and used by TEST_CLEANUP() macro.
169 ***********************************************************************/
170 struct usc_errno_t TEST_VALID_ENO[USC_MAX_ERRNO];
172 /***********************************************************************
173 * Globals for returning the return code and errno from the system call
175 ***********************************************************************/
179 /***********************************************************************
180 * temporary variables for determining max and min times in TEST macro
181 ***********************************************************************/
182 long btime, etime, tmptime;
184 #endif /* _USC_LIB_ */
186 /***********************************************************************
187 * structure for timing accumulator and counters
188 ***********************************************************************/
196 /***********************************************************************
197 * The following globals are externed here so that they are accessable
198 * in the macros that follow.
199 ***********************************************************************/
200 extern struct tblock tblock;
201 extern void STD_go();
202 extern int (*_TMP_FUNC)(void);
203 extern void STD_opts_help();
206 /***********************************************************************
207 * TEST: calls a system call
210 * SCALL = system call and parameters to execute
212 ***********************************************************************/
213 #define TEST(SCALL) errno=0; TEST_RETURN = (unsigned) SCALL; TEST_ERRNO=errno;
215 /***********************************************************************
216 * TEST_VOID: calls a system call
219 * SCALL = system call and parameters to execute
221 * Note: This is IDENTICAL to the TEST() macro except that it is intended
222 * for use with syscalls returning no values (void syscall()). The
223 * Typecasting nothing (void) into an unsigned integer causes compilation
226 ***********************************************************************/
227 #define TEST_VOID(SCALL) errno=0; SCALL; TEST_ERRNO=errno;
229 /***********************************************************************
230 * TEST_CLEANUP: print system call timing stats and errno log entries
231 * to stdout if STD_TIMING_ON and STD_ERRNO_LOG are set, respectively.
232 * Do NOT print ANY information if no system calls logged.
237 ***********************************************************************/
238 #define TEST_CLEANUP \
239 if ( STD_ERRNO_LOG ) { \
240 for (tmptime=0; tmptime<USC_MAX_ERRNO; tmptime++) { \
241 if ( STD_ERRNO_LIST[tmptime] ) { \
242 if ( TEST_VALID_ENO[tmptime].flag ) \
243 tst_resm(TINFO, "ERRNO %d:\tReceived %d Times", \
244 tmptime, STD_ERRNO_LIST[tmptime]); \
247 "ERRNO %d:\tReceived %d Times ** UNEXPECTED **", \
248 tmptime, STD_ERRNO_LIST[tmptime]); \
253 /***********************************************************************
254 * TEST_PAUSEF: Pause for SIGUSR1 if the pause flag is set.
255 * Set the user specified function as the interrupt
256 * handler instead of "STD_go"
261 ***********************************************************************/
262 #define TEST_PAUSEF(HANDLER) \
264 _TMP_FUNC = (int (*)())signal(SIGUSR1, HANDLER); \
266 signal(SIGUSR1, (void (*)())_TMP_FUNC); \
269 /***********************************************************************
270 * TEST_PAUSE: Pause for SIGUSR1 if the pause flag is set.
271 * Just continue when signal comes in.
276 ***********************************************************************/
277 #define TEST_PAUSE usc_global_setup_hook();
278 int usc_global_setup_hook();
280 /***********************************************************************
281 * TEST_LOOPING now call the usc_test_looping function.
282 * The function will return 1 if the test should continue
285 ***********************************************************************/
286 #define TEST_LOOPING usc_test_looping
287 int usc_test_looping(int counter);
289 /***********************************************************************
290 * TEST_ERROR_LOG(eno): log this errno if STD_ERRNO_LOG flag set
293 * int eno: the errno location in STD_ERRNO_LIST to log.
295 ***********************************************************************/
296 #define TEST_ERROR_LOG(eno) \
297 if ( STD_ERRNO_LOG ) \
298 if ( eno < USC_MAX_ERRNO ) \
299 STD_ERRNO_LIST[eno]++; \
302 /***********************************************************************
303 * TEST_EXP_ENOS(array): set the bits associated with the nput errnos
304 * in the TEST_VALID_ENO array.
307 * int array[]: a zero terminated array of errnos expected.
309 ***********************************************************************/
310 #define TEST_EXP_ENOS(array) \
312 while (array[tmptime] != 0) { \
313 if (array[tmptime] < USC_MAX_ERRNO) \
314 TEST_VALID_ENO[array[tmptime]].flag=1; \
319 #endif /* end of __USCTEST_H__ */