blob: f6d5270d668ba454a9956d6fa707bdba4700d53b [file] [log] [blame]
alaffincc2e5552000-07-27 17:13:18 +00001/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
Cyril Hrubis06f9fe42013-06-26 14:55:48 +02003 * Copyright (c) 2009-2013 Cyril Hrubis chrubis@suse.cz
subrata_modak88c166c2009-06-09 16:01:20 +00004 *
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
Wanlong Gaofed96412012-10-24 10:10:29 +080021 * with this program; if not, write the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
alaffincc2e5552000-07-27 17:13:18 +000034#ifndef __TEST_H__
35#define __TEST_H__
36
37#include <stdio.h>
38#include <signal.h>
39#include <unistd.h>
plars28884512002-05-21 13:01:00 +000040#include <string.h>
41#include <stdlib.h>
Xiaoguang Wang46941672014-04-25 10:02:07 +080042#include <stdint.h>
alaffincc2e5552000-07-27 17:13:18 +000043
vapier2751f262008-02-11 16:39:54 +000044#include "compiler.h"
45
Cyril Hrubisaabb8342015-02-04 14:37:03 +010046#include "usctest.h"
47
Cyril Hrubis42748952012-11-27 19:26:45 +010048#include "safe_file_ops.h"
Cyril Hrubisab8388c2012-11-28 15:42:17 +010049#include "tst_checkpoint.h"
Cyril Hrubis19240612012-12-11 18:51:54 +010050#include "tst_process_state.h"
Cyril Hrubis69c2ab02012-12-12 17:22:29 +010051#include "tst_resource.h"
Xiaoguang Wang6f6878f2014-06-24 15:11:39 +080052#include "tst_res_flags.h"
alaffincc2e5552000-07-27 17:13:18 +000053
Jan Stancek11a84a62013-10-17 12:44:49 +020054/* virt types for tst_is_virt() */
55#define VIRT_XEN 1 /* xen dom0/domU */
56
alaffincc2e5552000-07-27 17:13:18 +000057/*
alaffincc2e5552000-07-27 17:13:18 +000058 * Ensure that NUMSIGS is defined.
59 * It should be defined in signal.h or sys/signal.h on
60 * UNICOS/mk and IRIX systems. On UNICOS systems,
61 * it is not defined, thus it is being set to UNICOS's NSIG.
vapier45a8ba02009-07-20 10:59:32 +000062 * Note: IRIX's NSIG (signals are 1-(NSIG-1))
alaffincc2e5552000-07-27 17:13:18 +000063 * is not same meaning as UNICOS/UMK's NSIG (signals 1-NSIG)
64 */
65#ifndef NUMSIGS
66#define NUMSIGS NSIG
67#endif
68
69
70/* defines for unexpected signal setup routine (set_usig.c) */
71#define FORK 1 /* SIGCLD is to be ignored */
72#define NOFORK 0 /* SIGCLD is to be caught */
subrata_modak40bc6aa2009-09-27 17:46:05 +000073#define DEF_HANDLER SIG_ERR /* tells set_usig() to use default signal handler */
alaffincc2e5552000-07-27 17:13:18 +000074
75/*
76 * The following defines are used to control tst_res and t_result reporting.
77 */
78
79#define TOUTPUT "TOUTPUT" /* The name of the environment variable */
80 /* that can be set to one of the following */
81 /* strings to control tst_res output */
82 /* If not set, TOUT_VERBOSE_S is assumed */
83
alaffincc2e5552000-07-27 17:13:18 +000084/*
robbiewd34d5812005-07-11 22:28:09 +000085 * fork() can't be used on uClinux systems, so use FORK_OR_VFORK instead,
86 * which will run vfork() on uClinux.
87 * mmap() doesn't support MAP_PRIVATE on uClinux systems, so use
88 * MAP_PRIVATE_EXCEPT_UCLINUX instead, which will skip the option on uClinux.
89 * If MAP_PRIVATE really is required, the test can not be run on uClinux.
90 */
91#ifdef UCLINUX
Cyril Hrubis3f0510c2014-02-06 13:50:14 +010092# define FORK_OR_VFORK tst_vfork
93# define MAP_PRIVATE_EXCEPT_UCLINUX 0
94/* tst_flush() + vfork() */
95pid_t tst_vfork(void);
robbiewd34d5812005-07-11 22:28:09 +000096#else
Cyril Hrubis3f0510c2014-02-06 13:50:14 +010097# define FORK_OR_VFORK tst_fork
98# define MAP_PRIVATE_EXCEPT_UCLINUX MAP_PRIVATE
robbiewd34d5812005-07-11 22:28:09 +000099#endif
100
101/*
Alexey Kodanevbf17abf2014-02-18 18:08:30 +0400102 * Macro to use for making functions called only once in
103 * multi-threaded tests such as init or cleanup function.
104 * The first call to @name_fn function by any thread shall
105 * call the @exec_fn. Subsequent calls shall not call @exec_fn.
106 * *_fn functions must not take any arguments.
107 */
108#define TST_DECLARE_ONCE_FN(name_fn, exec_fn) \
109 void name_fn(void) \
110 { \
111 static pthread_once_t ltp_once = PTHREAD_ONCE_INIT; \
112 pthread_once(&ltp_once, exec_fn); \
113 }
114
115/*
Garrett Cooperaec33cd2010-12-17 04:14:16 -0800116 * lib/forker.c
alaffincc2e5552000-07-27 17:13:18 +0000117 */
Garrett Cooperaec33cd2010-12-17 04:14:16 -0800118extern int Forker_pids[];
119extern int Forker_npids;
120
121/* lib/tst_res.c */
vapier9799ea12009-07-20 02:42:32 +0000122const char *strttype(int ttype);
Xiaoguang Wanga161c6f2014-07-21 17:00:04 +0800123void tst_res_(const char *file, const int lineno, int ttype,
124 const char *fname, const char *arg_fmt, ...)
125 __attribute__ ((format (printf, 5, 6)));
126
127#define tst_res(ttype, fname, arg_fmt, ...) \
128 tst_res_(__FILE__, __LINE__, (ttype), (fname), \
129 (arg_fmt), ##__VA_ARGS__)
130
131void tst_resm_(const char *file, const int lineno, int ttype,
132 const char *arg_fmt, ...)
Alexey Kodanev04a34ba2013-05-23 11:03:18 +0400133 __attribute__ ((format (printf, 4, 5)));
Xiaoguang Wanga161c6f2014-07-21 17:00:04 +0800134#define tst_resm(ttype, arg_fmt, ...) \
135 tst_resm_(__FILE__, __LINE__, (ttype), \
136 (arg_fmt), ##__VA_ARGS__)
137
138void tst_resm_hexd_(const char *file, const int lineno, int ttype,
139 const void *buf, size_t size, const char *arg_fmt, ...)
140 __attribute__ ((format (printf, 6, 7)));
141#define tst_resm_hexd(ttype, buf, size, arg_fmt, ...) \
142 tst_resm_hexd_(__FILE__, __LINE__, (ttype), (buf), (size), \
143 (arg_fmt), ##__VA_ARGS__)
144
145void tst_brk_(const char *file, const int lineno, int ttype,
146 const char *fname, void (*func)(void), const char *arg_fmt, ...)
147 __attribute__ ((format (printf, 6, 7)));
148#define tst_brk(ttype, fname, func, arg_fmt, ...) \
149 tst_brk_(__FILE__, __LINE__, (ttype), (fname), (func), \
150 (arg_fmt), ##__VA_ARGS__)
151
152void tst_brkm_(const char *file, const int lineno, int ttype,
153 void (*func)(void), const char *arg_fmt, ...)
154 __attribute__ ((format (printf, 5, 6))) LTP_ATTRIBUTE_NORETURN;
155#define tst_brkm(ttype, func, arg_fmt, ...) \
156 tst_brkm_(__FILE__, __LINE__, (ttype), (func), \
157 (arg_fmt), ##__VA_ARGS__)
158
subrata_modak88c166c2009-06-09 16:01:20 +0000159void tst_require_root(void (*func)(void));
160int tst_environ(void);
161void tst_exit(void) LTP_ATTRIBUTE_NORETURN;
162void tst_flush(void);
alaffincc2e5552000-07-27 17:13:18 +0000163
Cyril Hrubisddd3b852014-02-03 17:10:04 +0100164/*
165 * tst_flush() + fork
Xiaoguang Wang8c1e0b32014-07-28 19:51:39 +0800166 * NOTE: tst_fork() will reset T_exitval to 0 for child process.
Cyril Hrubisddd3b852014-02-03 17:10:04 +0100167 */
168pid_t tst_fork(void);
169
Xiaoguang Wang8c1e0b32014-07-28 19:51:39 +0800170/* lib/tst_res.c */
171/*
172 * In case we need do real test work in child process parent process can use
173 * tst_record_childstatus() to make child process's test results propagated to
174 * parent process correctly.
175 *
176 * The child can use tst_resm(), tst_brkm() followed by the tst_exit() or
177 * plain old exit() (with TPASS, TFAIL and TBROK).
178 *
179 * WARNING: Be wary that the child cleanup function passed to tst_brkm()
180 * must clean only resources the child has allocated. E.g. the
181 * child cleanup is different function from the parent cleanup.
182 */
183void tst_record_childstatus(void (*cleanup)(void), pid_t child);
184
Caspar Zhangd59a6592013-03-07 14:59:12 +0800185extern int tst_count;
alaffincc2e5552000-07-27 17:13:18 +0000186
Garrett Cooperaec33cd2010-12-17 04:14:16 -0800187/* lib/tst_sig.c */
subrata_modak88c166c2009-06-09 16:01:20 +0000188void tst_sig(int fork_flag, void (*handler)(), void (*cleanup)());
alaffincc2e5552000-07-27 17:13:18 +0000189
Garrett Cooperaec33cd2010-12-17 04:14:16 -0800190/* lib/tst_tmpdir.c */
Marios Makris60b1baa2012-08-09 20:36:46 +0300191
192/* tst_tmpdir()
193 *
194 * Create a unique temporary directory and chdir() to it. It expects the caller
195 * to have defined/initialized the TCID/TST_TOTAL global variables.
196 * The TESTDIR global variable will be set to the directory that gets used
197 * as the testing directory.
198 *
199 * NOTE: This function must be called BEFORE any activity that would require
200 * CLEANUP. If tst_tmpdir() fails, it cleans up afer itself and calls
201 * tst_exit() (i.e. does not return).
202 */
subrata_modak88c166c2009-06-09 16:01:20 +0000203void tst_tmpdir(void);
Marios Makris60b1baa2012-08-09 20:36:46 +0300204/* tst_rmdir()
205 *
206 * Recursively remove the temporary directory created by tst_tmpdir().
207 * This function is intended ONLY as a companion to tst_tmpdir().
Marios Makris60b1baa2012-08-09 20:36:46 +0300208 */
subrata_modak88c166c2009-06-09 16:01:20 +0000209void tst_rmdir(void);
Cyril Hrubis9c31ad22014-05-14 17:15:39 +0200210/* tst_get_tmpdir()
Marios Makris60b1baa2012-08-09 20:36:46 +0300211 *
212 * Return a copy of the test temp directory as seen by LTP. This is for
213 * path-oriented tests like chroot, etc, that may munge the path a bit.
214 *
215 * FREE VARIABLE AFTER USE IF IT IS REUSED!
216 */
Cyril Hrubis9c31ad22014-05-14 17:15:39 +0200217char *tst_get_tmpdir(void);
Cyril Hrubisab8388c2012-11-28 15:42:17 +0100218/*
219 * Returns 1 if temp directory was created.
220 */
221int tst_tmpdir_created(void);
alaffincc2e5552000-07-27 17:13:18 +0000222
Garrett Cooperaec33cd2010-12-17 04:14:16 -0800223/* lib/get_high_address.c */
subrata_modak88c166c2009-06-09 16:01:20 +0000224char *get_high_address(void);
robbiewf3a83d52002-05-28 16:26:16 +0000225
Garrett Cooperaec33cd2010-12-17 04:14:16 -0800226/* lib/tst_kvercmp.c */
subrata_modak88c166c2009-06-09 16:01:20 +0000227void tst_getkver(int *k1, int *k2, int *k3);
228int tst_kvercmp(int r1, int r2, int r3);
robbiew143090a2005-01-17 22:10:09 +0000229
Wanlong Gaoef73cc92013-07-09 15:54:51 +0800230struct tst_kern_exv {
231 char *dist_name;
232 char *extra_ver;
233};
234
235int tst_kvercmp2(int r1, int r2, int r3, struct tst_kern_exv *vers);
236
Xiaoguang Wang46941672014-04-25 10:02:07 +0800237enum {
238 TST_BYTES = 1,
239 TST_KB = 1024,
240 TST_MB = 1048576,
241 TST_GB = 1073741824,
242};
243
244/* lib/tst_fs_has_free.c
245 *
246 * @path: path is the pathname of any file within the mounted file system
247 * @mult: mult should be TST_KB, TST_MB or TST_GB
248 * the required free space is calculated by @size * @mult
249 */
250int tst_fs_has_free(void (*cleanup)(void), const char *path,
251 unsigned int size, unsigned int mult);
subrata_modak88c166c2009-06-09 16:01:20 +0000252
Jan Stancek11a84a62013-10-17 12:44:49 +0200253int tst_is_virt(int virt_type);
254
Garrett Cooperaec33cd2010-12-17 04:14:16 -0800255/* lib/self_exec.c */
Mike Frysinger55d8ae52014-02-13 04:11:45 -0500256void maybe_run_child(void (*child)(), const char *fmt, ...);
257int self_exec(const char *argv0, const char *fmt, ...);
subrata_modak744305e2008-08-19 07:00:49 +0000258
Garrett Cooperaec33cd2010-12-17 04:14:16 -0800259/* Functions from lib/cloner.c */
Zeng Linggang1db62662014-01-09 20:10:11 +0800260int ltp_clone(unsigned long flags, int (*fn)(void *arg), void *arg,
261 size_t stack_size, void *stack);
262int ltp_clone7(unsigned long flags, int (*fn)(void *arg), void *arg,
zenglg.jy5f5cb632013-12-18 17:29:51 +0800263 size_t stack_size, void *stack, ...);
vapierf6d7f092009-11-03 20:07:35 +0000264int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg),
265 void *arg, size_t stacksize);
266int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
267 void *arg);
268#define clone(...) use_the_ltp_clone_functions,do_not_use_clone
269
Garrett Cooperaec33cd2010-12-17 04:14:16 -0800270/* Function from lib/get_path.c */
Subrata Modakca758b72010-05-18 01:28:14 +0530271int tst_get_path(const char *prog_name, char *buf, size_t buf_len);
272
Wanlong Gao3b535a82012-10-18 16:35:14 +0800273/* lib/tst_cpu.c */
274long tst_ncpus(void);
Zeng Linggangda642ba2014-09-10 13:25:57 +0800275long tst_ncpus_conf(void);
Wanlong Gao3b535a82012-10-18 16:35:14 +0800276long tst_ncpus_max(void);
277
Alexey Kodanev4bc55ec2013-06-27 18:52:22 +0400278/* lib/tst_run_cmd.c
279 *
280 * vfork() + execvp() specified program.
281 * @argv: a list of two (at least program name + NULL) or more pointers that
282 * represent the argument list to the new program. The array of pointers
283 * must be terminated by a NULL pointer.
Stanislav kholmanskikhbee0a942013-08-06 16:54:37 +0400284 * @stdout_fd: file descriptor where to redirect stdout. Set -1 if
285 * redirection is not needed.
286 * @stderr_fd: file descriptor where to redirect stderr. Set -1 if
287 * redirection is not needed.
Stanislav Kholmanskikha648a4d2015-01-26 13:15:32 +0300288 * @pass_exit_val: if it's non-zero, this function will return the program
289 * exit code, otherwise it will call cleanup_fn() if the program
290 * exit code is not zero.
Alexey Kodanev4bc55ec2013-06-27 18:52:22 +0400291 */
Stanislav Kholmanskikha648a4d2015-01-26 13:15:32 +0300292int tst_run_cmd_fds(void (cleanup_fn)(void),
Stanislav Kholmanskikhe63337a2013-08-08 11:18:06 +0400293 const char *const argv[],
Stanislav kholmanskikhbee0a942013-08-06 16:54:37 +0400294 int stdout_fd,
Stanislav Kholmanskikha648a4d2015-01-26 13:15:32 +0300295 int stderr_fd,
296 int pass_exit_val);
Stanislav kholmanskikhbee0a942013-08-06 16:54:37 +0400297
298/* Executes tst_run_cmd_fds() and redirects its output to a file
299 * @stdout_path: path where to redirect stdout. Set NULL if redirection is
300 * not needed.
301 * @stderr_path: path where to redirect stderr. Set NULL if redirection is
302 * not needed.
Stanislav Kholmanskikha648a4d2015-01-26 13:15:32 +0300303 * @pass_exit_val: if it's non-zero, this function will return the program
304 * exit code, otherwise it will call cleanup_fn() if the program
305 * exit code is not zero.
Stanislav kholmanskikhbee0a942013-08-06 16:54:37 +0400306 */
Stanislav Kholmanskikha648a4d2015-01-26 13:15:32 +0300307int tst_run_cmd(void (cleanup_fn)(void),
Stanislav Kholmanskikhe63337a2013-08-08 11:18:06 +0400308 const char *const argv[],
Stanislav kholmanskikhbee0a942013-08-06 16:54:37 +0400309 const char *stdout_path,
Stanislav Kholmanskikha648a4d2015-01-26 13:15:32 +0300310 const char *stderr_path,
311 int pass_exit_val);
Alexey Kodanev4bc55ec2013-06-27 18:52:22 +0400312
George Wanga83cbb82014-12-18 22:02:14 +0800313/* Wrapper function for system(3), ignorcing SIGCLD signal.
314 * @command: the command to be run.
315 */
316int tst_system(const char *command);
317
Cyril Hrubis2492ce22013-08-08 14:24:38 +0200318/* lib/tst_mkfs.c
319 *
320 * @dev: path to a device
321 * @fs_type: filesystem type
Xiaoguang Wang35266852014-03-26 17:23:45 +0800322 * @fs_opts: NULL or NULL terminated array of extra mkfs options
Cyril Hrubis2492ce22013-08-08 14:24:38 +0200323 */
324void tst_mkfs(void (cleanup_fn)(void), const char *dev,
Xiaoguang Wang35266852014-03-26 17:23:45 +0800325 const char *fs_type, const char *const fs_opts[]);
Cyril Hrubis2492ce22013-08-08 14:24:38 +0200326
Cyril Hrubise6c24c12014-06-19 12:46:45 +0200327/*
328 * Returns filesystem type to be used for the testing. Unless your test is
329 * designed for specific filesystem you should use this function to the tested
330 * filesytem.
331 *
332 * If TST_DEV_FS_TYPE is set the function returns it's content,
333 * otherwise default fs type hardcoded in the library is returned.
334 */
335const char *tst_dev_fs_type(void);
336
Cyril Hrubis85e787e2014-06-18 17:09:21 +0200337/* lib/tst_device.c
338 *
339 * Acquires test device.
340 *
341 * Can be used only once, i.e. you cannot get two different devices.
342 *
343 * Looks for LTP_DEV env variable first (which may be passed by the test
344 * driver or by a user) and returns just it's value if found.
345 *
346 * Otherwise creates a temp file and loop device.
347 *
348 * Note that you have to call tst_tmpdir() beforehand.
349 *
350 * Returns path to the device or NULL if it cannot be created.
351 */
352const char *tst_acquire_device(void (cleanup_fn)(void));
353
354/* lib/tst_device.c
355 * @dev: device path returned by the tst_acquire_device()
356 */
357void tst_release_device(void (cleanup_fn)(void), const char *dev);
358
Cyril Hrubis420add22015-01-29 16:00:10 +0100359/* lib/tst_device.c
360 *
361 * Just like umount() but retries several times on failure.
362 * @path: Path to umount
363 */
364int tst_umount(const char *path);
365
Stanislav Kholmanskikh1d5d4842013-08-14 10:01:46 +0400366/* lib/tst_fill_file.c
367 *
368 * Creates/ovewrites a file with specified pattern
369 * @path: path to file
370 * @pattern: pattern
371 * @bs: block size
372 * @bcount: blocks amount
373 */
374int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount);
375
Jan Stanceke77bf552014-03-07 10:08:30 +0100376/* lib/tst_net.c
377 *
378 * Return unused port
379 */
380unsigned short tst_get_unused_port(void (cleanup_fn)(void),
381 unsigned short family, int type);
382
Xiaoguang Wang1a6f68a2014-05-13 19:02:59 +0800383/* lib/tst_res.c
384 * tst_strsig converts signal's value to corresponding string.
385 * tst_strerrno converts errno to corresponding string.
386 */
387const char *tst_strsig(int sig);
388const char *tst_strerrno(int err);
389
gux.fnst@cn.fujitsu.com2db57392014-05-08 17:50:51 +0800390/* lib/tst_path_has_mnt_flags.c
391 *
392 * Check whether a path is on a filesystem that is mounted with
393 * specified flags
Cyril Hrubis78fe6422014-05-14 16:53:04 +0200394 * @path: path to file, if path is NULL tst_tmpdir is used.
gux.fnst@cn.fujitsu.com2db57392014-05-08 17:50:51 +0800395 * @flags: NULL or NULL terminated array of mount flags
396 *
397 * Return: 0..n - number of flags matched
398 */
399int tst_path_has_mnt_flags(void (cleanup_fn)(void),
400 const char *path, const char *flags[]);
401
Xiaoguang Wang3db20822014-06-09 15:37:10 +0800402/*
403 * lib/tst_fs_link_count.c
404 *
405 * Try to get maximum number of hard links to a regular file inside the @dir.
406 *
407 * Note: This number depends on the filesystem @dir is on.
408 *
409 * The code uses link(2) to create hard links to a single file until it gets
410 * EMLINK or creates 65535 links.
411 *
412 * If limit is hit maximal number of hardlinks is returned and the the @dir is
413 * filled with hardlinks in format "testfile%i" where i belongs to [0, limit)
414 * interval.
415 *
416 * If no limit is hit (succed to create 65535 without error) or if link()
417 * failed with ENOSPC or EDQUOT zero is returned previously created files are
418 * removed.
419 */
420int tst_fs_fill_hardlinks(void (*cleanup) (void), const char *dir);
421
422/*
423 * lib/tst_fs_link_count.c
424 *
425 * Try to get maximum number of subdirectories in directory.
426 *
427 * Note: This number depends on the filesystem @dir is on.
428 *
429 * The code uses mkdir(2) to create directories in @dir until it gets EMLINK
430 * or creates 65535 directories.
431 *
432 * If limit is hit the maximal number of subdirectories is returned and the
433 * @dir is filled with subdirectories in format "testdir%i" where i belongs to
434 * [0, limit - 2) interval (because each newly created dir has two links
435 * allready the '.' and link from parent dir).
436 *
437 * If no limit is hit or mkdir() failed with ENOSPC or EDQUOT zero is returned
438 * previously created directories are removed.
439 *
440 */
441int tst_fs_fill_subdirs(void (*cleanup) (void), const char *dir);
442
Stanislav Kholmanskikh07a10332014-06-30 14:48:22 +0400443/*
444 * lib/tst_pid.c
445 *
Stanislav Kholmanskikh502e42f2014-06-30 14:48:23 +0400446 * Get a pid value not used by the OS
Stanislav Kholmanskikh07a10332014-06-30 14:48:22 +0400447 */
Stanislav Kholmanskikh502e42f2014-06-30 14:48:23 +0400448pid_t tst_get_unused_pid(void (*cleanup_fn) (void));
Stanislav Kholmanskikh07a10332014-06-30 14:48:22 +0400449
450/*
451 * lib/tst_pid.c
452 *
Stanislav Kholmanskikh502e42f2014-06-30 14:48:23 +0400453 * Returns number of free pids by substarction of the number of pids
Stanislav Kholmanskikh07a10332014-06-30 14:48:22 +0400454 * currently used ('ps -eT') from max_pids
455 */
Stanislav Kholmanskikh502e42f2014-06-30 14:48:23 +0400456int tst_get_free_pids(void (*cleanup_fn) (void));
Stanislav Kholmanskikh07a10332014-06-30 14:48:22 +0400457
subrata_modak744305e2008-08-19 07:00:49 +0000458#ifdef TST_USE_COMPAT16_SYSCALL
459#define TCID_BIT_SUFFIX "_16"
460#elif TST_USE_NEWER64_SYSCALL
461#define TCID_BIT_SUFFIX "_64"
462#else
463#define TCID_BIT_SUFFIX ""
464#endif
subrata_modak88c166c2009-06-09 16:01:20 +0000465#define TCID_DEFINE(ID) char *TCID = (#ID TCID_BIT_SUFFIX)
subrata_modak744305e2008-08-19 07:00:49 +0000466
subrata_modak88c166c2009-06-09 16:01:20 +0000467#endif /* __TEST_H__ */