alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. |
Cyril Hrubis | 06f9fe4 | 2013-06-26 14:55:48 +0200 | [diff] [blame] | 3 | * Copyright (c) 2009-2013 Cyril Hrubis chrubis@suse.cz |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 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 |
Wanlong Gao | fed9641 | 2012-10-24 10:10:29 +0800 | [diff] [blame] | 21 | * with this program; if not, write the Free Software Foundation, Inc., |
| 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 34 | #ifndef __TEST_H__ |
| 35 | #define __TEST_H__ |
| 36 | |
| 37 | #include <stdio.h> |
| 38 | #include <signal.h> |
| 39 | #include <unistd.h> |
plars | 2888451 | 2002-05-21 13:01:00 +0000 | [diff] [blame] | 40 | #include <string.h> |
| 41 | #include <stdlib.h> |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 42 | |
vapier | 2751f26 | 2008-02-11 16:39:54 +0000 | [diff] [blame] | 43 | #include "compiler.h" |
| 44 | |
Cyril Hrubis | 4274895 | 2012-11-27 19:26:45 +0100 | [diff] [blame] | 45 | #include "safe_file_ops.h" |
Cyril Hrubis | ab8388c | 2012-11-28 15:42:17 +0100 | [diff] [blame] | 46 | #include "tst_checkpoint.h" |
Cyril Hrubis | 1924061 | 2012-12-11 18:51:54 +0100 | [diff] [blame] | 47 | #include "tst_process_state.h" |
Cyril Hrubis | 69c2ab0 | 2012-12-12 17:22:29 +0100 | [diff] [blame] | 48 | #include "tst_resource.h" |
Cyril Hrubis | 4274895 | 2012-11-27 19:26:45 +0100 | [diff] [blame] | 49 | |
subrata_modak | 7f71cfb | 2009-08-04 11:47:10 +0000 | [diff] [blame] | 50 | /* Use low 6 bits to encode test type */ |
| 51 | #define TTYPE_MASK 0x3f |
vapier | 9799ea1 | 2009-07-20 02:42:32 +0000 | [diff] [blame] | 52 | #define TPASS 0 /* Test passed flag */ |
| 53 | #define TFAIL 1 /* Test failed flag */ |
| 54 | #define TBROK 2 /* Test broken flag */ |
subrata_modak | 7f71cfb | 2009-08-04 11:47:10 +0000 | [diff] [blame] | 55 | #define TWARN 4 /* Test warning flag */ |
| 56 | #define TRETR 8 /* Test retire flag */ |
| 57 | #define TINFO 16 /* Test information flag */ |
| 58 | #define TCONF 32 /* Test not appropriate for configuration flag */ |
vapier | 9799ea1 | 2009-07-20 02:42:32 +0000 | [diff] [blame] | 59 | #define TTYPE_RESULT(ttype) ((ttype) & TTYPE_MASK) |
| 60 | |
| 61 | #define TERRNO 0x100 /* Append errno information to output */ |
| 62 | #define TTERRNO 0x200 /* Append TEST_ERRNO information to output */ |
Garrett Cooper | a9e49f1 | 2010-12-16 10:54:03 -0800 | [diff] [blame] | 63 | #define TRERRNO 0x300 /* Capture errno information from TEST_RETURN to |
| 64 | output; useful for pthread-like APIs :). */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 65 | |
Jan Stancek | 11a84a6 | 2013-10-17 12:44:49 +0200 | [diff] [blame] | 66 | /* virt types for tst_is_virt() */ |
| 67 | #define VIRT_XEN 1 /* xen dom0/domU */ |
| 68 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 69 | /* |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 70 | * Ensure that NUMSIGS is defined. |
| 71 | * It should be defined in signal.h or sys/signal.h on |
| 72 | * UNICOS/mk and IRIX systems. On UNICOS systems, |
| 73 | * it is not defined, thus it is being set to UNICOS's NSIG. |
vapier | 45a8ba0 | 2009-07-20 10:59:32 +0000 | [diff] [blame] | 74 | * Note: IRIX's NSIG (signals are 1-(NSIG-1)) |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 75 | * is not same meaning as UNICOS/UMK's NSIG (signals 1-NSIG) |
| 76 | */ |
| 77 | #ifndef NUMSIGS |
| 78 | #define NUMSIGS NSIG |
| 79 | #endif |
| 80 | |
| 81 | |
| 82 | /* defines for unexpected signal setup routine (set_usig.c) */ |
| 83 | #define FORK 1 /* SIGCLD is to be ignored */ |
| 84 | #define NOFORK 0 /* SIGCLD is to be caught */ |
subrata_modak | 40bc6aa | 2009-09-27 17:46:05 +0000 | [diff] [blame] | 85 | #define DEF_HANDLER SIG_ERR /* tells set_usig() to use default signal handler */ |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * The following defines are used to control tst_res and t_result reporting. |
| 89 | */ |
| 90 | |
| 91 | #define TOUTPUT "TOUTPUT" /* The name of the environment variable */ |
| 92 | /* that can be set to one of the following */ |
| 93 | /* strings to control tst_res output */ |
| 94 | /* If not set, TOUT_VERBOSE_S is assumed */ |
| 95 | |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 96 | /* |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 97 | * fork() can't be used on uClinux systems, so use FORK_OR_VFORK instead, |
| 98 | * which will run vfork() on uClinux. |
| 99 | * mmap() doesn't support MAP_PRIVATE on uClinux systems, so use |
| 100 | * MAP_PRIVATE_EXCEPT_UCLINUX instead, which will skip the option on uClinux. |
| 101 | * If MAP_PRIVATE really is required, the test can not be run on uClinux. |
| 102 | */ |
| 103 | #ifdef UCLINUX |
Cyril Hrubis | 3f0510c | 2014-02-06 13:50:14 +0100 | [diff] [blame] | 104 | # define FORK_OR_VFORK tst_vfork |
| 105 | # define MAP_PRIVATE_EXCEPT_UCLINUX 0 |
| 106 | /* tst_flush() + vfork() */ |
| 107 | pid_t tst_vfork(void); |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 108 | #else |
Cyril Hrubis | 3f0510c | 2014-02-06 13:50:14 +0100 | [diff] [blame] | 109 | # define FORK_OR_VFORK tst_fork |
| 110 | # define MAP_PRIVATE_EXCEPT_UCLINUX MAP_PRIVATE |
robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 111 | #endif |
| 112 | |
| 113 | /* |
Alexey Kodanev | bf17abf | 2014-02-18 18:08:30 +0400 | [diff] [blame] | 114 | * Macro to use for making functions called only once in |
| 115 | * multi-threaded tests such as init or cleanup function. |
| 116 | * The first call to @name_fn function by any thread shall |
| 117 | * call the @exec_fn. Subsequent calls shall not call @exec_fn. |
| 118 | * *_fn functions must not take any arguments. |
| 119 | */ |
| 120 | #define TST_DECLARE_ONCE_FN(name_fn, exec_fn) \ |
| 121 | void name_fn(void) \ |
| 122 | { \ |
| 123 | static pthread_once_t ltp_once = PTHREAD_ONCE_INIT; \ |
| 124 | pthread_once(<p_once, exec_fn); \ |
| 125 | } |
| 126 | |
| 127 | /* |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 128 | * lib/forker.c |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 129 | */ |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 130 | extern int Forker_pids[]; |
| 131 | extern int Forker_npids; |
| 132 | |
| 133 | /* lib/tst_res.c */ |
vapier | 9799ea1 | 2009-07-20 02:42:32 +0000 | [diff] [blame] | 134 | const char *strttype(int ttype); |
Mike Frysinger | 55d8ae5 | 2014-02-13 04:11:45 -0500 | [diff] [blame] | 135 | void tst_res(int ttype, const char *fname, const char *arg_fmt, ...) |
subrata_modak | 0d719e5 | 2009-08-30 17:18:18 +0000 | [diff] [blame] | 136 | __attribute__ ((format (printf, 3, 4))); |
Mike Frysinger | 55d8ae5 | 2014-02-13 04:11:45 -0500 | [diff] [blame] | 137 | void tst_resm(int ttype, const char *arg_fmt, ...) |
subrata_modak | 0d719e5 | 2009-08-30 17:18:18 +0000 | [diff] [blame] | 138 | __attribute__ ((format (printf, 2, 3))); |
Mike Frysinger | 55d8ae5 | 2014-02-13 04:11:45 -0500 | [diff] [blame] | 139 | void tst_resm_hexd(int ttype, const void *buf, size_t size, const char *arg_fmt, ...) |
Alexey Kodanev | 04a34ba | 2013-05-23 11:03:18 +0400 | [diff] [blame] | 140 | __attribute__ ((format (printf, 4, 5))); |
Mike Frysinger | 55d8ae5 | 2014-02-13 04:11:45 -0500 | [diff] [blame] | 141 | void tst_brk(int ttype, const char *fname, void (*func)(void), const char *arg_fmt, ...) |
Garrett Cooper | 68d76e0 | 2010-12-20 05:49:48 -0800 | [diff] [blame] | 142 | __attribute__ ((format (printf, 4, 5))); |
Mike Frysinger | 55d8ae5 | 2014-02-13 04:11:45 -0500 | [diff] [blame] | 143 | void tst_brkm(int ttype, void (*func)(void), const char *arg_fmt, ...) |
Cyril Hrubis | 9ef186f | 2011-05-11 13:13:12 +0200 | [diff] [blame] | 144 | __attribute__ ((format (printf, 3, 4))) LTP_ATTRIBUTE_NORETURN; |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 145 | void tst_require_root(void (*func)(void)); |
| 146 | int tst_environ(void); |
| 147 | void tst_exit(void) LTP_ATTRIBUTE_NORETURN; |
| 148 | void tst_flush(void); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 149 | |
Cyril Hrubis | ddd3b85 | 2014-02-03 17:10:04 +0100 | [diff] [blame] | 150 | /* |
| 151 | * tst_flush() + fork |
| 152 | */ |
| 153 | pid_t tst_fork(void); |
| 154 | |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 155 | extern int tst_count; |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 156 | |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 157 | /* lib/tst_sig.c */ |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 158 | void tst_sig(int fork_flag, void (*handler)(), void (*cleanup)()); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 159 | |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 160 | /* lib/tst_tmpdir.c */ |
Marios Makris | 60b1baa | 2012-08-09 20:36:46 +0300 | [diff] [blame] | 161 | |
| 162 | /* tst_tmpdir() |
| 163 | * |
| 164 | * Create a unique temporary directory and chdir() to it. It expects the caller |
| 165 | * to have defined/initialized the TCID/TST_TOTAL global variables. |
| 166 | * The TESTDIR global variable will be set to the directory that gets used |
| 167 | * as the testing directory. |
| 168 | * |
| 169 | * NOTE: This function must be called BEFORE any activity that would require |
| 170 | * CLEANUP. If tst_tmpdir() fails, it cleans up afer itself and calls |
| 171 | * tst_exit() (i.e. does not return). |
| 172 | */ |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 173 | void tst_tmpdir(void); |
Marios Makris | 60b1baa | 2012-08-09 20:36:46 +0300 | [diff] [blame] | 174 | /* tst_rmdir() |
| 175 | * |
| 176 | * Recursively remove the temporary directory created by tst_tmpdir(). |
| 177 | * This function is intended ONLY as a companion to tst_tmpdir(). |
Marios Makris | 60b1baa | 2012-08-09 20:36:46 +0300 | [diff] [blame] | 178 | */ |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 179 | void tst_rmdir(void); |
Marios Makris | 60b1baa | 2012-08-09 20:36:46 +0300 | [diff] [blame] | 180 | /* get_tst_tmpdir() |
| 181 | * |
| 182 | * Return a copy of the test temp directory as seen by LTP. This is for |
| 183 | * path-oriented tests like chroot, etc, that may munge the path a bit. |
| 184 | * |
| 185 | * FREE VARIABLE AFTER USE IF IT IS REUSED! |
| 186 | */ |
Garrett Cooper | db97680 | 2010-12-16 15:56:25 -0800 | [diff] [blame] | 187 | char *get_tst_tmpdir(void); |
Cyril Hrubis | ab8388c | 2012-11-28 15:42:17 +0100 | [diff] [blame] | 188 | /* |
| 189 | * Returns 1 if temp directory was created. |
| 190 | */ |
| 191 | int tst_tmpdir_created(void); |
alaffin | cc2e555 | 2000-07-27 17:13:18 +0000 | [diff] [blame] | 192 | |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 193 | /* lib/get_high_address.c */ |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 194 | char *get_high_address(void); |
robbiew | f3a83d5 | 2002-05-28 16:26:16 +0000 | [diff] [blame] | 195 | |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 196 | /* lib/tst_kvercmp.c */ |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 197 | void tst_getkver(int *k1, int *k2, int *k3); |
| 198 | int tst_kvercmp(int r1, int r2, int r3); |
robbiew | 143090a | 2005-01-17 22:10:09 +0000 | [diff] [blame] | 199 | |
Wanlong Gao | ef73cc9 | 2013-07-09 15:54:51 +0800 | [diff] [blame] | 200 | struct tst_kern_exv { |
| 201 | char *dist_name; |
| 202 | char *extra_ver; |
| 203 | }; |
| 204 | |
| 205 | int tst_kvercmp2(int r1, int r2, int r3, struct tst_kern_exv *vers); |
| 206 | |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 207 | /* lib/tst_cwd_has_free.c */ |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 208 | int tst_cwd_has_free(int required_kib); |
| 209 | |
Jan Stancek | 11a84a6 | 2013-10-17 12:44:49 +0200 | [diff] [blame] | 210 | int tst_is_virt(int virt_type); |
| 211 | |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 212 | /* lib/self_exec.c */ |
Mike Frysinger | 55d8ae5 | 2014-02-13 04:11:45 -0500 | [diff] [blame] | 213 | void maybe_run_child(void (*child)(), const char *fmt, ...); |
| 214 | int self_exec(const char *argv0, const char *fmt, ...); |
subrata_modak | 744305e | 2008-08-19 07:00:49 +0000 | [diff] [blame] | 215 | |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 216 | /* Functions from lib/cloner.c */ |
Zeng Linggang | 1db6266 | 2014-01-09 20:10:11 +0800 | [diff] [blame] | 217 | int ltp_clone(unsigned long flags, int (*fn)(void *arg), void *arg, |
| 218 | size_t stack_size, void *stack); |
| 219 | int ltp_clone7(unsigned long flags, int (*fn)(void *arg), void *arg, |
zenglg.jy | 5f5cb63 | 2013-12-18 17:29:51 +0800 | [diff] [blame] | 220 | size_t stack_size, void *stack, ...); |
vapier | f6d7f09 | 2009-11-03 20:07:35 +0000 | [diff] [blame] | 221 | int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg), |
| 222 | void *arg, size_t stacksize); |
| 223 | int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg), |
| 224 | void *arg); |
| 225 | #define clone(...) use_the_ltp_clone_functions,do_not_use_clone |
| 226 | |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 227 | /* Functions from lib/mount_utils.c */ |
yaberauneya | cfb7063 | 2010-01-10 08:01:15 +0000 | [diff] [blame] | 228 | char *get_block_device(const char *path); |
yaberauneya | c2a3ba5 | 2010-01-10 22:27:14 +0000 | [diff] [blame] | 229 | char *get_mountpoint(const char *path); |
yaberauneya | cfb7063 | 2010-01-10 08:01:15 +0000 | [diff] [blame] | 230 | |
Garrett Cooper | aec33cd | 2010-12-17 04:14:16 -0800 | [diff] [blame] | 231 | /* Function from lib/get_path.c */ |
Subrata Modak | ca758b7 | 2010-05-18 01:28:14 +0530 | [diff] [blame] | 232 | int tst_get_path(const char *prog_name, char *buf, size_t buf_len); |
| 233 | |
Wanlong Gao | 3b535a8 | 2012-10-18 16:35:14 +0800 | [diff] [blame] | 234 | /* lib/tst_cpu.c */ |
| 235 | long tst_ncpus(void); |
| 236 | long tst_ncpus_max(void); |
| 237 | |
Alexey Kodanev | 4bc55ec | 2013-06-27 18:52:22 +0400 | [diff] [blame] | 238 | /* lib/tst_run_cmd.c |
| 239 | * |
| 240 | * vfork() + execvp() specified program. |
| 241 | * @argv: a list of two (at least program name + NULL) or more pointers that |
| 242 | * represent the argument list to the new program. The array of pointers |
| 243 | * must be terminated by a NULL pointer. |
Stanislav kholmanskikh | bee0a94 | 2013-08-06 16:54:37 +0400 | [diff] [blame] | 244 | * @stdout_fd: file descriptor where to redirect stdout. Set -1 if |
| 245 | * redirection is not needed. |
| 246 | * @stderr_fd: file descriptor where to redirect stderr. Set -1 if |
| 247 | * redirection is not needed. |
Alexey Kodanev | 4bc55ec | 2013-06-27 18:52:22 +0400 | [diff] [blame] | 248 | */ |
Stanislav kholmanskikh | bee0a94 | 2013-08-06 16:54:37 +0400 | [diff] [blame] | 249 | void tst_run_cmd_fds(void (cleanup_fn)(void), |
Stanislav Kholmanskikh | e63337a | 2013-08-08 11:18:06 +0400 | [diff] [blame] | 250 | const char *const argv[], |
Stanislav kholmanskikh | bee0a94 | 2013-08-06 16:54:37 +0400 | [diff] [blame] | 251 | int stdout_fd, |
| 252 | int stderr_fd); |
| 253 | |
| 254 | /* Executes tst_run_cmd_fds() and redirects its output to a file |
| 255 | * @stdout_path: path where to redirect stdout. Set NULL if redirection is |
| 256 | * not needed. |
| 257 | * @stderr_path: path where to redirect stderr. Set NULL if redirection is |
| 258 | * not needed. |
| 259 | */ |
| 260 | void tst_run_cmd(void (cleanup_fn)(void), |
Stanislav Kholmanskikh | e63337a | 2013-08-08 11:18:06 +0400 | [diff] [blame] | 261 | const char *const argv[], |
Stanislav kholmanskikh | bee0a94 | 2013-08-06 16:54:37 +0400 | [diff] [blame] | 262 | const char *stdout_path, |
| 263 | const char *stderr_path); |
Alexey Kodanev | 4bc55ec | 2013-06-27 18:52:22 +0400 | [diff] [blame] | 264 | |
Cyril Hrubis | 2492ce2 | 2013-08-08 14:24:38 +0200 | [diff] [blame] | 265 | /* lib/tst_mkfs.c |
| 266 | * |
| 267 | * @dev: path to a device |
| 268 | * @fs_type: filesystem type |
| 269 | * @fs_opts: extra mkfs options |
| 270 | */ |
| 271 | void tst_mkfs(void (cleanup_fn)(void), const char *dev, |
| 272 | const char *fs_type, const char *fs_opts); |
| 273 | |
Stanislav Kholmanskikh | 1d5d484 | 2013-08-14 10:01:46 +0400 | [diff] [blame] | 274 | /* lib/tst_fill_file.c |
| 275 | * |
| 276 | * Creates/ovewrites a file with specified pattern |
| 277 | * @path: path to file |
| 278 | * @pattern: pattern |
| 279 | * @bs: block size |
| 280 | * @bcount: blocks amount |
| 281 | */ |
| 282 | int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); |
| 283 | |
Stanislav Kholmanskikh | bc44eb3 | 2014-01-13 13:35:22 +0400 | [diff] [blame] | 284 | /* lib/tst_uid_gid.c |
| 285 | * |
| 286 | * Return the first unused uid and gid |
| 287 | */ |
| 288 | uid_t tst_get_unused_uid(void); |
| 289 | gid_t tst_get_unused_gid(void); |
| 290 | |
subrata_modak | 744305e | 2008-08-19 07:00:49 +0000 | [diff] [blame] | 291 | #ifdef TST_USE_COMPAT16_SYSCALL |
| 292 | #define TCID_BIT_SUFFIX "_16" |
| 293 | #elif TST_USE_NEWER64_SYSCALL |
| 294 | #define TCID_BIT_SUFFIX "_64" |
| 295 | #else |
| 296 | #define TCID_BIT_SUFFIX "" |
| 297 | #endif |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 298 | #define TCID_DEFINE(ID) char *TCID = (#ID TCID_BIT_SUFFIX) |
subrata_modak | 744305e | 2008-08-19 07:00:49 +0000 | [diff] [blame] | 299 | |
subrata_modak | 88c166c | 2009-06-09 16:01:20 +0000 | [diff] [blame] | 300 | #endif /* __TEST_H__ */ |