OSDN Git Service

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