00001 /* 00002 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 00003 * 00004 * This program is free software; you can redistribute it and/or modify it 00005 * under the terms of version 2 of the GNU General Public License as 00006 * published by the Free Software Foundation. 00007 * 00008 * This program is distributed in the hope that it would be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00011 * 00012 * Further, this software is distributed without any warranty that it is 00013 * free of the rightful claim of any third person regarding infringement 00014 * or the like. Any license provided herein, whether implied or 00015 * otherwise, applies only to this software file. Patent licenses, if 00016 * any, provided herein do not apply to combinations of this program with 00017 * other software, or any other product whatsoever. 00018 * 00019 * You should have received a copy of the GNU General Public License along 00020 * with this program; if not, write the Free Software Foundation, Inc., 59 00021 * Temple Place - Suite 330, Boston MA 02111-1307, USA. 00022 * 00023 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 00024 * Mountain View, CA 94043, or: 00025 * 00026 * http://www.sgi.com 00027 * 00028 * For further information regarding this notice, see: 00029 * 00030 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 00031 */ 00032 00033 /* $Id: test.h,v 1.10 2006/05/26 06:17:53 vapier Exp $ */ 00034 00035 #ifndef __TEST_H__ 00036 #define __TEST_H__ 00037 00038 #include <stdio.h> 00039 #include <signal.h> 00040 #include <unistd.h> 00041 #include <string.h> 00042 #include <stdlib.h> 00043 00044 #define TPASS 0 /* Test passed flag */ 00045 #define TFAIL 1 /* Test failed flag */ 00046 #define TBROK 2 /* Test broken flag */ 00047 #define TWARN 4 /* Test warning flag */ 00048 #define TRETR 8 /* Test retire flag */ 00049 #define TINFO 16 /* Test information flag */ 00050 #define TCONF 32 /* Test not appropriate for configuration flag */ 00051 00052 /* 00053 * To determine if you are on a Umk or Unicos system, 00054 * use sysconf(_SC_CRAY_SYSTEM). But since _SC_CRAY_SYSTEM 00055 * is not defined until 90, it will be define here if not already 00056 * defined. 00057 * if ( sysconf(_SC_CRAY_SYSTEM) == 1 ) 00058 * on UMK 00059 * else # returned 0 or -1 00060 * on Unicos 00061 * This is only being done on CRAY systems. 00062 */ 00063 #ifdef CRAY 00064 #ifndef _SC_CRAY_SYSTEM 00065 #define _SC_CRAY_SYSTEM 140 00066 #endif /* ! _SC_CRAY_SYSTEM */ 00067 #endif /* CRAY */ 00068 00069 /* 00070 * Ensure that NUMSIGS is defined. 00071 * It should be defined in signal.h or sys/signal.h on 00072 * UNICOS/mk and IRIX systems. On UNICOS systems, 00073 * it is not defined, thus it is being set to UNICOS's NSIG. 00074 * Note: IRIX's NSIG (signals are 1-(NSIG-1)) 00075 * is not same meaning as UNICOS/UMK's NSIG (signals 1-NSIG) 00076 */ 00077 #define NSIG _NSIG 00078 #define SIGCLD SIGCHLD 00079 #ifndef NUMSIGS 00080 #define NUMSIGS NSIG 00081 #endif 00082 00083 00084 /* defines for unexpected signal setup routine (set_usig.c) */ 00085 #define FORK 1 /* SIGCLD is to be ignored */ 00086 #define NOFORK 0 /* SIGCLD is to be caught */ 00087 #define DEF_HANDLER 0 /* tells set_usig() to use default signal handler */ 00088 00089 /* 00090 * The following defines are used to control tst_res and t_result reporting. 00091 */ 00092 00093 #define TOUTPUT "TOUTPUT" /* The name of the environment variable */ 00094 /* that can be set to one of the following */ 00095 /* strings to control tst_res output */ 00096 /* If not set, TOUT_VERBOSE_S is assumed */ 00097 00098 #define TOUT_VERBOSE_S "VERBOSE" /* All test cases reported */ 00099 #define TOUT_CONDENSE_S "CONDENSE" /* ranges are used where identical messages*/ 00100 /* occur for sequential test cases */ 00101 #define TOUT_NOPASS_S "NOPASS" /* No pass test cases are reported */ 00102 #define TOUT_DISCARD_S "DISCARD" /* No output is reported */ 00103 00104 #define TST_NOBUF "TST_NOBUF" /* The name of the environment variable */ 00105 /* that can be set to control whether or not */ 00106 /* tst_res will buffer output into 4096 byte */ 00107 /* blocks of output */ 00108 /* If not set, buffer is done. If set, no */ 00109 /* internal buffering will be done in tst_res */ 00110 /* t_result does not have internal buffering */ 00111 00112 /* 00113 * The following defines are used to control tst_tmpdir, tst_wildcard and t_mkchdir 00114 */ 00115 00116 #define TDIRECTORY "TDIRECTORY" /* The name of the environment variable */ 00117 /* that if is set, the value (directory) */ 00118 /* is used by all tests as their working */ 00119 /* directory. tst_rmdir and t_rmdir will */ 00120 /* not attempt to clean up. */ 00121 /* This environment variable should only */ 00122 /* be set when doing system testing since */ 00123 /* tests will collide and break and fail */ 00124 /* because of setting it. */ 00125 00126 #define TEMPDIR "/tmp" /* This is the default temporary directory. */ 00127 /* The environment variable TMPDIR is */ 00128 /* used prior to this valid by tempnam(3). */ 00129 /* To control the base location of the */ 00130 /* temporary directory, set the TMPDIR */ 00131 /* environment variable to desired path */ 00132 00133 /* 00134 * The following contains support for error message passing. 00135 * See test_error.c for details. 00136 */ 00137 #define TST_ERR_MESG_SIZE 1023 /* max size of error message */ 00138 #define TST_ERR_FILE_SIZE 511 /* max size of module name used by compiler */ 00139 #define TST_ERR_FUNC_SIZE 127 /* max size of func name */ 00140 00141 typedef struct { 00142 int te_line; /* line where last error was reported. Use */ 00143 /* "__LINE__" and let compiler do the rest */ 00144 int te_level; /* If set, will prevent current stored */ 00145 /* error to not be overwritten */ 00146 char te_func[TST_ERR_FUNC_SIZE+1]; /* name of function of last error */ 00147 /* Name of function or NULL */ 00148 char te_file[TST_ERR_FILE_SIZE+1]; /* module of last error. Use */ 00149 /* "__FILE__" and let compiler do the rest */ 00150 char te_mesg[TST_ERR_MESG_SIZE+1]; /* string of last error */ 00151 00152 } _TST_ERROR; 00153 00154 extern _TST_ERROR Tst_error; /* defined in test_error.c */ 00155 #if __STDC__ 00156 extern void tst_set_error(char *file, int line, char *func, char *fmt, ...); 00157 #else 00158 extern void tst_set_error(void); 00159 #endif 00160 extern void tst_clear_error(void); 00161 00162 00163 /* 00164 * The following define contains the name of an environmental variable 00165 * that can be used to specify the number of iterations. 00166 * It is supported in parse_opts.c and USC_setup.c. 00167 */ 00168 #define USC_ITERATION_ENV "USC_ITERATIONS" 00169 00170 /* 00171 * The following define contains the name of an environmental variable 00172 * that can be used to specify to iteration until desired time 00173 * in floating point seconds has gone by. 00174 * Supported in USC_setup.c. 00175 */ 00176 #define USC_LOOP_WALLTIME "USC_LOOP_WALLTIME" 00177 00178 /* 00179 * The following define contains the name of an environmental variable 00180 * that can be used to specify that no functional checks are wanted. 00181 * It is supported in parse_opts.c and USC_setup.c. 00182 */ 00183 #define USC_NO_FUNC_CHECK "USC_NO_FUNC_CHECK" 00184 00185 /* 00186 * The following define contains the name of an environmental variable 00187 * that can be used to specify the delay between each loop iteration. 00188 * The value is in seconds (fractional numbers are allowed). 00189 * It is supported in parse_opts.c. 00190 */ 00191 #define USC_LOOP_DELAY "USC_LOOP_DELAY" 00192 00193 /* 00194 * fork() can't be used on uClinux systems, so use FORK_OR_VFORK instead, 00195 * which will run vfork() on uClinux. 00196 * mmap() doesn't support MAP_PRIVATE on uClinux systems, so use 00197 * MAP_PRIVATE_EXCEPT_UCLINUX instead, which will skip the option on uClinux. 00198 * If MAP_PRIVATE really is required, the test can not be run on uClinux. 00199 */ 00200 #ifdef UCLINUX 00201 #define FORK_OR_VFORK vfork 00202 #define MAP_PRIVATE_EXCEPT_UCLINUX 0 00203 #else 00204 #define FORK_OR_VFORK fork 00205 #define MAP_PRIVATE_EXCEPT_UCLINUX MAP_PRIVATE 00206 #endif 00207 00208 /* 00209 * The following prototypes are needed to remove compile errors 00210 * on IRIX systems when compiled with -n32 and -64. 00211 */ 00212 extern void tst_res(int ttype, char *fname, char *arg_fmt, ...); 00213 extern void tst_resm(int ttype, char *arg_fmt, ...); 00214 extern void tst_brk(int ttype, char *fname, void (*func)(void), 00215 char *arg_fmt, ...); 00216 extern void tst_brkloop(int ttype, char *fname, void (*func)(void), 00217 char *arg_fmt, ...); 00218 extern void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...); 00219 extern void tst_brkloopm(int ttype, void (*func)(void), char *arg_fmt, ...); 00220 00221 extern int tst_environ(void); 00222 extern void tst_exit(void); 00223 extern void tst_flush(void); 00224 00225 /* prototypes for the t_res.c functions */ 00226 extern void t_result(char *tcid, int tnum, int ttype, char *tmesg); 00227 extern void tt_exit(void); 00228 extern int t_environ(void); 00229 extern void t_breakum(char *tcid, int total, int typ, char *msg, void (*fnc)(void)); 00230 00231 extern void tst_sig(int fork_flag, void (*handler)(int), void (*cleanup)(void)); 00232 extern void tst_tmpdir(void); 00233 extern void tst_rmdir(void); 00234 00235 extern char * get_high_address(void); 00236 00237 extern void get_kver(int*, int*, int*); 00238 extern int tst_kvercmp(int, int, int); 00239 00240 extern int tst_is_cwd_tmpfs(void); 00241 extern int tst_cwd_has_free(int required_kib); 00242 00243 extern int Tst_count; 00244 00245 /* self_exec.c functions */ 00246 void maybe_run_child(void (*child)(void), char *fmt, ...); 00247 int self_exec(char *argv0, char *fmt, ...); 00248 00249 #endif /* end of __TEST_H__ */
1.5.8