alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 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 | |
vapier | 2751f26 | 2008-02-11 16:39:54 +0000 | [diff] [blame^] | 33 | /* $Id: test.h,v 1.12 2008/02/11 16:39:54 vapier Exp $ */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 34 | |
| 35 | #ifndef __TEST_H__ |
| 36 | #define __TEST_H__ |
| 37 | |
| 38 | #include <stdio.h> |
| 39 | #include <signal.h> |
| 40 | #include <unistd.h> |
plars | 2888451 | 2002-05-21 13:01:00 +0000 | [diff] [blame] | 41 | #include <string.h> |
| 42 | #include <stdlib.h> |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 43 | |
vapier | 2751f26 | 2008-02-11 16:39:54 +0000 | [diff] [blame^] | 44 | #include "compiler.h" |
| 45 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 46 | #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 | |
| 141 | typedef 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 | |
| 154 | extern _TST_ERROR Tst_error; /* defined in test_error.c */ |
| 155 | #if __STDC__ |
| 156 | extern void tst_set_error(char *file, int line, char *func, char *fmt, ...); |
| 157 | #else |
| 158 | extern void tst_set_error(); |
| 159 | #endif |
| 160 | extern 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 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 193 | /* |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 194 | * 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 | /* |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 209 | * The following prototypes are needed to remove compile errors |
| 210 | * on IRIX systems when compiled with -n32 and -64. |
| 211 | */ |
| 212 | extern void tst_res(int ttype, char *fname, char *arg_fmt, ...); |
| 213 | extern void tst_resm(int ttype, char *arg_fmt, ...); |
| 214 | extern void tst_brk(int ttype, char *fname, void (*func)(), |
| 215 | char *arg_fmt, ...); |
| 216 | extern void tst_brkloop(int ttype, char *fname, void (*func)(), |
| 217 | char *arg_fmt, ...); |
| 218 | extern void tst_brkm(int ttype, void (*func)(), char *arg_fmt, ...); |
| 219 | extern void tst_brkloopm(int ttype, void (*func)(), char *arg_fmt, ...); |
| 220 | |
| 221 | extern int tst_environ(); |
vapier | 2751f26 | 2008-02-11 16:39:54 +0000 | [diff] [blame^] | 222 | extern void tst_exit() attribute_noreturn; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 223 | extern void tst_flush(); |
| 224 | |
| 225 | /* prototypes for the t_res.c functions */ |
| 226 | extern void t_result(char *tcid, int tnum, int ttype, char *tmesg); |
| 227 | extern void tt_exit(); |
| 228 | extern int t_environ(); |
| 229 | extern void t_breakum(char *tcid, int total, int typ, char *msg, void (*fnc)()); |
| 230 | |
nstraz | 9418108 | 2000-08-30 18:43:38 +0000 | [diff] [blame] | 231 | extern void tst_sig(int fork_flag, void (*handler)(), void (*cleanup)()); |
| 232 | extern void tst_tmpdir(); |
| 233 | extern void tst_rmdir(); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 234 | |
robbiew | f3a83d5 | 2002-05-28 16:26:16 +0000 | [diff] [blame] | 235 | extern char * get_high_address(void); |
robbiew | f3a83d5 | 2002-05-28 16:26:16 +0000 | [diff] [blame] | 236 | |
plars | ea696e0 | 2003-02-27 16:48:33 +0000 | [diff] [blame] | 237 | extern void get_kver(int*, int*, int*); |
plars | 255c352 | 2003-03-03 21:40:43 +0000 | [diff] [blame] | 238 | extern int tst_kvercmp(int, int, int); |
subrata_modak | fa9086a | 2007-11-15 08:46:18 +0000 | [diff] [blame] | 239 | extern int tst_is_cwd_nfs(); |
robbiew | 143090a | 2005-01-17 22:10:09 +0000 | [diff] [blame] | 240 | extern int tst_is_cwd_tmpfs(); |
| 241 | extern int tst_cwd_has_free(int required_kib); |
| 242 | |
vapier | 6064c3a | 2006-05-26 06:17:53 +0000 | [diff] [blame] | 243 | extern int Tst_count; |
| 244 | |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 245 | /* self_exec.c functions */ |
| 246 | void maybe_run_child(void (*child)(), char *fmt, ...); |
| 247 | int self_exec(char *argv0, char *fmt, ...); |
| 248 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 249 | #endif /* end of __TEST_H__ */ |