Update copyright annotations and license boilerplates to correspond with SGI Legals...
[xfstests-dev.git] / include / test.h
1 /*
2  * Copyright (c) 2000 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it would be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write the Free Software Foundation,
16  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18
19 /* $Id: test.h,v 1.2 2005/11/09 02:50:19 nathans.longdrop.melbourne.sgi.com Exp $ */
20
21 #ifndef __TEST_H__
22 #define __TEST_H__
23
24 #include <stdio.h>
25 #include <signal.h>
26 #include <unistd.h>
27 #include <string.h>
28 #include <stdlib.h>
29
30 #define TPASS    0    /* Test passed flag */
31 #define TFAIL    1    /* Test failed flag */
32 #define TBROK    2    /* Test broken flag */
33 #define TWARN    4    /* Test warning flag */
34 #define TRETR    8    /* Test retire flag */
35 #define TINFO    16   /* Test information flag */
36 #define TCONF    32   /* Test not appropriate for configuration flag */
37
38 /*
39  * To determine if you are on a Umk or Unicos system,
40  * use sysconf(_SC_CRAY_SYSTEM).  But since _SC_CRAY_SYSTEM
41  * is not defined until 90, it will be define here if not already
42  * defined.
43  * if ( sysconf(_SC_CRAY_SYSTEM) == 1 )
44  *    on UMK
45  * else   # returned 0 or -1 
46  *    on Unicos
47  * This is only being done on CRAY systems.
48  */
49 #ifdef CRAY
50 #ifndef _SC_CRAY_SYSTEM
51 #define _SC_CRAY_SYSTEM  140
52 #endif /* ! _SC_CRAY_SYSTEM */
53 #endif /* CRAY */
54
55 /*
56  * Ensure that NUMSIGS is defined.
57  * It should be defined in signal.h or sys/signal.h on
58  * UNICOS/mk and IRIX systems.   On UNICOS systems,
59  * it is not defined, thus it is being set to UNICOS's NSIG.
60  * Note:  IRIX's NSIG (signals are 1-(NSIG-1)) 
61  *      is not same meaning as UNICOS/UMK's NSIG  (signals 1-NSIG)
62  */
63 #ifndef NUMSIGS
64 #define NUMSIGS NSIG
65 #endif
66
67
68 /* defines for unexpected signal setup routine (set_usig.c) */
69 #define FORK    1               /* SIGCLD is to be ignored */
70 #define NOFORK  0               /* SIGCLD is to be caught */
71 #define DEF_HANDLER 0   /* tells set_usig() to use default signal handler */
72
73 /*
74  * The following defines are used to control tst_res and t_result reporting.
75  */
76
77 #define TOUTPUT    "TOUTPUT"            /* The name of the environment variable */
78                                         /* that can be set to one of the following */
79                                         /* strings to control tst_res output */
80                                         /* If not set, TOUT_VERBOSE_S is assumed */
81
82 #define TOUT_VERBOSE_S  "VERBOSE"       /* All test cases reported */
83 #define TOUT_CONDENSE_S "CONDENSE"      /* ranges are used where identical messages*/
84                                         /* occur for sequential test cases */
85 #define TOUT_NOPASS_S   "NOPASS"        /* No pass test cases are reported */
86 #define TOUT_DISCARD_S  "DISCARD"       /* No output is reported */
87
88 #define TST_NOBUF       "TST_NOBUF"     /* The name of the environment variable */
89                                         /* that can be set to control whether or not */
90                                         /* tst_res will buffer output into 4096 byte */
91                                         /* blocks of output */
92                                         /* If not set, buffer is done.  If set, no */
93                                         /* internal buffering will be done in tst_res */
94                                         /* t_result does not have internal buffering */
95
96 /*
97  * The following defines are used to control tst_tmpdir, tst_wildcard and t_mkchdir
98  */
99
100 #define TDIRECTORY  "TDIRECTORY"        /* The name of the environment variable */
101                                         /* that if is set, the value (directory) */
102                                         /* is used by all tests as their working */
103                                         /* directory.  tst_rmdir and t_rmdir will */
104                                         /* not attempt to clean up. */
105                                         /* This environment variable should only */
106                                         /* be set when doing system testing since */
107                                         /* tests will collide and break and fail */
108                                         /* because of setting it. */
109
110 #define TEMPDIR "/tmp"                  /* This is the default temporary directory. */
111                                         /* The environment variable TMPDIR is */
112                                         /* used prior to this valid by tempnam(3). */
113                                         /* To control the base location of the */
114                                         /* temporary directory, set the TMPDIR */
115                                         /* environment variable to desired path */
116
117 /*
118  * The following contains support for error message passing.
119  * See test_error.c for details.
120  */
121 #define  TST_ERR_MESG_SIZE      1023    /* max size of error message */
122 #define  TST_ERR_FILE_SIZE      511     /* max size of module name used by compiler */
123 #define  TST_ERR_FUNC_SIZE      127     /* max size of func name */
124
125 typedef struct {
126     int  te_line;                       /* line where last error was reported.  Use */
127                                         /* "__LINE__" and let compiler do the rest */
128     int  te_level;                      /* If set, will prevent current stored */
129                                         /* error to not be overwritten */
130     char te_func[TST_ERR_FUNC_SIZE+1];  /* name of function of last error */
131                                         /* Name of function or NULL */
132     char te_file[TST_ERR_FILE_SIZE+1];  /* module of last error.  Use */
133                                         /* "__FILE__" and let compiler do the rest */
134     char te_mesg[TST_ERR_MESG_SIZE+1];  /* string of last error */
135
136 } _TST_ERROR;
137
138 extern _TST_ERROR Tst_error;            /* defined in test_error.c */
139 #if __STDC__
140 extern void tst_set_error(char *file, int line, char *func, char *fmt, ...);
141 #else
142 extern void tst_set_error();
143 #endif
144 extern void tst_clear_error();
145
146
147 /*
148  * The following define contains the name of an environmental variable
149  * that can be used to specify the number of iterations.
150  * It is supported in parse_opts.c and USC_setup.c.
151  */
152 #define USC_ITERATION_ENV       "USC_ITERATIONS"
153
154 /*
155  * The following define contains the name of an environmental variable
156  * that can be used to specify to iteration until desired time
157  * in floating point seconds has gone by.
158  * Supported in USC_setup.c.
159  */
160 #define USC_LOOP_WALLTIME       "USC_LOOP_WALLTIME"
161
162 /*
163  * The following define contains the name of an environmental variable
164  * that can be used to specify that no functional checks are wanted.
165  * It is supported in parse_opts.c and USC_setup.c.
166  */
167 #define USC_NO_FUNC_CHECK       "USC_NO_FUNC_CHECK"
168
169 /*
170  * The following define contains the name of an environmental variable
171  * that can be used to specify the delay between each loop iteration.
172  * The value is in seconds (fractional numbers are allowed).
173  * It is supported in parse_opts.c.
174  */
175 #define USC_LOOP_DELAY          "USC_LOOP_DELAY"
176
177 /*
178  * The following prototypes are needed to remove compile errors
179  * on IRIX systems when compiled with -n32 and -64.
180  */
181 extern void tst_res(int ttype, char *fname, char *arg_fmt, ...);
182 extern void tst_resm(int ttype, char *arg_fmt, ...);
183 extern void tst_brk(int ttype, char *fname, void (*func)(), 
184                                                         char *arg_fmt, ...);
185 extern void tst_brkloop(int ttype, char *fname, void (*func)(), 
186                                                         char *arg_fmt, ...);
187 extern void tst_brkm(int ttype, void (*func)(), char *arg_fmt, ...);
188 extern void tst_brkloopm(int ttype, void (*func)(), char *arg_fmt, ...);
189
190 extern int  tst_environ();
191 extern void tst_exit();
192 extern void tst_flush();
193
194 /* prototypes for the t_res.c functions */
195 extern void t_result(char *tcid, int tnum, int ttype, char *tmesg);
196 extern void tt_exit();
197 extern int  t_environ();
198 extern void t_breakum(char *tcid, int total, int typ, char *msg, void (*fnc)());
199
200 extern void tst_sig(int fork_flag, void (*handler)(), void (*cleanup)());
201 extern void tst_tmpdir();
202 extern void tst_rmdir();
203
204 extern char * get_high_address(void);
205
206 extern void get_kver(int*, int*, int*);
207 extern int tst_kvercmp(int, int, int);
208
209 #endif  /* end of __TEST_H__ */