generic: hole punching followed by writes in the same range
[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  * Ensure that NUMSIGS is defined.
40  * It should be defined in signal.h or sys/signal.h on
41  * UNICOS/mk and IRIX systems.   On UNICOS systems,
42  * it is not defined, thus it is being set to UNICOS's NSIG.
43  * Note:  IRIX's NSIG (signals are 1-(NSIG-1)) 
44  *      is not same meaning as UNICOS/UMK's NSIG  (signals 1-NSIG)
45  */
46 #ifndef NUMSIGS
47 #define NUMSIGS NSIG
48 #endif
49
50
51 /* defines for unexpected signal setup routine (set_usig.c) */
52 #define FORK    1               /* SIGCLD is to be ignored */
53 #define NOFORK  0               /* SIGCLD is to be caught */
54 #define DEF_HANDLER 0   /* tells set_usig() to use default signal handler */
55
56 /*
57  * The following defines are used to control tst_res and t_result reporting.
58  */
59
60 #define TOUTPUT    "TOUTPUT"            /* The name of the environment variable */
61                                         /* that can be set to one of the following */
62                                         /* strings to control tst_res output */
63                                         /* If not set, TOUT_VERBOSE_S is assumed */
64
65 #define TOUT_VERBOSE_S  "VERBOSE"       /* All test cases reported */
66 #define TOUT_CONDENSE_S "CONDENSE"      /* ranges are used where identical messages*/
67                                         /* occur for sequential test cases */
68 #define TOUT_NOPASS_S   "NOPASS"        /* No pass test cases are reported */
69 #define TOUT_DISCARD_S  "DISCARD"       /* No output is reported */
70
71 #define TST_NOBUF       "TST_NOBUF"     /* The name of the environment variable */
72                                         /* that can be set to control whether or not */
73                                         /* tst_res will buffer output into 4096 byte */
74                                         /* blocks of output */
75                                         /* If not set, buffer is done.  If set, no */
76                                         /* internal buffering will be done in tst_res */
77                                         /* t_result does not have internal buffering */
78
79 /*
80  * The following defines are used to control tst_tmpdir, tst_wildcard and t_mkchdir
81  */
82
83 #define TDIRECTORY  "TDIRECTORY"        /* The name of the environment variable */
84                                         /* that if is set, the value (directory) */
85                                         /* is used by all tests as their working */
86                                         /* directory.  tst_rmdir and t_rmdir will */
87                                         /* not attempt to clean up. */
88                                         /* This environment variable should only */
89                                         /* be set when doing system testing since */
90                                         /* tests will collide and break and fail */
91                                         /* because of setting it. */
92
93 #define TEMPDIR "/tmp"                  /* This is the default temporary directory. */
94                                         /* The environment variable TMPDIR is */
95                                         /* used prior to this valid by tempnam(3). */
96                                         /* To control the base location of the */
97                                         /* temporary directory, set the TMPDIR */
98                                         /* environment variable to desired path */
99
100 /*
101  * The following contains support for error message passing.
102  * See test_error.c for details.
103  */
104 #define  TST_ERR_MESG_SIZE      1023    /* max size of error message */
105 #define  TST_ERR_FILE_SIZE      511     /* max size of module name used by compiler */
106 #define  TST_ERR_FUNC_SIZE      127     /* max size of func name */
107
108 typedef struct {
109     int  te_line;                       /* line where last error was reported.  Use */
110                                         /* "__LINE__" and let compiler do the rest */
111     int  te_level;                      /* If set, will prevent current stored */
112                                         /* error to not be overwritten */
113     char te_func[TST_ERR_FUNC_SIZE+1];  /* name of function of last error */
114                                         /* Name of function or NULL */
115     char te_file[TST_ERR_FILE_SIZE+1];  /* module of last error.  Use */
116                                         /* "__FILE__" and let compiler do the rest */
117     char te_mesg[TST_ERR_MESG_SIZE+1];  /* string of last error */
118
119 } _TST_ERROR;
120
121 extern _TST_ERROR Tst_error;            /* defined in test_error.c */
122 #if __STDC__
123 extern void tst_set_error(char *file, int line, char *func, char *fmt, ...);
124 #else
125 extern void tst_set_error();
126 #endif
127 extern void tst_clear_error();
128
129
130 /*
131  * The following define contains the name of an environmental variable
132  * that can be used to specify the number of iterations.
133  * It is supported in parse_opts.c and USC_setup.c.
134  */
135 #define USC_ITERATION_ENV       "USC_ITERATIONS"
136
137 /*
138  * The following define contains the name of an environmental variable
139  * that can be used to specify to iteration until desired time
140  * in floating point seconds has gone by.
141  * Supported in USC_setup.c.
142  */
143 #define USC_LOOP_WALLTIME       "USC_LOOP_WALLTIME"
144
145 /*
146  * The following define contains the name of an environmental variable
147  * that can be used to specify that no functional checks are wanted.
148  * It is supported in parse_opts.c and USC_setup.c.
149  */
150 #define USC_NO_FUNC_CHECK       "USC_NO_FUNC_CHECK"
151
152 /*
153  * The following define contains the name of an environmental variable
154  * that can be used to specify the delay between each loop iteration.
155  * The value is in seconds (fractional numbers are allowed).
156  * It is supported in parse_opts.c.
157  */
158 #define USC_LOOP_DELAY          "USC_LOOP_DELAY"
159
160 /*
161  * The following prototypes are needed to remove compile errors
162  * on IRIX systems when compiled with -n32 and -64.
163  */
164 extern void tst_res(int ttype, char *fname, char *arg_fmt, ...);
165 extern void tst_resm(int ttype, char *arg_fmt, ...);
166 extern void tst_brk(int ttype, char *fname, void (*func)(), 
167                                                         char *arg_fmt, ...);
168 extern void tst_brkloop(int ttype, char *fname, void (*func)(), 
169                                                         char *arg_fmt, ...);
170 extern void tst_brkm(int ttype, void (*func)(), char *arg_fmt, ...);
171 extern void tst_brkloopm(int ttype, void (*func)(), char *arg_fmt, ...);
172
173 extern int  tst_environ();
174 extern void tst_exit();
175 extern void tst_flush();
176
177 /* prototypes for the t_res.c functions */
178 extern void t_result(char *tcid, int tnum, int ttype, char *tmesg);
179 extern void tt_exit();
180 extern int  t_environ();
181 extern void t_breakum(char *tcid, int total, int typ, char *msg, void (*fnc)());
182
183 extern void tst_sig(int fork_flag, void (*handler)(), void (*cleanup)());
184 extern void tst_tmpdir();
185 extern void tst_rmdir();
186
187 extern char * get_high_address(void);
188
189 extern void get_kver(int*, int*, int*);
190 extern int tst_kvercmp(int, int, int);
191
192 #endif  /* end of __TEST_H__ */