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 * IRIX/Linux Feature Test and Evaluation - Silicon Graphics, Inc.
37 * FUNCTION NAME : usctest.h
39 * FUNCTION TITLE : System Call Test Macros
42 * See DESCRIPTION below.
44 * AUTHOR : William Roske
46 * INITIAL RELEASE : UNICOS 7.0
49 * TEST(SCALL) - calls a system call
50 * TEST_VOID(SCALL) - same as TEST() but for syscalls with no return value.
51 * TEST_CLEANUP - print the log of errno return counts if STD_ERRNO_LOG
53 * TEST_PAUSEF(HAND) - Pause for SIGUSR1 if the pause flag is set.
54 * Use "hand" as the interrupt handling function
55 * TEST_PAUSE - Pause for SIGUSR1 if the pause flag is set.
56 * Use internal function to do nothing on signal and go on.
57 * TEST_LOOPING(COUNTER) - Conditional to check if test should
58 * loop. Evaluates to TRUE (1) or FALSE (0).
59 * TEST_ERROR_LOG(eno) - log that this errno was received,
60 * if STD_ERRNO_LOG is set.
61 * TEST_EXP_ENOS(array) - set the bits in TEST_VALID_ENO array at
62 * positions specified in integer "array"
65 * TEST(SCALL) - Global Variables set:
66 * int TEST_RETURN=return code from SCALL
67 * int TEST_ERRNO=value of errno at return from SCALL
68 * TEST_VOID(SCALL) - Global Variables set:
69 * int TEST_ERRNO=value of errno at return from SCALL
70 * TEST_CLEANUP - None.
71 * TEST_PAUSEF(HAND) - None.
73 * TEST_LOOPING(COUNTER) - True if COUNTER < STD_LOOP_COUNT or
74 * STD_INFINITE is set.
75 * TEST_ERROR_LOG(eno) - None
76 * TEST_EXP_ENOS(array) - None
79 * If you use the TEST_PAUSE or TEST_LOOPING macros, you must
80 * link in parse_opts.o, which contains the code for those functions.
82 *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
85 #define __USCTEST_H__ 1
91 #include <sys/param.h>
94 * Ensure that PATH_MAX is defined
98 #define PATH_MAX MAXPATHLEN
100 #define PATH_MAX 1024
110 /***********************************************************************
111 * Define option_t structure type.
112 * Entries in this struct are used by the parse_opts routine
113 * to indicate valid options and return option arguments
114 ***********************************************************************/
116 char *option
; /* Valid option string (one option only) like "a:" */
117 int *flag
; /* pointer to location to set true if option given */
118 char **arg
; /* pointer to location to place argument, if needed */
121 /***********************************************************************
122 * The following globals are defined in parse_opts.c but must be
123 * externed here because they are used in the macros defined below.
124 ***********************************************************************/
125 extern int STD_FUNCTIONAL_TEST
, /* turned off by -f to not do functional test */
126 STD_TIMING_ON
, /* turned on by -t to print timing stats */
127 STD_PAUSE
, /* turned on by -p to pause before loop */
128 STD_INFINITE
, /* turned on by -i0 to loop forever */
129 STD_LOOP_COUNT
, /* changed by -in to set loop count to n */
130 STD_ERRNO_LOG
, /* turned on by -e to log errnos returned */
131 STD_ERRNO_LIST
[], /* counts of errnos returned. indexed by errno */
135 extern float STD_LOOP_DURATION
, /* wall clock time to iterate */
136 STD_LOOP_DELAY
; /* delay time after each iteration */
138 #define USC_MAX_ERRNO 2000
140 /**********************************************************************
141 * Prototype for parse_opts routine
142 **********************************************************************/
143 extern char *parse_opts(int ac
, char **av
, option_t
*user_optarr
, void (*uhf
)(void));
153 /***********************************************************************
157 **********************************************************************/
160 extern long TEST_RETURN
;
161 extern long TEST_ERRNO
;
162 extern struct usc_errno_t TEST_VALID_ENO
[USC_MAX_ERRNO
];
163 extern long btime
, etime
, tmptime
;
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(int);
202 extern int (*_TMP_FUNC
)(void);
203 extern void STD_opts_help(void);
206 /***********************************************************************
207 * TEST: calls a system call
210 * SCALL = system call and parameters to execute
212 ***********************************************************************/
213 #define TEST(SCALL) \
216 TEST_RETURN = SCALL; \
217 TEST_ERRNO = errno; \
220 /***********************************************************************
221 * TEST_VOID: calls a system call
224 * SCALL = system call and parameters to execute
226 * Note: This is IDENTICAL to the TEST() macro except that it is intended
227 * for use with syscalls returning no values (void syscall()). The
228 * Typecasting nothing (void) into an unsigned integer causes compilation
231 ***********************************************************************/
232 #define TEST_VOID(SCALL) errno=0; SCALL; TEST_ERRNO=errno;
234 /***********************************************************************
235 * TEST_CLEANUP: print system call timing stats and errno log entries
236 * to stdout if STD_TIMING_ON and STD_ERRNO_LOG are set, respectively.
237 * Do NOT print ANY information if no system calls logged.
242 ***********************************************************************/
243 #define TEST_CLEANUP \
244 if ( STD_ERRNO_LOG ) { \
245 for (tmptime=0; tmptime<USC_MAX_ERRNO; tmptime++) { \
246 if ( STD_ERRNO_LIST[tmptime] ) { \
247 if ( TEST_VALID_ENO[tmptime].flag ) \
248 tst_resm(TINFO, "ERRNO %d:\tReceived %d Times", \
249 tmptime, STD_ERRNO_LIST[tmptime]); \
252 "ERRNO %d:\tReceived %d Times ** UNEXPECTED **", \
253 tmptime, STD_ERRNO_LIST[tmptime]); \
258 /***********************************************************************
259 * TEST_PAUSEF: Pause for SIGUSR1 if the pause flag is set.
260 * Set the user specified function as the interrupt
261 * handler instead of "STD_go"
266 ***********************************************************************/
267 #define TEST_PAUSEF(HANDLER) \
269 _TMP_FUNC = (int (*)(void))signal(SIGUSR1, HANDLER); \
271 signal(SIGUSR1, (void (*)(void))_TMP_FUNC); \
274 /***********************************************************************
275 * TEST_PAUSE: Pause for SIGUSR1 if the pause flag is set.
276 * Just continue when signal comes in.
281 ***********************************************************************/
282 #define TEST_PAUSE usc_global_setup_hook();
283 int usc_global_setup_hook(void);
285 /***********************************************************************
286 * TEST_LOOPING now call the usc_test_looping function.
287 * The function will return 1 if the test should continue
290 ***********************************************************************/
291 #define TEST_LOOPING usc_test_looping
292 int usc_test_looping(int counter
);
294 /***********************************************************************
295 * TEST_ERROR_LOG(eno): log this errno if STD_ERRNO_LOG flag set
298 * int eno: the errno location in STD_ERRNO_LIST to log.
300 ***********************************************************************/
301 #define TEST_ERROR_LOG(eno) \
302 if ( STD_ERRNO_LOG ) \
303 if ( eno < USC_MAX_ERRNO ) \
304 STD_ERRNO_LIST[eno]++; \
307 /***********************************************************************
308 * TEST_EXP_ENOS(array): set the bits associated with the nput errnos
309 * in the TEST_VALID_ENO array.
312 * int array[]: a zero terminated array of errnos expected.
314 ***********************************************************************/
315 #define TEST_EXP_ENOS(array) \
317 while (array[tmptime] != 0) { \
318 if (array[tmptime] < USC_MAX_ERRNO) \
319 TEST_VALID_ENO[array[tmptime]].flag=1; \
324 #endif /* end of __USCTEST_H__ */