[cc2e55]: include / usctest.h  Maximize  Restore  History

Download this file

374 lines (328 with data), 13.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
/*
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
*
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
* Mountain View, CA 94043, or:
*
* http://www.sgi.com
*
* For further information regarding this notice, see:
*
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*/
/* $Id: usctest.h,v 1.1 2000/07/27 17:13:18 alaffin Exp $ */
/**********************************************************
*
* IRIX/Linux Feature Test and Evaluation - Silicon Graphics, Inc.
*
* FUNCTION NAME : usctest.h
*
* FUNCTION TITLE : System Call Test Macros
*
* SYNOPSIS:
* See DESCRIPTION below.
*
* AUTHOR : William Roske
*
* INITIAL RELEASE : UNICOS 7.0
*
* DESCRIPTION
* TEST(SCALL) - calls a system call
* TEST_VOID(SCALL) - same as TEST() but for syscalls with no return value.
* TEST_CLEANUP - print the log of errno return counts if STD_ERRNO_LOG
* is set.
* TEST_PAUSEF(HAND) - Pause for SIGUSR1 if the pause flag is set.
* Use "hand" as the interrupt handling function
* TEST_PAUSE - Pause for SIGUSR1 if the pause flag is set.
* Use internal function to do nothing on signal and go on.
* TEST_LOOPING(COUNTER) - Conditional to check if test should
* loop. Evaluates to TRUE (1) or FALSE (0).
* TEST_ERROR_LOG(eno) - log that this errno was received,
* if STD_ERRNO_LOG is set.
* TEST_EXP_ENOS(array) - set the bits in TEST_VALID_ENO array at
* positions specified in integer "array"
*
* RETURN VALUE
* TEST(SCALL) - Global Variables set:
* int TEST_RETURN=return code from SCALL
* int TEST_ERRNO=value of errno at return from SCALL
* TEST_VOID(SCALL) - Global Variables set:
* int TEST_ERRNO=value of errno at return from SCALL
* TEST_CLEANUP - None.
* TEST_PAUSEF(HAND) - None.
* TEST_PAUSE - None.
* TEST_LOOPING(COUNTER) - True if COUNTER < STD_LOOP_COUNT or
* STD_INFINITE is set.
* TEST_ERROR_LOG(eno) - None
* TEST_EXP_ENOS(array) - None
*
* KNOWN BUGS
* If you use the TEST_PAUSE or TEST_LOOPING macros, you must
* link in parse_opts.o, which contains the code for those functions.
*
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
#ifndef __USCTEST_H__
#define __USCTEST_H__ 1
#ifndef _SC_CLK_TCK
#include <unistd.h>
#endif
#include <sys/param.h>
/*
* Ensure that PATH_MAX is defined
*/
#ifndef PATH_MAX
#ifdef MAXPATHLEN
#define PATH_MAX MAXPATHLEN
#else
#define PATH_MAX 1024
#endif
#endif
#ifndef CRAY
#ifndef BSIZE
#define BSIZE BBSIZE
#endif
#endif
/*
* Define standard options.
* These value should match the values in USC_common.h.
*/
#define NOFUNC "nofunc" /* no func check flag */
#define ITERATIONS "iterations:" /* # iterations */
#define DURATION "duration:" /* walltime floating point */
#define DELAY "delay:" /* delay each iteration */
#define TIMING "timing" /* sys call timing flag */
#define ERRNO_LOGGING "errno_logging" /* errno logging flag */
#define SETUP_PAUSE "pause_for_sigusr1" /* wait sigusr1 signal in setup */
#define COPIES "copies:" /* number copies */
#define USC_HELP "Help" /* basic help */
#define ITERATIONS_HELP \
" -iterations cnt : Execute test \"cnt\" times (Default is 1).\n\
A value of 0 will cause the test to run indefinitely.\n"
#define DELAY_HELP \
" -delay secs : Delay for \"secs\" seconds each iteration (def 0.0)\n"
#define DURATION_HELP \
" -duration secs : Iterate for elapsed time of \"secs\" (def 0.0)\n"
#define NOFUNC_HELP \
" -nofunc : Turn OFF Functional testing. Just exercise the system call.\n"
#define SETUP_PAUSE_HELP \
" -pause_for_sigusr1 : Pause for SIGUSR1 before entering testing loop.\n"
#define TIMING_HELP \
" -timing : Turn ON timing statistics (min, max and avg time in system call).\n"
#define ERRNO_LOGGING_HELP \
" -errno_logging : Turn ON errno logging.\n"
#define COPIES_HELP \
" -copies num : fork so there num copies (def 1)\n"
#define USC_HELP_HELP \
" -Help : parse_opts standard help and exit.\n"
/*
* Defines used for genating usage
*/
#define NOFUNC_USE "[-nofunc]"
#define ITERATIONS_USE "[-iterations cnt]"
#define DURATION_USE "[-duration secs]"
#define DELAY_USE "[-delay secs]"
#define TIMING_USE "[-timing]"
#define ERRNO_LOGGING_USE "[-errno_logging]"
#define SETUP_PAUSE_USE "[-pause_for_sigusr1]"
#define COPIES_USE "[-copies num]"
#define HELP_USE "[-Help]"
/***********************************************************************
* Define option_t structure type.
* Entries in this struct are used by the parse_opts routine
* to indicate valid options and return option arguments
***********************************************************************/
typedef struct {
char *option; /* Valid option string (one option only) like "a:" */
int *flag; /* pointer to location to set true if option given */
char **arg; /* pointer to location to place argument, if needed */
} option_t;
/***********************************************************************
* The following globals are defined in parse_opts.c but must be
* externed here because they are used in the macros defined below.
***********************************************************************/
extern int STD_FUNCTIONAL_TEST, /* turned off by -f to not do functional test */
STD_TIMING_ON, /* turned on by -t to print timing stats */
STD_PAUSE, /* turned on by -p to pause before loop */
STD_INFINITE, /* turned on by -c0 to loop forever */
STD_LOOP_COUNT, /* changed by -cn to set loop count to n */
STD_ERRNO_LOG, /* turned on by -e to log errnos returned */
STD_ERRNO_LIST[], /* counts of errnos returned. indexed by errno */
STD_COPIES,
STD_argind;
extern float STD_LOOP_DURATION, /* wall clock time to iterate */
STD_LOOP_DELAY; /* delay time after each iteration */
#define USC_MAX_ERRNO 2000
/**********************************************************************
* Prototype for parse_opts routine
**********************************************************************/
extern char *parse_opts();
/*
* define a structure
*/
struct usc_errno_t {
int flag;
};
/***********************************************************************
****
****
****
**********************************************************************/
#ifdef _USC_LIB_
extern int TEST_RETURN;
extern int TEST_ERRNO;
#else
/***********************************************************************
* Global array of bit masks to indicate errnos that are expected.
* Bits set by TEST_EXP_ENOS() macro and used by TEST_CLEANUP() macro.
***********************************************************************/
struct usc_errno_t TEST_VALID_ENO[USC_MAX_ERRNO];
/***********************************************************************
* Globals for returning the return code and errno from the system call
* test macros.
***********************************************************************/
int TEST_RETURN;
int TEST_ERRNO;
/***********************************************************************
* temporary variables for determining max and min times in TEST macro
***********************************************************************/
long btime, etime, tmptime;
#endif /* _USC_LIB_ */
/***********************************************************************
* structure for timing accumulator and counters
***********************************************************************/
struct tblock {
long tb_max;
long tb_min;
long tb_total;
long tb_count;
};
/***********************************************************************
* The following globals are externed here so that they are accessable
* in the macros that follow.
***********************************************************************/
extern struct tblock tblock;
extern void STD_go();
extern int (*_TMP_FUNC)(void);
extern char *STD_opts_help();
extern char *STD_opts();
/***********************************************************************
* TEST: calls a system call
*
* parameters:
* SCALL = system call and parameters to execute
*
***********************************************************************/
#define TEST(SCALL) TEST_RETURN = (unsigned) SCALL; TEST_ERRNO=errno;
/***********************************************************************
* TEST_VOID: calls a system call
*
* parameters:
* SCALL = system call and parameters to execute
*
* Note: This is IDENTICAL to the TEST() macro except that it is intended
* for use with syscalls returning no values (void syscall()). The
* Typecasting nothing (void) into an unsigned integer causes compilation
* errors.
*
***********************************************************************/
#define TEST_VOID(SCALL) SCALL; TEST_ERRNO=errno;
/***********************************************************************
* TEST_CLEANUP: print system call timing stats and errno log entries
* to stdout if STD_TIMING_ON and STD_ERRNO_LOG are set, respectively.
* Do NOT print ANY information if no system calls logged.
*
* parameters:
* none
*
***********************************************************************/
#define TEST_CLEANUP \
if ( STD_ERRNO_LOG ) { \
for (tmptime=0; tmptime<USC_MAX_ERRNO; tmptime++) { \
if ( STD_ERRNO_LIST[tmptime] ) { \
if ( TEST_VALID_ENO[tmptime].flag ) \
tst_resm(TINFO, "ERRNO %d:\tReceived %d Times", \
tmptime, STD_ERRNO_LIST[tmptime]); \
else \
tst_resm(TINFO, \
"ERRNO %d:\tReceived %d Times ** UNEXPECTED **", \
tmptime, STD_ERRNO_LIST[tmptime]); \
} \
} \
}
/***********************************************************************
* TEST_PAUSEF: Pause for SIGUSR1 if the pause flag is set.
* Set the user specified function as the interrupt
* handler instead of "STD_go"
*
* parameters:
* none
*
***********************************************************************/
#define TEST_PAUSEF(HANDLER) \
if ( STD_PAUSE ) { \
_TMP_FUNC = (int (*)())signal(SIGUSR1, HANDLER); \
pause(); \
signal(SIGUSR1, (void (*)())_TMP_FUNC); \
}
/***********************************************************************
* TEST_PAUSE: Pause for SIGUSR1 if the pause flag is set.
* Just continue when signal comes in.
*
* parameters:
* none
*
***********************************************************************/
#define TEST_PAUSE usc_global_setup_hook();
/***********************************************************************
* TEST_LOOPING now call the usc_test_looping function.
* The function will return 1 if the test should continue
* iterating.
*
***********************************************************************/
#define TEST_LOOPING usc_test_looping
/***********************************************************************
* TEST_ERROR_LOG(eno): log this errno if STD_ERRNO_LOG flag set
*
* parameters:
* int eno: the errno location in STD_ERRNO_LIST to log.
*
***********************************************************************/
#define TEST_ERROR_LOG(eno) \
if ( STD_ERRNO_LOG ) \
if ( eno < USC_MAX_ERRNO ) \
STD_ERRNO_LIST[eno]++; \
/***********************************************************************
* TEST_EXP_ENOS(array): set the bits associated with the nput errnos
* in the TEST_VALID_ENO array.
*
* parameters:
* int array[]: a zero terminated array of errnos expected.
*
***********************************************************************/
#define TEST_EXP_ENOS(array) \
tmptime=0; \
while (array[tmptime] != 0) { \
if (array[tmptime] < USC_MAX_ERRNO) \
TEST_VALID_ENO[array[tmptime]].flag=1; \
tmptime++; \
}
#endif /* end of __USCTEST_H__ */