blob: 3a8a6cb5a45d101c02f3e3479e482796645aa5ef [file] [log] [blame]
alaffincc2e5552000-07-27 17:13:18 +00001/*
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
vapier2751f262008-02-11 16:39:54 +000033/* $Id: test.h,v 1.12 2008/02/11 16:39:54 vapier Exp $ */
alaffincc2e5552000-07-27 17:13:18 +000034
35#ifndef __TEST_H__
36#define __TEST_H__
37
38#include <stdio.h>
39#include <signal.h>
40#include <unistd.h>
plars28884512002-05-21 13:01:00 +000041#include <string.h>
42#include <stdlib.h>
alaffincc2e5552000-07-27 17:13:18 +000043
vapier2751f262008-02-11 16:39:54 +000044#include "compiler.h"
45
alaffincc2e5552000-07-27 17:13:18 +000046#define TPASS 0 /* Test passed flag */
47#define TFAIL 1 /* Test failed flag */
48#define TBROK 2 /* Test broken flag */
49#define TWARN 4 /* Test warning flag */
50#define TRETR 8 /* Test retire flag */
51#define TINFO 16 /* Test information flag */
52#define TCONF 32 /* Test not appropriate for configuration flag */
53
54/*
55 * To determine if you are on a Umk or Unicos system,
56 * use sysconf(_SC_CRAY_SYSTEM). But since _SC_CRAY_SYSTEM
57 * is not defined until 90, it will be define here if not already
58 * defined.
59 * if ( sysconf(_SC_CRAY_SYSTEM) == 1 )
60 * on UMK
61 * else # returned 0 or -1
62 * on Unicos
63 * This is only being done on CRAY systems.
64 */
65#ifdef CRAY
66#ifndef _SC_CRAY_SYSTEM
67#define _SC_CRAY_SYSTEM 140
68#endif /* ! _SC_CRAY_SYSTEM */
69#endif /* CRAY */
70
71/*
72 * Ensure that NUMSIGS is defined.
73 * It should be defined in signal.h or sys/signal.h on
74 * UNICOS/mk and IRIX systems. On UNICOS systems,
75 * it is not defined, thus it is being set to UNICOS's NSIG.
76 * Note: IRIX's NSIG (signals are 1-(NSIG-1))
77 * is not same meaning as UNICOS/UMK's NSIG (signals 1-NSIG)
78 */
79#ifndef NUMSIGS
80#define NUMSIGS NSIG
81#endif
82
83
84/* defines for unexpected signal setup routine (set_usig.c) */
85#define FORK 1 /* SIGCLD is to be ignored */
86#define NOFORK 0 /* SIGCLD is to be caught */
87#define DEF_HANDLER 0 /* tells set_usig() to use default signal handler */
88
89/*
90 * The following defines are used to control tst_res and t_result reporting.
91 */
92
93#define TOUTPUT "TOUTPUT" /* The name of the environment variable */
94 /* that can be set to one of the following */
95 /* strings to control tst_res output */
96 /* If not set, TOUT_VERBOSE_S is assumed */
97
98#define TOUT_VERBOSE_S "VERBOSE" /* All test cases reported */
99#define TOUT_CONDENSE_S "CONDENSE" /* ranges are used where identical messages*/
100 /* occur for sequential test cases */
101#define TOUT_NOPASS_S "NOPASS" /* No pass test cases are reported */
102#define TOUT_DISCARD_S "DISCARD" /* No output is reported */
103
104#define TST_NOBUF "TST_NOBUF" /* The name of the environment variable */
105 /* that can be set to control whether or not */
106 /* tst_res will buffer output into 4096 byte */
107 /* blocks of output */
108 /* If not set, buffer is done. If set, no */
109 /* internal buffering will be done in tst_res */
110 /* t_result does not have internal buffering */
111
112/*
113 * The following defines are used to control tst_tmpdir, tst_wildcard and t_mkchdir
114 */
115
116#define TDIRECTORY "TDIRECTORY" /* The name of the environment variable */
117 /* that if is set, the value (directory) */
118 /* is used by all tests as their working */
119 /* directory. tst_rmdir and t_rmdir will */
120 /* not attempt to clean up. */
121 /* This environment variable should only */
122 /* be set when doing system testing since */
123 /* tests will collide and break and fail */
124 /* because of setting it. */
125
126#define TEMPDIR "/tmp" /* This is the default temporary directory. */
127 /* The environment variable TMPDIR is */
128 /* used prior to this valid by tempnam(3). */
129 /* To control the base location of the */
130 /* temporary directory, set the TMPDIR */
131 /* environment variable to desired path */
132
133/*
134 * The following contains support for error message passing.
135 * See test_error.c for details.
136 */
137#define TST_ERR_MESG_SIZE 1023 /* max size of error message */
138#define TST_ERR_FILE_SIZE 511 /* max size of module name used by compiler */
139#define TST_ERR_FUNC_SIZE 127 /* max size of func name */
140
141typedef struct {
142 int te_line; /* line where last error was reported. Use */
143 /* "__LINE__" and let compiler do the rest */
144 int te_level; /* If set, will prevent current stored */
145 /* error to not be overwritten */
146 char te_func[TST_ERR_FUNC_SIZE+1]; /* name of function of last error */
147 /* Name of function or NULL */
148 char te_file[TST_ERR_FILE_SIZE+1]; /* module of last error. Use */
149 /* "__FILE__" and let compiler do the rest */
150 char te_mesg[TST_ERR_MESG_SIZE+1]; /* string of last error */
151
152} _TST_ERROR;
153
154extern _TST_ERROR Tst_error; /* defined in test_error.c */
155#if __STDC__
156extern void tst_set_error(char *file, int line, char *func, char *fmt, ...);
157#else
158extern void tst_set_error();
159#endif
160extern void tst_clear_error();
161
162
163/*
164 * The following define contains the name of an environmental variable
165 * that can be used to specify the number of iterations.
166 * It is supported in parse_opts.c and USC_setup.c.
167 */
168#define USC_ITERATION_ENV "USC_ITERATIONS"
169
170/*
171 * The following define contains the name of an environmental variable
172 * that can be used to specify to iteration until desired time
173 * in floating point seconds has gone by.
174 * Supported in USC_setup.c.
175 */
176#define USC_LOOP_WALLTIME "USC_LOOP_WALLTIME"
177
178/*
179 * The following define contains the name of an environmental variable
180 * that can be used to specify that no functional checks are wanted.
181 * It is supported in parse_opts.c and USC_setup.c.
182 */
183#define USC_NO_FUNC_CHECK "USC_NO_FUNC_CHECK"
184
185/*
186 * The following define contains the name of an environmental variable
187 * that can be used to specify the delay between each loop iteration.
188 * The value is in seconds (fractional numbers are allowed).
189 * It is supported in parse_opts.c.
190 */
191#define USC_LOOP_DELAY "USC_LOOP_DELAY"
192
alaffincc2e5552000-07-27 17:13:18 +0000193/*
robbiewd34d5812005-07-11 22:28:09 +0000194 * fork() can't be used on uClinux systems, so use FORK_OR_VFORK instead,
195 * which will run vfork() on uClinux.
196 * mmap() doesn't support MAP_PRIVATE on uClinux systems, so use
197 * MAP_PRIVATE_EXCEPT_UCLINUX instead, which will skip the option on uClinux.
198 * If MAP_PRIVATE really is required, the test can not be run on uClinux.
199 */
200#ifdef UCLINUX
201#define FORK_OR_VFORK vfork
202#define MAP_PRIVATE_EXCEPT_UCLINUX 0
203#else
204#define FORK_OR_VFORK fork
205#define MAP_PRIVATE_EXCEPT_UCLINUX MAP_PRIVATE
206#endif
207
208/*
alaffincc2e5552000-07-27 17:13:18 +0000209 * The following prototypes are needed to remove compile errors
210 * on IRIX systems when compiled with -n32 and -64.
211 */
212extern void tst_res(int ttype, char *fname, char *arg_fmt, ...);
213extern void tst_resm(int ttype, char *arg_fmt, ...);
214extern void tst_brk(int ttype, char *fname, void (*func)(),
215 char *arg_fmt, ...);
216extern void tst_brkloop(int ttype, char *fname, void (*func)(),
217 char *arg_fmt, ...);
218extern void tst_brkm(int ttype, void (*func)(), char *arg_fmt, ...);
219extern void tst_brkloopm(int ttype, void (*func)(), char *arg_fmt, ...);
220
221extern int tst_environ();
vapier2751f262008-02-11 16:39:54 +0000222extern void tst_exit() attribute_noreturn;
alaffincc2e5552000-07-27 17:13:18 +0000223extern void tst_flush();
224
225/* prototypes for the t_res.c functions */
226extern void t_result(char *tcid, int tnum, int ttype, char *tmesg);
227extern void tt_exit();
228extern int t_environ();
229extern void t_breakum(char *tcid, int total, int typ, char *msg, void (*fnc)());
230
nstraz94181082000-08-30 18:43:38 +0000231extern void tst_sig(int fork_flag, void (*handler)(), void (*cleanup)());
232extern void tst_tmpdir();
233extern void tst_rmdir();
alaffincc2e5552000-07-27 17:13:18 +0000234
robbiewf3a83d52002-05-28 16:26:16 +0000235extern char * get_high_address(void);
robbiewf3a83d52002-05-28 16:26:16 +0000236
plarsea696e02003-02-27 16:48:33 +0000237extern void get_kver(int*, int*, int*);
plars255c3522003-03-03 21:40:43 +0000238extern int tst_kvercmp(int, int, int);
subrata_modakfa9086a2007-11-15 08:46:18 +0000239extern int tst_is_cwd_nfs();
robbiew143090a2005-01-17 22:10:09 +0000240extern int tst_is_cwd_tmpfs();
241extern int tst_cwd_has_free(int required_kib);
242
vapier6064c3a2006-05-26 06:17:53 +0000243extern int Tst_count;
244
robbiewd34d5812005-07-11 22:28:09 +0000245/* self_exec.c functions */
246void maybe_run_child(void (*child)(), char *fmt, ...);
247int self_exec(char *argv0, char *fmt, ...);
248
alaffincc2e5552000-07-27 17:13:18 +0000249#endif /* end of __TEST_H__ */