blob: 7ac182a7173a228dca401e93a7a4c32bd8af7f6b [file] [log] [blame]
alaffincc2e5552000-07-27 17:13:18 +00001/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
subrata_modak88c166c2009-06-09 16:01:20 +00003 * Copyright (c) 2009 Cyril Hrubis chrubis@suse.cz
4 *
alaffincc2e5552000-07-27 17:13:18 +00005 * 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.
vapier45a8ba02009-07-20 10:59:32 +00008 *
alaffincc2e5552000-07-27 17:13:18 +00009 * 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.
vapier45a8ba02009-07-20 10:59:32 +000012 *
alaffincc2e5552000-07-27 17:13:18 +000013 * 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.
vapier45a8ba02009-07-20 10:59:32 +000019 *
alaffincc2e5552000-07-27 17:13:18 +000020 * 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.
vapier45a8ba02009-07-20 10:59:32 +000023 *
alaffincc2e5552000-07-27 17:13:18 +000024 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 * Mountain View, CA 94043, or:
vapier45a8ba02009-07-20 10:59:32 +000026 *
27 * http://www.sgi.com
28 *
29 * For further information regarding this notice, see:
30 *
alaffincc2e5552000-07-27 17:13:18 +000031 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
32 */
33
yaberauneyac2a3ba52010-01-10 22:27:14 +000034/* $Id: test.h,v 1.26 2010/01/10 22:27:15 yaberauneya Exp $ */
alaffincc2e5552000-07-27 17:13:18 +000035
36#ifndef __TEST_H__
37#define __TEST_H__
38
39#include <stdio.h>
40#include <signal.h>
41#include <unistd.h>
plars28884512002-05-21 13:01:00 +000042#include <string.h>
43#include <stdlib.h>
alaffincc2e5552000-07-27 17:13:18 +000044
vapier2751f262008-02-11 16:39:54 +000045#include "compiler.h"
46
subrata_modak7f71cfb2009-08-04 11:47:10 +000047/* Use low 6 bits to encode test type */
48#define TTYPE_MASK 0x3f
vapier9799ea12009-07-20 02:42:32 +000049#define TPASS 0 /* Test passed flag */
50#define TFAIL 1 /* Test failed flag */
51#define TBROK 2 /* Test broken flag */
subrata_modak7f71cfb2009-08-04 11:47:10 +000052#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 */
vapier9799ea12009-07-20 02:42:32 +000056#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 */
alaffincc2e5552000-07-27 17:13:18 +000060
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
vapier45a8ba02009-07-20 10:59:32 +000068 * else # returned 0 or -1
alaffincc2e5552000-07-27 17:13:18 +000069 * 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.
vapier45a8ba02009-07-20 10:59:32 +000083 * Note: IRIX's NSIG (signals are 1-(NSIG-1))
alaffincc2e5552000-07-27 17:13:18 +000084 * 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_modak40bc6aa2009-09-27 17:46:05 +000094#define DEF_HANDLER SIG_ERR /* tells set_usig() to use default signal handler */
alaffincc2e5552000-07-27 17:13:18 +000095
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/*
alaffincc2e5552000-07-27 17:13:18 +0000141 * 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
alaffincc2e5552000-07-27 17:13:18 +0000170/*
robbiewd34d5812005-07-11 22:28:09 +0000171 * 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
vapier45a8ba02009-07-20 10:59:32 +0000179#define MAP_PRIVATE_EXCEPT_UCLINUX 0
robbiewd34d5812005-07-11 22:28:09 +0000180#else
181#define FORK_OR_VFORK fork
182#define MAP_PRIVATE_EXCEPT_UCLINUX MAP_PRIVATE
183#endif
184
185/*
subrata_modak88c166c2009-06-09 16:01:20 +0000186 * Functions from lib/tst_res.c
alaffincc2e5552000-07-27 17:13:18 +0000187 */
vapier9799ea12009-07-20 02:42:32 +0000188const char *strttype(int ttype);
subrata_modak0d719e52009-08-30 17:18:18 +0000189void tst_res(int ttype, char *fname, char *arg_fmt, ...)
190 __attribute__ ((format (printf, 3, 4)));
191void tst_resm(int ttype, char *arg_fmt, ...)
192 __attribute__ ((format (printf, 2, 3)));
193void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...)
194 __attribute__ ((format (printf, 4, 5)));
195void tst_brkloop(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...)
196 __attribute__ ((format (printf, 4, 5)));
197void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...)
198 __attribute__ ((format (printf, 3, 4)));
199void tst_brkloopm(int ttype, void (*func)(void), char *arg_fmt, ...)
200 __attribute__ ((format (printf, 3, 4)));
subrata_modak88c166c2009-06-09 16:01:20 +0000201void tst_require_root(void (*func)(void));
202int tst_environ(void);
203void tst_exit(void) LTP_ATTRIBUTE_NORETURN;
204void tst_flush(void);
alaffincc2e5552000-07-27 17:13:18 +0000205
subrata_modak88c166c2009-06-09 16:01:20 +0000206extern int Tst_count;
alaffincc2e5552000-07-27 17:13:18 +0000207
subrata_modak88c166c2009-06-09 16:01:20 +0000208/*
209 * Function from lib/tst_sig.c
210 */
211void tst_sig(int fork_flag, void (*handler)(), void (*cleanup)());
alaffincc2e5552000-07-27 17:13:18 +0000212
subrata_modak88c166c2009-06-09 16:01:20 +0000213/*
214 * Functions from lib/tst_tmpdir.c
215 */
216void tst_tmpdir(void);
217void tst_rmdir(void);
alaffincc2e5552000-07-27 17:13:18 +0000218
subrata_modak88c166c2009-06-09 16:01:20 +0000219/*
220 * Function from lib/get_high_address.c
221 */
222char *get_high_address(void);
robbiewf3a83d52002-05-28 16:26:16 +0000223
subrata_modak88c166c2009-06-09 16:01:20 +0000224/*
225 * Functions from lib/tst_kvercmp.c
226 */
227void tst_getkver(int *k1, int *k2, int *k3);
228int tst_kvercmp(int r1, int r2, int r3);
robbiew143090a2005-01-17 22:10:09 +0000229
subrata_modak88c166c2009-06-09 16:01:20 +0000230/*
vapier019fc962009-08-28 12:43:06 +0000231 * Function from lib/tst_is_cwd.c
subrata_modak88c166c2009-06-09 16:01:20 +0000232 */
233int tst_is_cwd_nfs(void);
subrata_modak88c166c2009-06-09 16:01:20 +0000234int tst_is_cwd_tmpfs(void);
vapier019fc962009-08-28 12:43:06 +0000235int tst_is_cwd_ramfs(void);
subrata_modak88c166c2009-06-09 16:01:20 +0000236
237/*
238 * Function from lib/tst_cwd_has_free.c
239 */
240int tst_cwd_has_free(int required_kib);
241
242/*
243 * Functions from lib/self_exec.c
244 */
245void maybe_run_child(void (*child)(), char *fmt, ...);
246int self_exec(char *argv0, char *fmt, ...);
subrata_modak744305e2008-08-19 07:00:49 +0000247
vapierf6d7f092009-11-03 20:07:35 +0000248/*
249 * Functions from lib/cloner.c
250 */
251int ltp_clone(unsigned long clone_flags, int (*fn)(void *arg), void *arg,
252 size_t stack_size, void *stack);
253int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg),
254 void *arg, size_t stacksize);
255int 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
yaberauneyacfb70632010-01-10 08:01:15 +0000259/*
yaberauneyac2a3ba52010-01-10 22:27:14 +0000260 * Functions from lib/mount_utils.c
yaberauneyacfb70632010-01-10 08:01:15 +0000261 */
262char *get_block_device(const char *path);
yaberauneyac2a3ba52010-01-10 22:27:14 +0000263char *get_mountpoint(const char *path);
yaberauneyacfb70632010-01-10 08:01:15 +0000264
Subrata Modakca758b72010-05-18 01:28:14 +0530265/*
266 * Function from lib/get_path.c
267 */
268int tst_get_path(const char *prog_name, char *buf, size_t buf_len);
269
subrata_modak744305e2008-08-19 07:00:49 +0000270#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_modak88c166c2009-06-09 16:01:20 +0000277#define TCID_DEFINE(ID) char *TCID = (#ID TCID_BIT_SUFFIX)
subrata_modak744305e2008-08-19 07:00:49 +0000278
subrata_modak88c166c2009-06-09 16:01:20 +0000279#endif /* __TEST_H__ */