alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 3 | * Copyright (c) 2009 Cyril Hrubis chrubis@suse.cz |
| 4 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of version 2 of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 8 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 9 | * This program is distributed in the hope that it would be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 12 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 13 | * Further, this software is distributed without any warranty that it is |
| 14 | * free of the rightful claim of any third person regarding infringement |
| 15 | * or the like. Any license provided herein, whether implied or |
| 16 | * otherwise, applies only to this software file. Patent licenses, if |
| 17 | * any, provided herein do not apply to combinations of this program with |
| 18 | * other software, or any other product whatsoever. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 19 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 20 | * You should have received a copy of the GNU General Public License along |
| 21 | * with this program; if not, write the Free Software Foundation, Inc., 59 |
| 22 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 23 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 24 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 25 | * Mountain View, CA 94043, or: |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 26 | * |
| 27 | * http://www.sgi.com |
| 28 | * |
| 29 | * For further information regarding this notice, see: |
| 30 | * |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 31 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 32 | */ |
| 33 | |
yaberauneya | c2a3ba5 | 2010-01-10 22:27:14 +0000 | [diff] [blame] | 34 | /* $Id: test.h,v 1.26 2010/01/10 22:27:15 yaberauneya Exp $ */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 35 | |
| 36 | #ifndef __TEST_H__ |
| 37 | #define __TEST_H__ |
| 38 | |
| 39 | #include <stdio.h> |
| 40 | #include <signal.h> |
| 41 | #include <unistd.h> |
plars | 2888451 | 2002-05-21 13:01:00 +0000 | [diff] [blame] | 42 | #include <string.h> |
| 43 | #include <stdlib.h> |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 44 | |
vapier | 2751f26 | 2008-02-11 16:39:54 +0000 | [diff] [blame] | 45 | #include "compiler.h" |
| 46 | |
subrata_modak | 7f71cfb | 2009-08-04 11:47:10 +0000 | [diff] [blame] | 47 | /* Use low 6 bits to encode test type */ |
| 48 | #define TTYPE_MASK 0x3f |
vapier | 9799ea1 | 2009-07-20 02:42:32 +0000 | [diff] [blame] | 49 | #define TPASS 0 /* Test passed flag */ |
| 50 | #define TFAIL 1 /* Test failed flag */ |
| 51 | #define TBROK 2 /* Test broken flag */ |
subrata_modak | 7f71cfb | 2009-08-04 11:47:10 +0000 | [diff] [blame] | 52 | #define TWARN 4 /* Test warning flag */ |
| 53 | #define TRETR 8 /* Test retire flag */ |
| 54 | #define TINFO 16 /* Test information flag */ |
| 55 | #define TCONF 32 /* Test not appropriate for configuration flag */ |
vapier | 9799ea1 | 2009-07-20 02:42:32 +0000 | [diff] [blame] | 56 | #define TTYPE_RESULT(ttype) ((ttype) & TTYPE_MASK) |
| 57 | |
| 58 | #define TERRNO 0x100 /* Append errno information to output */ |
| 59 | #define TTERRNO 0x200 /* Append TEST_ERRNO information to output */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 60 | |
| 61 | /* |
| 62 | * To determine if you are on a Umk or Unicos system, |
| 63 | * use sysconf(_SC_CRAY_SYSTEM). But since _SC_CRAY_SYSTEM |
| 64 | * is not defined until 90, it will be define here if not already |
| 65 | * defined. |
| 66 | * if ( sysconf(_SC_CRAY_SYSTEM) == 1 ) |
| 67 | * on UMK |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 68 | * else # returned 0 or -1 |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 69 | * on Unicos |
| 70 | * This is only being done on CRAY systems. |
| 71 | */ |
| 72 | #ifdef CRAY |
| 73 | #ifndef _SC_CRAY_SYSTEM |
| 74 | #define _SC_CRAY_SYSTEM 140 |
| 75 | #endif /* ! _SC_CRAY_SYSTEM */ |
| 76 | #endif /* CRAY */ |
| 77 | |
| 78 | /* |
| 79 | * Ensure that NUMSIGS is defined. |
| 80 | * It should be defined in signal.h or sys/signal.h on |
| 81 | * UNICOS/mk and IRIX systems. On UNICOS systems, |
| 82 | * it is not defined, thus it is being set to UNICOS's NSIG. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 83 | * Note: IRIX's NSIG (signals are 1-(NSIG-1)) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 84 | * is not same meaning as UNICOS/UMK's NSIG (signals 1-NSIG) |
| 85 | */ |
| 86 | #ifndef NUMSIGS |
| 87 | #define NUMSIGS NSIG |
| 88 | #endif |
| 89 | |
| 90 | |
| 91 | /* defines for unexpected signal setup routine (set_usig.c) */ |
| 92 | #define FORK 1 /* SIGCLD is to be ignored */ |
| 93 | #define NOFORK 0 /* SIGCLD is to be caught */ |
subrata_modak | 40bc6aa | 2009-09-27 17:46:05 +0000 | [diff] [blame] | 94 | #define DEF_HANDLER SIG_ERR /* tells set_usig() to use default signal handler */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 95 | |
| 96 | /* |
| 97 | * The following defines are used to control tst_res and t_result reporting. |
| 98 | */ |
| 99 | |
| 100 | #define TOUTPUT "TOUTPUT" /* The name of the environment variable */ |
| 101 | /* that can be set to one of the following */ |
| 102 | /* strings to control tst_res output */ |
| 103 | /* If not set, TOUT_VERBOSE_S is assumed */ |
| 104 | |
| 105 | #define TOUT_VERBOSE_S "VERBOSE" /* All test cases reported */ |
| 106 | #define TOUT_CONDENSE_S "CONDENSE" /* ranges are used where identical messages*/ |
| 107 | /* occur for sequential test cases */ |
| 108 | #define TOUT_NOPASS_S "NOPASS" /* No pass test cases are reported */ |
| 109 | #define TOUT_DISCARD_S "DISCARD" /* No output is reported */ |
| 110 | |
| 111 | #define TST_NOBUF "TST_NOBUF" /* The name of the environment variable */ |
| 112 | /* that can be set to control whether or not */ |
| 113 | /* tst_res will buffer output into 4096 byte */ |
| 114 | /* blocks of output */ |
| 115 | /* If not set, buffer is done. If set, no */ |
| 116 | /* internal buffering will be done in tst_res */ |
| 117 | /* t_result does not have internal buffering */ |
| 118 | |
| 119 | /* |
| 120 | * The following defines are used to control tst_tmpdir, tst_wildcard and t_mkchdir |
| 121 | */ |
| 122 | |
| 123 | #define TDIRECTORY "TDIRECTORY" /* The name of the environment variable */ |
| 124 | /* that if is set, the value (directory) */ |
| 125 | /* is used by all tests as their working */ |
| 126 | /* directory. tst_rmdir and t_rmdir will */ |
| 127 | /* not attempt to clean up. */ |
| 128 | /* This environment variable should only */ |
| 129 | /* be set when doing system testing since */ |
| 130 | /* tests will collide and break and fail */ |
| 131 | /* because of setting it. */ |
| 132 | |
| 133 | #define TEMPDIR "/tmp" /* This is the default temporary directory. */ |
| 134 | /* The environment variable TMPDIR is */ |
| 135 | /* used prior to this valid by tempnam(3). */ |
| 136 | /* To control the base location of the */ |
| 137 | /* temporary directory, set the TMPDIR */ |
| 138 | /* environment variable to desired path */ |
| 139 | |
| 140 | /* |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 141 | * The following define contains the name of an environmental variable |
| 142 | * that can be used to specify the number of iterations. |
| 143 | * It is supported in parse_opts.c and USC_setup.c. |
| 144 | */ |
| 145 | #define USC_ITERATION_ENV "USC_ITERATIONS" |
| 146 | |
| 147 | /* |
| 148 | * The following define contains the name of an environmental variable |
| 149 | * that can be used to specify to iteration until desired time |
| 150 | * in floating point seconds has gone by. |
| 151 | * Supported in USC_setup.c. |
| 152 | */ |
| 153 | #define USC_LOOP_WALLTIME "USC_LOOP_WALLTIME" |
| 154 | |
| 155 | /* |
| 156 | * The following define contains the name of an environmental variable |
| 157 | * that can be used to specify that no functional checks are wanted. |
| 158 | * It is supported in parse_opts.c and USC_setup.c. |
| 159 | */ |
| 160 | #define USC_NO_FUNC_CHECK "USC_NO_FUNC_CHECK" |
| 161 | |
| 162 | /* |
| 163 | * The following define contains the name of an environmental variable |
| 164 | * that can be used to specify the delay between each loop iteration. |
| 165 | * The value is in seconds (fractional numbers are allowed). |
| 166 | * It is supported in parse_opts.c. |
| 167 | */ |
| 168 | #define USC_LOOP_DELAY "USC_LOOP_DELAY" |
| 169 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 170 | /* |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 171 | * fork() can't be used on uClinux systems, so use FORK_OR_VFORK instead, |
| 172 | * which will run vfork() on uClinux. |
| 173 | * mmap() doesn't support MAP_PRIVATE on uClinux systems, so use |
| 174 | * MAP_PRIVATE_EXCEPT_UCLINUX instead, which will skip the option on uClinux. |
| 175 | * If MAP_PRIVATE really is required, the test can not be run on uClinux. |
| 176 | */ |
| 177 | #ifdef UCLINUX |
| 178 | #define FORK_OR_VFORK vfork |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 179 | #define MAP_PRIVATE_EXCEPT_UCLINUX 0 |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 180 | #else |
| 181 | #define FORK_OR_VFORK fork |
| 182 | #define MAP_PRIVATE_EXCEPT_UCLINUX MAP_PRIVATE |
| 183 | #endif |
| 184 | |
| 185 | /* |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 186 | * Functions from lib/tst_res.c |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 187 | */ |
vapier | 9799ea1 | 2009-07-20 02:42:32 +0000 | [diff] [blame] | 188 | const char *strttype(int ttype); |
subrata_modak | 0d719e5 | 2009-08-30 17:18:18 +0000 | [diff] [blame] | 189 | void tst_res(int ttype, char *fname, char *arg_fmt, ...) |
| 190 | __attribute__ ((format (printf, 3, 4))); |
| 191 | void tst_resm(int ttype, char *arg_fmt, ...) |
| 192 | __attribute__ ((format (printf, 2, 3))); |
| 193 | void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...) |
| 194 | __attribute__ ((format (printf, 4, 5))); |
| 195 | void tst_brkloop(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...) |
| 196 | __attribute__ ((format (printf, 4, 5))); |
| 197 | void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...) |
| 198 | __attribute__ ((format (printf, 3, 4))); |
| 199 | void tst_brkloopm(int ttype, void (*func)(void), char *arg_fmt, ...) |
| 200 | __attribute__ ((format (printf, 3, 4))); |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 201 | void tst_require_root(void (*func)(void)); |
| 202 | int tst_environ(void); |
| 203 | void tst_exit(void) LTP_ATTRIBUTE_NORETURN; |
| 204 | void tst_flush(void); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 205 | |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 206 | extern int Tst_count; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 207 | |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 208 | /* |
| 209 | * Function from lib/tst_sig.c |
| 210 | */ |
| 211 | void tst_sig(int fork_flag, void (*handler)(), void (*cleanup)()); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 212 | |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 213 | /* |
| 214 | * Functions from lib/tst_tmpdir.c |
| 215 | */ |
| 216 | void tst_tmpdir(void); |
| 217 | void tst_rmdir(void); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 218 | |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 219 | /* |
| 220 | * Function from lib/get_high_address.c |
| 221 | */ |
| 222 | char *get_high_address(void); |
robbiew | f3a83d5 | 2002-05-28 16:26:16 +0000 | [diff] [blame] | 223 | |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 224 | /* |
| 225 | * Functions from lib/tst_kvercmp.c |
| 226 | */ |
| 227 | void tst_getkver(int *k1, int *k2, int *k3); |
| 228 | int tst_kvercmp(int r1, int r2, int r3); |
robbiew | 143090a | 2005-01-17 22:10:09 +0000 | [diff] [blame] | 229 | |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 230 | /* |
vapier | 019fc96 | 2009-08-28 12:43:06 +0000 | [diff] [blame] | 231 | * Function from lib/tst_is_cwd.c |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 232 | */ |
| 233 | int tst_is_cwd_nfs(void); |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 234 | int tst_is_cwd_tmpfs(void); |
vapier | 019fc96 | 2009-08-28 12:43:06 +0000 | [diff] [blame] | 235 | int tst_is_cwd_ramfs(void); |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 236 | |
| 237 | /* |
| 238 | * Function from lib/tst_cwd_has_free.c |
| 239 | */ |
| 240 | int tst_cwd_has_free(int required_kib); |
| 241 | |
| 242 | /* |
| 243 | * Functions from lib/self_exec.c |
| 244 | */ |
| 245 | void maybe_run_child(void (*child)(), char *fmt, ...); |
| 246 | int self_exec(char *argv0, char *fmt, ...); |
subrata_modak | 744305e | 2008-08-19 07:00:49 +0000 | [diff] [blame] | 247 | |
vapier | f6d7f09 | 2009-11-03 20:07:35 +0000 | [diff] [blame] | 248 | /* |
| 249 | * Functions from lib/cloner.c |
| 250 | */ |
| 251 | int ltp_clone(unsigned long clone_flags, int (*fn)(void *arg), void *arg, |
| 252 | size_t stack_size, void *stack); |
| 253 | int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg), |
| 254 | void *arg, size_t stacksize); |
| 255 | int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg), |
| 256 | void *arg); |
| 257 | #define clone(...) use_the_ltp_clone_functions,do_not_use_clone |
| 258 | |
yaberauneya | cfb7063 | 2010-01-10 08:01:15 +0000 | [diff] [blame] | 259 | /* |
yaberauneya | c2a3ba5 | 2010-01-10 22:27:14 +0000 | [diff] [blame] | 260 | * Functions from lib/mount_utils.c |
yaberauneya | cfb7063 | 2010-01-10 08:01:15 +0000 | [diff] [blame] | 261 | */ |
| 262 | char *get_block_device(const char *path); |
yaberauneya | c2a3ba5 | 2010-01-10 22:27:14 +0000 | [diff] [blame] | 263 | char *get_mountpoint(const char *path); |
yaberauneya | cfb7063 | 2010-01-10 08:01:15 +0000 | [diff] [blame] | 264 | |
Subrata Modak | ca758b7 | 2010-05-18 01:28:14 +0530 | [diff] [blame] | 265 | /* |
| 266 | * Function from lib/get_path.c |
| 267 | */ |
| 268 | int tst_get_path(const char *prog_name, char *buf, size_t buf_len); |
| 269 | |
subrata_modak | 744305e | 2008-08-19 07:00:49 +0000 | [diff] [blame] | 270 | #ifdef TST_USE_COMPAT16_SYSCALL |
| 271 | #define TCID_BIT_SUFFIX "_16" |
| 272 | #elif TST_USE_NEWER64_SYSCALL |
| 273 | #define TCID_BIT_SUFFIX "_64" |
| 274 | #else |
| 275 | #define TCID_BIT_SUFFIX "" |
| 276 | #endif |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 277 | #define TCID_DEFINE(ID) char *TCID = (#ID TCID_BIT_SUFFIX) |
subrata_modak | 744305e | 2008-08-19 07:00:49 +0000 | [diff] [blame] | 278 | |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 279 | #endif /* __TEST_H__ */ |