summaryrefslogtreecommitdiffstats
path: root/src/kernel/tests/include/old
diff options
context:
space:
mode:
authorManuel Bentele2020-10-23 15:18:01 +0200
committerManuel Bentele2020-10-23 15:18:01 +0200
commitdbb41ce2b7f309d394054a6bd1e33afd578798a5 (patch)
tree6a31092063d9f2fb5ac5720ec6759040e793c3d5 /src/kernel/tests/include/old
parentSet Linux kernel version to unknown if it is not detectable (diff)
downloadxloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.gz
xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.xz
xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.zip
Move the source code of all xloop components to the common 'src' directory
Diffstat (limited to 'src/kernel/tests/include/old')
-rw-r--r--src/kernel/tests/include/old/cleanup.c47
-rw-r--r--src/kernel/tests/include/old/ltp_cpuid.h35
-rw-r--r--src/kernel/tests/include/old/ltp_priv.h74
-rw-r--r--src/kernel/tests/include/old/ltp_signal.h56
-rw-r--r--src/kernel/tests/include/old/old_checkpoint.h59
-rw-r--r--src/kernel/tests/include/old/old_device.h84
-rw-r--r--src/kernel/tests/include/old/old_module.h72
-rw-r--r--src/kernel/tests/include/old/old_resource.h55
-rw-r--r--src/kernel/tests/include/old/old_safe_file_ops.h64
-rw-r--r--src/kernel/tests/include/old/old_safe_net.h50
-rw-r--r--src/kernel/tests/include/old/old_safe_stdio.h37
-rw-r--r--src/kernel/tests/include/old/old_tmpdir.h56
-rw-r--r--src/kernel/tests/include/old/random_range.h45
-rw-r--r--src/kernel/tests/include/old/safe_macros.h340
-rw-r--r--src/kernel/tests/include/old/test.h214
-rw-r--r--src/kernel/tests/include/old/tlibio.h161
-rw-r--r--src/kernel/tests/include/old/usctest.h105
17 files changed, 1554 insertions, 0 deletions
diff --git a/src/kernel/tests/include/old/cleanup.c b/src/kernel/tests/include/old/cleanup.c
new file mode 100644
index 0000000..040dff8
--- /dev/null
+++ b/src/kernel/tests/include/old/cleanup.c
@@ -0,0 +1,47 @@
+/*
+ * Default cleanup logic because linux_syscall_numbers.h's need for cleanup
+ * and binutils bugs suck.
+ *
+ * Copyright (c) 2009 Cisco Systems, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like. Any license provided herein, whether implied or
+ * otherwise, applies only to this software file. Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#ifndef __CLEANUP_C__
+#define __CLEANUP_C__
+
+/* Did the user define a cleanup function? */
+#ifndef CLEANUP
+#define USING_DUMMY_CLEANUP 1
+#define CLEANUP dummy_cleanup
+#endif
+
+/* A freebie for defining the function prototype. */
+static void CLEANUP(void) __attribute__ ((unused));
+
+#ifdef USING_DUMMY_CLEANUP
+/* The stub function. Wewt.. */
+static void dummy_cleanup(void)
+{
+}
+#endif
+
+#endif
diff --git a/src/kernel/tests/include/old/ltp_cpuid.h b/src/kernel/tests/include/old/ltp_cpuid.h
new file mode 100644
index 0000000..6bd5537
--- /dev/null
+++ b/src/kernel/tests/include/old/ltp_cpuid.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012-2013 The Chromium OS Authors. All rights reserved.
+ *
+ * Licensed under the BSD 3-clause.
+ */
+
+#ifndef __LTP_CPUID_H__
+#define __LTP_CPUID_H__
+
+static inline void cpuid(unsigned int info, unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+{
+#if defined(__i386__) || defined(__x86_64__)
+ unsigned int _eax = info, _ebx, _ecx, _edx;
+ asm volatile(
+# ifdef __i386__
+ "xchg %%ebx, %%esi;" /* save ebx (for PIC) */
+ "cpuid;"
+ "xchg %%esi, %%ebx;" /* restore ebx & pass to caller */
+ : "=S" (_ebx),
+# else
+ "cpuid;"
+ : "=b" (_ebx),
+# endif
+ "+a" (_eax), "=c" (_ecx), "=d" (_edx)
+ : /* inputs: eax is handled above */
+ );
+ if (eax) *eax = _eax;
+ if (ebx) *ebx = _ebx;
+ if (ecx) *ecx = _ecx;
+ if (edx) *edx = _edx;
+#endif
+}
+
+#endif
diff --git a/src/kernel/tests/include/old/ltp_priv.h b/src/kernel/tests/include/old/ltp_priv.h
new file mode 100644
index 0000000..0552457
--- /dev/null
+++ b/src/kernel/tests/include/old/ltp_priv.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013 Cyril Hrubis chrubis@suse.cz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LTP_PRIV_H__
+#define __LTP_PRIV_H__
+
+#include <stdarg.h>
+
+/*
+ * This is the default temporary directory used by tst_tmpdir().
+ *
+ * This is used when TMPDIR env variable is not set.
+ */
+#define TEMPDIR "/tmp"
+
+/*
+ * Default filesystem to be used for tests.
+ */
+#define DEFAULT_FS_TYPE "ext2"
+
+/* environment variables for controlling tst_res verbosity */
+#define TOUT_VERBOSE_S "VERBOSE" /* All test cases reported */
+#define TOUT_NOPASS_S "NOPASS" /* No pass test cases are reported */
+#define TOUT_DISCARD_S "DISCARD" /* No output is reported */
+
+#define USC_ITERATION_ENV "USC_ITERATIONS"
+#define USC_LOOP_WALLTIME "USC_LOOP_WALLTIME"
+#define USC_NO_FUNC_CHECK "USC_NO_FUNC_CHECK"
+#define USC_LOOP_DELAY "USC_LOOP_DELAY"
+
+const char *parse_opts(int ac, char **av, const option_t *user_optarr, void
+ (*uhf)(void));
+
+/* Interface for rerouting to new lib calls from tst_res.c */
+extern void *tst_test;
+
+void tst_vbrk_(const char *file, const int lineno, int ttype,
+ const char *fmt, va_list va) __attribute__((noreturn));
+
+void tst_brk_(const char *file, const int lineno, int ttype,
+ const char *msg, ...);
+
+void tst_vres_(const char *file, const int lineno, int ttype,
+ const char *fmt, va_list va);
+
+void tst_res_(const char *file, const int lineno, int ttype,
+ const char *msg, ...);
+
+
+#define NO_NEWLIB_ASSERT(file, lineno) \
+ if (tst_test) { \
+ tst_brk_(file, lineno, TBROK, \
+ "%s() executed from newlib!", __FUNCTION__); \
+ }
+
+#endif /* __LTP_PRIV_H__ */
diff --git a/src/kernel/tests/include/old/ltp_signal.h b/src/kernel/tests/include/old/ltp_signal.h
new file mode 100644
index 0000000..02ee834
--- /dev/null
+++ b/src/kernel/tests/include/old/ltp_signal.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2009 Cisco Systems, Inc. All Rights Reserved.
+ * Copyright (c) 2009 FUJITSU LIMITED. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like. Any license provided herein, whether implied or
+ * otherwise, applies only to this software file. Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Author: Liu Bo <liubo2009@cn.fujitsu.com>
+ * Author: Ngie Cooper <yaneurabeya@gmail.com>
+ *
+ */
+
+#ifndef __LTP_SIGNAL_H
+#define __LTP_SIGNAL_H
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include "config.h"
+
+/*
+ * For all but __mips__:
+ *
+ * _COMPAT_NSIG / _COMPAT_NSIG_BPW == 2.
+ *
+ * For __mips__:
+ *
+ * _COMPAT_NSIG / _COMPAT_NSIG_BPW == 4.
+ *
+ * See asm/compat.h under the kernel source for more details.
+ *
+ * Multiply that by a fudge factor of 4 and you have your SIGSETSIZE.
+ */
+#if defined __mips__
+#define SIGSETSIZE 16
+#else
+#define SIGSETSIZE (_NSIG / 8)
+#endif
+
+#endif
diff --git a/src/kernel/tests/include/old/old_checkpoint.h b/src/kernel/tests/include/old/old_checkpoint.h
new file mode 100644
index 0000000..c8ffc92
--- /dev/null
+++ b/src/kernel/tests/include/old/old_checkpoint.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015-2016 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ /*
+
+ Checkpoint - easy to use parent-child synchronization.
+
+ Checkpoint is based on futexes (man futex). The library allocates a page of
+ shared memory for futexes and the id is an offset to it which gives the user
+ up to page_size/sizeof(uint32_t) checkpoint pairs. Up to INT_MAX processes
+ can sleep on single id and can be woken up by single wake.
+
+ */
+
+#ifndef OLD_CHECKPOINT__
+#define OLD_CHECKPOINT__
+
+#include "test.h"
+#include "tst_checkpoint_fn.h"
+
+/*
+ * Checkpoint initializaton, must be done first.
+ *
+ * NOTE: tst_tmpdir() must be called beforehand.
+ */
+#define TST_CHECKPOINT_INIT(cleanup_fn) \
+ tst_checkpoint_init(__FILE__, __LINE__, cleanup_fn)
+
+#define TST_SAFE_CHECKPOINT_WAIT(cleanup_fn, id) \
+ tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id, 0);
+
+#define TST_SAFE_CHECKPOINT_WAIT2(cleanup_fn, id, msec_timeout) \
+ tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id, msec_timeout);
+
+#define TST_SAFE_CHECKPOINT_WAKE(cleanup_fn, id) \
+ tst_safe_checkpoint_wake(__FILE__, __LINE__, cleanup_fn, id, 1);
+
+#define TST_SAFE_CHECKPOINT_WAKE2(cleanup_fn, id, nr_wake) \
+ tst_safe_checkpoint_wake(__FILE__, __LINE__, cleanup_fn, id, nr_wake);
+
+#define TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(cleanup_fn, id) \
+ tst_safe_checkpoint_wake(__FILE__, __LINE__, cleanup_fn, id, 1); \
+ tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id, 0);
+
+#endif /* OLD_CHECKPOINT__ */
diff --git a/src/kernel/tests/include/old/old_device.h b/src/kernel/tests/include/old/old_device.h
new file mode 100644
index 0000000..a6e9fea
--- /dev/null
+++ b/src/kernel/tests/include/old/old_device.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2014-2016 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef OLD_DEVICE_H__
+#define OLD_DEVICE_H__
+
+/*
+ * Returns filesystem type to be used for the testing. Unless your test is
+ * designed for specific filesystem you should use this function to the tested
+ * filesystem.
+ *
+ * If TST_DEV_FS_TYPE is set the function returns it's content,
+ * otherwise default fs type hardcoded in the library is returned.
+ */
+const char *tst_dev_fs_type(void);
+
+/*
+ * Acquires test device.
+ *
+ * Can be used only once, i.e. you cannot get two different devices.
+ *
+ * Looks for LTP_DEV env variable first (which may be passed by the test
+ * driver or by a user) and returns just it's value if found.
+ *
+ * Otherwise creates a temp file and loop device.
+ *
+ * Note that you have to call tst_tmpdir() beforehand.
+ *
+ * Returns path to the device or NULL if it cannot be created.
+ * Call tst_release_device() when you're done.
+ */
+const char *tst_acquire_device_(void (cleanup_fn)(void), unsigned int size);
+
+const char *tst_acquire_device__(unsigned int size);
+
+static inline const char *tst_acquire_device(void (cleanup_fn)(void))
+{
+ return tst_acquire_device_(cleanup_fn, 0);
+}
+
+/*
+ * Acquire a loop device with specified temp filename. This function allows
+ * you to acquire multiple devices at the same time. LTP_DEV is ignored.
+ * If you call this function directly, use tst_detach_device() to release
+ * the devices. tst_release_device() will not work correctly.
+ *
+ * The return value points to a static buffer and additional calls of
+ * tst_acquire_loop_device() or tst_acquire_device() will overwrite it.
+ */
+const char *tst_acquire_loop_device(unsigned int size, const char *filename);
+
+/*
+ * @dev: device path returned by the tst_acquire_device()
+ */
+int tst_release_device(const char *dev);
+
+/*
+ * Cleanup function for tst_acquire_loop_device(). If you have acquired
+ * a device using tst_acquire_device(), use tst_release_device() instead.
+ * @dev: device path returned by the tst_acquire_loop_device()
+ */
+int tst_detach_device(const char *dev);
+
+/*
+ * Just like umount() but retries several times on failure.
+ * @path: Path to umount
+ */
+int tst_umount(const char *path);
+
+#endif /* OLD_DEVICE_H__ */
diff --git a/src/kernel/tests/include/old/old_module.h b/src/kernel/tests/include/old/old_module.h
new file mode 100644
index 0000000..c50efec
--- /dev/null
+++ b/src/kernel/tests/include/old/old_module.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Alexey Kodanev <alexey.kodanev@oracle.com>
+ *
+ * These functions help to load and unload kernel modules in the tests.
+ *
+ * tst_module_load function already includes tst_module_exists function,
+ * which is checking the following possible module's locations:
+ *
+ * 1. Current working directory
+ *
+ * 2. LTP installation path (using env LTPROOT, which is usually /opt/ltp)
+ *
+ * 3. If tmp directory created, it'll look at the test start working directory
+ *
+ */
+
+#ifndef TST_MODULE
+#define TST_MODULE
+
+/*
+ * Check module existence.
+ *
+ * @mod_name: module's file name.
+ * @mod_path: if it is not NULL, then tst_module_exists places the found
+ * module's path into the location pointed to by *mod_path. It must be freed
+ * with free() when it is no longer needed.
+ *
+ * In case of failure, test'll call cleanup_fn and exit with TCONF return value.
+ */
+void tst_module_exist(void (cleanup_fn)(void), const char *mod_name,
+ char **mod_path);
+
+/*
+ * Load a module using insmod program.
+ *
+ * @mod_name: module's file name.
+ * @argv: an array of pointers to null-terminated strings that represent the
+ * additional parameters to the module. The array of pointers must be
+ * terminated by a NULL pointer. If argv points to NULL, it will be ignored.
+ *
+ * In case of insmod failure, test will call cleanup_fn and exit with TBROK
+ * return value.
+ */
+void tst_module_load(void (cleanup_fn)(void),
+ const char *mod_name, char *const argv[]);
+
+/*
+ * Unload a module using rmmod program. In case of failure, test will call
+ * cleanup_fn and exit with TBROK return value.
+ *
+ * @mod_name: can be module name or module's file name.
+ */
+void tst_module_unload(void (cleanup_fn)(void), const char *mod_name);
+
+#endif /* TST_MODULE */
diff --git a/src/kernel/tests/include/old/old_resource.h b/src/kernel/tests/include/old/old_resource.h
new file mode 100644
index 0000000..46767f3
--- /dev/null
+++ b/src/kernel/tests/include/old/old_resource.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 Cyril Hrubis chrubis@suse.cz
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like. Any license provided herein, whether implied or
+ * otherwise, applies only to this software file. Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+ /*
+
+ Small helper for preparing files the test needs to copy before the testing.
+
+ We need to support two scenarios.
+
+ 1. Test is executed in local directory and this is also the place
+ we should look for files
+
+
+ 2. Test is executed after LTP has been installed, in this case we
+ look for env LTPROOT (usually /opt/ltp/)
+
+ */
+
+#ifndef TST_RESOURCE
+#define TST_RESOURCE
+
+const char *tst_dataroot(void);
+
+/*
+ * Copy a file to the CWD. The destination is apended to CWD.
+ */
+#define TST_RESOURCE_COPY(cleanup_fn, filename, dest) \
+ tst_resource_copy(__FILE__, __LINE__, (cleanup_fn), \
+ (filename), (dest))
+
+void tst_resource_copy(const char *file, const int lineno,
+ void (*cleanup_fn)(void),
+ const char *filename, const char *dest);
+
+#endif /* TST_RESOURCE */
diff --git a/src/kernel/tests/include/old/old_safe_file_ops.h b/src/kernel/tests/include/old/old_safe_file_ops.h
new file mode 100644
index 0000000..d6e2d29
--- /dev/null
+++ b/src/kernel/tests/include/old/old_safe_file_ops.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012-2016 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ /*
+
+ This code helps with file reading/writing files providing scanf/printf like
+ interface that opens and closes the file automatically.
+
+ This kind of interface is especially useful for reading/writing values
+ from/to pseudo filesystems like procfs or sysfs.
+
+ */
+
+#ifndef SAFE_FILE_OPS
+#define SAFE_FILE_OPS
+
+#include "safe_file_ops_fn.h"
+
+#define FILE_SCANF(path, fmt, ...) \
+ file_scanf(__FILE__, __LINE__, \
+ (path), (fmt), ## __VA_ARGS__)
+
+#define SAFE_FILE_SCANF(cleanup_fn, path, fmt, ...) \
+ safe_file_scanf(__FILE__, __LINE__, (cleanup_fn), \
+ (path), (fmt), ## __VA_ARGS__)
+
+#define FILE_LINES_SCANF(cleanup_fn, path, fmt, ...) \
+ file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 0, \
+ (path), (fmt), ## __VA_ARGS__)
+
+#define SAFE_FILE_LINES_SCANF(cleanup_fn, path, fmt, ...) \
+ file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 1, \
+ (path), (fmt), ## __VA_ARGS__)
+
+#define FILE_PRINTF(path, fmt, ...) \
+ file_printf(__FILE__, __LINE__, \
+ (path), (fmt), ## __VA_ARGS__)
+
+#define SAFE_FILE_PRINTF(cleanup_fn, path, fmt, ...) \
+ safe_file_printf(__FILE__, __LINE__, (cleanup_fn), \
+ (path), (fmt), ## __VA_ARGS__)
+
+#define SAFE_CP(cleanup_fn, src, dst) \
+ safe_cp(__FILE__, __LINE__, (cleanup_fn), (src), (dst))
+
+#define SAFE_TOUCH(cleanup_fn, pathname, mode, times) \
+ safe_touch(__FILE__, __LINE__, (cleanup_fn), \
+ (pathname), (mode), (times))
+
+#endif /* SAFE_FILE_OPS */
diff --git a/src/kernel/tests/include/old/old_safe_net.h b/src/kernel/tests/include/old/old_safe_net.h
new file mode 100644
index 0000000..639094a
--- /dev/null
+++ b/src/kernel/tests/include/old/old_safe_net.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015 Fujitsu Ltd.
+ * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef OLD_SAFE_NET_H__
+#define OLD_SAFE_NET_H__
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/un.h>
+
+#include "safe_net_fn.h"
+
+#define SAFE_SOCKET(cleanup_fn, domain, type, protocol) \
+ safe_socket(__FILE__, __LINE__, (cleanup_fn), domain, type, protocol)
+
+#define SAFE_BIND(cleanup_fn, socket, address, address_len) \
+ safe_bind(__FILE__, __LINE__, (cleanup_fn), socket, address, \
+ address_len)
+
+#define SAFE_LISTEN(cleanup_fn, socket, backlog) \
+ safe_listen(__FILE__, __LINE__, (cleanup_fn), socket, backlog)
+
+#define SAFE_CONNECT(cleanup_fn, sockfd, addr, addrlen) \
+ safe_connect(__FILE__, __LINE__, (cleanup_fn), sockfd, addr, addrlen)
+
+#define SAFE_GETSOCKNAME(cleanup_fn, sockfd, addr, addrlen) \
+ safe_getsockname(__FILE__, __LINE__, (cleanup_fn), sockfd, addr, \
+ addrlen)
+
+#define TST_GET_UNUSED_PORT(cleanup_fn, family, type) \
+ tst_get_unused_port(__FILE__, __LINE__, (cleanup_fn), family, type)
+
+#endif /* OLD_SAFE_NET_H__ */
diff --git a/src/kernel/tests/include/old/old_safe_stdio.h b/src/kernel/tests/include/old/old_safe_stdio.h
new file mode 100644
index 0000000..3508b24
--- /dev/null
+++ b/src/kernel/tests/include/old/old_safe_stdio.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013-2016 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef OLD_SAFE_STDIO_H__
+#define OLD_SAFE_STDIO_H__
+
+#include <stdio.h>
+
+#include "safe_stdio_fn.h"
+
+#define SAFE_FOPEN(cleanup_fn, path, mode) \
+ safe_fopen(__FILE__, __LINE__, cleanup_fn, path, mode)
+
+#define SAFE_FCLOSE(cleanup_fn, f) \
+ safe_fclose(__FILE__, __LINE__, cleanup_fn, f)
+
+#define SAFE_ASPRINTF(cleanup_fn, strp, fmt, ...) \
+ safe_asprintf(__FILE__, __LINE__, cleanup_fn, strp, fmt, __VA_ARGS__)
+
+#define SAFE_POPEN(cleanup_fn, command, type) \
+ safe_popen(__FILE__, __LINE__, cleanup_fn, command, type)
+
+#endif /* OLD_SAFE_STDIO_H__ */
diff --git a/src/kernel/tests/include/old/old_tmpdir.h b/src/kernel/tests/include/old/old_tmpdir.h
new file mode 100644
index 0000000..9c61172
--- /dev/null
+++ b/src/kernel/tests/include/old/old_tmpdir.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef OLD_TMPDIR_H__
+#define OLD_TMPDIR_H__
+
+/*
+ * Create a unique temporary directory and chdir() to it. It expects the caller
+ * to have defined/initialized the TCID/TST_TOTAL global variables.
+ * The TESTDIR global variable will be set to the directory that gets used
+ * as the testing directory.
+ *
+ * NOTE: This function must be called BEFORE any activity that would require
+ * CLEANUP. If tst_tmpdir() fails, it cleans up afer itself and calls
+ * tst_exit() (i.e. does not return).
+ */
+void tst_tmpdir(void);
+
+/*
+ * Recursively remove the temporary directory created by tst_tmpdir().
+ * This function is intended ONLY as a companion to tst_tmpdir().
+ */
+void tst_rmdir(void);
+
+/* tst_get_tmpdir()
+ *
+ * Return a copy of the test temp directory as seen by LTP. This is for
+ * path-oriented tests like chroot, etc, that may munge the path a bit.
+ *
+ * FREE VARIABLE AFTER USE IF IT IS REUSED!
+ */
+char *tst_get_tmpdir(void);
+
+/*
+ * Returns 1 if temp directory was created.
+ */
+int tst_tmpdir_created(void);
+
+/* declared in tst_tmpdir.c */
+const char *tst_get_startwd(void);
+
+#endif /* OLD_TMPDIR_H__ */
diff --git a/src/kernel/tests/include/old/random_range.h b/src/kernel/tests/include/old/random_range.h
new file mode 100644
index 0000000..22b3f93
--- /dev/null
+++ b/src/kernel/tests/include/old/random_range.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like. Any license provided herein, whether implied or
+ * otherwise, applies only to this software file. Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+ * Mountain View, CA 94043, or:
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
+ * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
+ */
+#ifndef _RANDOM_RANGE_H_
+#define _RANDOM_RANGE_H_
+
+int parse_ranges ( char *, int, int, int, int (*)(), char **, char ** );
+int range_min ( char *, int );
+int range_max ( char *, int );
+int range_mult ( char *, int );
+long random_range ( int, int, int, char ** );
+long random_rangel ( long, long, long, char ** );
+long long random_rangell ( long long, long long, long long, char ** );
+void random_range_seed( long );
+long random_bit ( long );
+
+#endif
diff --git a/src/kernel/tests/include/old/safe_macros.h b/src/kernel/tests/include/old/safe_macros.h
new file mode 100644
index 0000000..e778d30
--- /dev/null
+++ b/src/kernel/tests/include/old/safe_macros.h
@@ -0,0 +1,340 @@
+/*
+ * Safe macros for commonly used syscalls to reduce code duplication in LTP
+ * testcases, and to ensure all errors are caught in said testcases as
+ * gracefully as possible.
+ *
+ * Also satiates some versions of gcc/glibc when the warn_unused_result
+ * attribute is applied to the function call.
+ *
+ * Licensed under the GPLv2.
+ */
+
+#ifndef __TEST_H__
+#error "you must include test.h before this file"
+#else
+
+#ifndef __SAFE_MACROS_H__
+#define __SAFE_MACROS_H__
+
+#include "safe_macros_fn.h"
+#include "old_safe_stdio.h"
+#include "old_safe_net.h"
+
+#define SAFE_BASENAME(cleanup_fn, path) \
+ safe_basename(__FILE__, __LINE__, (cleanup_fn), (path))
+
+#define SAFE_CHDIR(cleanup_fn, path) \
+ safe_chdir(__FILE__, __LINE__, (cleanup_fn), (path))
+
+#define SAFE_CLOSE(cleanup_fn, fd) ({ \
+ int ret = safe_close(__FILE__, __LINE__, (cleanup_fn), (fd)); \
+ fd = -1; \
+ ret; \
+ })
+
+#define SAFE_CREAT(cleanup_fn, pathname, mode) \
+ safe_creat(__FILE__, __LINE__, cleanup_fn, (pathname), (mode))
+
+#define SAFE_DIRNAME(cleanup_fn, path) \
+ safe_dirname(__FILE__, __LINE__, (cleanup_fn), (path))
+
+#define SAFE_GETCWD(cleanup_fn, buf, size) \
+ safe_getcwd(__FILE__, __LINE__, (cleanup_fn), (buf), (size))
+
+#define SAFE_GETPWNAM(cleanup_fn, name) \
+ safe_getpwnam(__FILE__, __LINE__, cleanup_fn, (name))
+
+#define SAFE_GETRUSAGE(cleanup_fn, who, usage) \
+ safe_getrusage(__FILE__, __LINE__, (cleanup_fn), (who), (usage))
+
+#define SAFE_MALLOC(cleanup_fn, size) \
+ safe_malloc(__FILE__, __LINE__, (cleanup_fn), (size))
+
+#define SAFE_MKDIR(cleanup_fn, pathname, mode) \
+ safe_mkdir(__FILE__, __LINE__, (cleanup_fn), (pathname), (mode))
+
+#define SAFE_RMDIR(cleanup_fn, pathname) \
+ safe_rmdir(__FILE__, __LINE__, (cleanup_fn), (pathname))
+
+#define SAFE_MUNMAP(cleanup_fn, addr, length) \
+ safe_munmap(__FILE__, __LINE__, (cleanup_fn), (addr), (length))
+
+#define SAFE_OPEN(cleanup_fn, pathname, oflags, ...) \
+ safe_open(__FILE__, __LINE__, (cleanup_fn), (pathname), (oflags), \
+ ##__VA_ARGS__)
+
+#define SAFE_PIPE(cleanup_fn, fildes) \
+ safe_pipe(__FILE__, __LINE__, cleanup_fn, (fildes))
+
+#define SAFE_READ(cleanup_fn, len_strict, fildes, buf, nbyte) \
+ safe_read(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
+ (buf), (nbyte))
+
+#define SAFE_SETEGID(cleanup_fn, egid) \
+ safe_setegid(__FILE__, __LINE__, cleanup_fn, (egid))
+
+#define SAFE_SETEUID(cleanup_fn, euid) \
+ safe_seteuid(__FILE__, __LINE__, cleanup_fn, (euid))
+
+#define SAFE_SETGID(cleanup_fn, gid) \
+ safe_setgid(__FILE__, __LINE__, cleanup_fn, (gid))
+
+#define SAFE_SETUID(cleanup_fn, uid) \
+ safe_setuid(__FILE__, __LINE__, cleanup_fn, (uid))
+
+#define SAFE_GETRESUID(cleanup_fn, ruid, euid, suid) \
+ safe_getresuid(__FILE__, __LINE__, cleanup_fn, (ruid), (euid), (suid))
+
+#define SAFE_GETRESGID(cleanup_fn, rgid, egid, sgid) \
+ safe_getresgid(__FILE__, __LINE__, cleanup_fn, (rgid), (egid), (sgid))
+
+#define SAFE_UNLINK(cleanup_fn, pathname) \
+ safe_unlink(__FILE__, __LINE__, cleanup_fn, (pathname))
+
+#define SAFE_LINK(cleanup_fn, oldpath, newpath) \
+ safe_link(__FILE__, __LINE__, cleanup_fn, (oldpath), (newpath))
+
+#define SAFE_LINKAT(cleanup_fn, olddirfd, oldpath, newdirfd, newpath, flags) \
+ safe_linkat(__FILE__, __LINE__, cleanup_fn, (olddirfd), (oldpath), \
+ (newdirfd), (newpath), (flags))
+
+#define SAFE_READLINK(cleanup_fn, path, buf, bufsize) \
+ safe_readlink(__FILE__, __LINE__, cleanup_fn, (path), (buf), (bufsize))
+
+#define SAFE_SYMLINK(cleanup_fn, oldpath, newpath) \
+ safe_symlink(__FILE__, __LINE__, cleanup_fn, (oldpath), (newpath))
+
+#define SAFE_WRITE(cleanup_fn, len_strict, fildes, buf, nbyte) \
+ safe_write(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
+ (buf), (nbyte))
+
+#define SAFE_STRTOL(cleanup_fn, str, min, max) \
+ safe_strtol(__FILE__, __LINE__, cleanup_fn, (str), (min), (max))
+
+#define SAFE_STRTOUL(cleanup_fn, str, min, max) \
+ safe_strtoul(__FILE__, __LINE__, cleanup_fn, (str), (min), (max))
+
+#define SAFE_SYSCONF(cleanup_fn, name) \
+ safe_sysconf(__FILE__, __LINE__, cleanup_fn, name)
+
+#define SAFE_CHMOD(cleanup_fn, path, mode) \
+ safe_chmod(__FILE__, __LINE__, (cleanup_fn), (path), (mode))
+
+#define SAFE_FCHMOD(cleanup_fn, fd, mode) \
+ safe_fchmod(__FILE__, __LINE__, (cleanup_fn), (fd), (mode))
+
+#define SAFE_CHOWN(cleanup_fn, path, owner, group) \
+ safe_chown(__FILE__, __LINE__, (cleanup_fn), (path), (owner), (group))
+
+#define SAFE_FCHOWN(cleanup_fn, fd, owner, group) \
+ safe_fchown(__FILE__, __LINE__, (cleanup_fn), (fd), (owner), (group))
+
+#define SAFE_WAIT(cleanup_fn, status) \
+ safe_wait(__FILE__, __LINE__, (cleanup_fn), (status))
+
+#define SAFE_WAITPID(cleanup_fn, pid, status, opts) \
+ safe_waitpid(__FILE__, __LINE__, (cleanup_fn), (pid), (status), (opts))
+
+#define SAFE_KILL(cleanup_fn, pid, sig) \
+ safe_kill(__FILE__, __LINE__, (cleanup_fn), (pid), (sig))
+
+#define SAFE_MEMALIGN(cleanup_fn, alignment, size) \
+ safe_memalign(__FILE__, __LINE__, (cleanup_fn), (alignment), (size))
+
+#define SAFE_MKFIFO(cleanup_fn, pathname, mode) \
+ safe_mkfifo(__FILE__, __LINE__, (cleanup_fn), (pathname), (mode))
+
+#define SAFE_RENAME(cleanup_fn, oldpath, newpath) \
+ safe_rename(__FILE__, __LINE__, (cleanup_fn), (oldpath), (newpath))
+
+#define SAFE_MOUNT(cleanup_fn, source, target, filesystemtype, \
+ mountflags, data) \
+ safe_mount(__FILE__, __LINE__, (cleanup_fn), (source), (target), \
+ (filesystemtype), (mountflags), (data))
+
+#define SAFE_UMOUNT(cleanup_fn, target) \
+ safe_umount(__FILE__, __LINE__, (cleanup_fn), (target))
+
+/*
+ * following functions are inline because the behaviour may depend on
+ * -D_FILE_OFFSET_BITS=64 -DOFF_T=__off64_t compile flags
+ */
+
+static inline void *safe_mmap(const char *file, const int lineno,
+ void (*cleanup_fn)(void), void *addr, size_t length,
+ int prot, int flags, int fd, off_t offset)
+{
+ void *rval;
+
+ rval = mmap(addr, length, prot, flags, fd, offset);
+ if (rval == MAP_FAILED) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: mmap(%p,%zu,%d,%d,%d,%ld) failed",
+ file, lineno, addr, length, prot, flags, fd,
+ (long) offset);
+ }
+
+ return rval;
+}
+#define SAFE_MMAP(cleanup_fn, addr, length, prot, flags, fd, offset) \
+ safe_mmap(__FILE__, __LINE__, (cleanup_fn), (addr), (length), (prot), \
+ (flags), (fd), (offset))
+
+static inline int safe_ftruncate(const char *file, const int lineno,
+ void (cleanup_fn) (void), int fd, off_t length)
+{
+ int rval;
+
+ rval = ftruncate(fd, length);
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: ftruncate(%d,%ld) failed",
+ file, lineno, fd, (long)length);
+ }
+
+ return rval;
+}
+#define SAFE_FTRUNCATE(cleanup_fn, fd, length) \
+ safe_ftruncate(__FILE__, __LINE__, cleanup_fn, (fd), (length))
+
+static inline int safe_truncate(const char *file, const int lineno,
+ void (cleanup_fn) (void), const char *path, off_t length)
+{
+ int rval;
+
+ rval = truncate(path, length);
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: truncate(%s,%ld) failed",
+ file, lineno, path, (long)length);
+ }
+
+ return rval;
+}
+#define SAFE_TRUNCATE(cleanup_fn, path, length) \
+ safe_truncate(__FILE__, __LINE__, cleanup_fn, (path), (length))
+
+static inline int safe_stat(const char *file, const int lineno,
+ void (cleanup_fn)(void), const char *path, struct stat *buf)
+{
+ int rval;
+
+ rval = stat(path, buf);
+
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: stat(%s,%p) failed", file, lineno, path, buf);
+ }
+
+ return rval;
+}
+#define SAFE_STAT(cleanup_fn, path, buf) \
+ safe_stat(__FILE__, __LINE__, (cleanup_fn), (path), (buf))
+
+static inline int safe_fstat(const char *file, const int lineno,
+ void (cleanup_fn)(void), int fd, struct stat *buf)
+{
+ int rval;
+
+ rval = fstat(fd, buf);
+
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: fstat(%d,%p) failed", file, lineno, fd, buf);
+ }
+
+ return rval;
+}
+#define SAFE_FSTAT(cleanup_fn, fd, buf) \
+ safe_fstat(__FILE__, __LINE__, (cleanup_fn), (fd), (buf))
+
+static inline int safe_lstat(const char *file, const int lineno,
+ void (cleanup_fn)(void), const char *path, struct stat *buf)
+{
+ int rval;
+
+ rval = lstat(path, buf);
+
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: lstat(%s,%p) failed", file, lineno, path, buf);
+ }
+
+ return rval;
+}
+#define SAFE_LSTAT(cleanup_fn, path, buf) \
+ safe_lstat(__FILE__, __LINE__, (cleanup_fn), (path), (buf))
+
+static inline off_t safe_lseek(const char *file, const int lineno,
+ void (cleanup_fn)(void), int fd, off_t offset, int whence)
+{
+ off_t rval;
+
+ rval = lseek(fd, offset, whence);
+
+ if (rval == (off_t) -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: lseek(%d,%ld,%d) failed",
+ file, lineno, fd, (long)offset, whence);
+ }
+
+ return rval;
+}
+#define SAFE_LSEEK(cleanup_fn, fd, offset, whence) \
+ safe_lseek(__FILE__, __LINE__, cleanup_fn, (fd), (offset), (whence))
+
+static inline int safe_getrlimit(const char *file, const int lineno,
+ void (cleanup_fn)(void), int resource, struct rlimit *rlim)
+{
+ int rval;
+
+ rval = getrlimit(resource, rlim);
+
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: getrlimit(%d,%p) failed",
+ file, lineno, resource, rlim);
+ }
+
+ return rval;
+}
+#define SAFE_GETRLIMIT(cleanup_fn, resource, rlim) \
+ safe_getrlimit(__FILE__, __LINE__, (cleanup_fn), (resource), (rlim))
+
+static inline int safe_setrlimit(const char *file, const int lineno,
+ void (cleanup_fn)(void), int resource, const struct rlimit *rlim)
+{
+ int rval;
+
+ rval = setrlimit(resource, rlim);
+
+ if (rval == -1) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: setrlimit(%d,%p) failed",
+ file, lineno, resource, rlim);
+ }
+
+ return rval;
+}
+#define SAFE_SETRLIMIT(cleanup_fn, resource, rlim) \
+ safe_setrlimit(__FILE__, __LINE__, (cleanup_fn), (resource), (rlim))
+
+#define SAFE_OPENDIR(cleanup_fn, name) \
+ safe_opendir(__FILE__, __LINE__, (cleanup_fn), (name))
+
+#define SAFE_CLOSEDIR(cleanup_fn, dirp) \
+ safe_closedir(__FILE__, __LINE__, (cleanup_fn), (dirp))
+
+#define SAFE_READDIR(cleanup_fn, dirp) \
+ safe_readdir(__FILE__, __LINE__, (cleanup_fn), (dirp))
+
+
+#define SAFE_IOCTL(cleanup_fn, fd, request, ...) \
+ ({int ret = ioctl(fd, request, __VA_ARGS__); \
+ if (ret < 0) \
+ tst_brkm(TBROK | TERRNO, cleanup_fn, \
+ "ioctl(%i,%s,...) failed", fd, #request); \
+ ret;})
+
+#endif /* __SAFE_MACROS_H__ */
+#endif /* __TEST_H__ */
diff --git a/src/kernel/tests/include/old/test.h b/src/kernel/tests/include/old/test.h
new file mode 100644
index 0000000..604254e
--- /dev/null
+++ b/src/kernel/tests/include/old/test.h
@@ -0,0 +1,214 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ * Copyright (c) 2009-2013 Cyril Hrubis chrubis@suse.cz
+ */
+
+#ifndef __TEST_H__
+#define __TEST_H__
+
+#ifdef TST_TEST_H__
+# error Newlib tst_test.h already included
+#endif /* TST_TEST_H__ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include "usctest.h"
+
+#include "tst_common.h"
+#include "old_safe_file_ops.h"
+#include "old_checkpoint.h"
+#include "tst_process_state.h"
+#include "old_resource.h"
+#include "tst_res_flags.h"
+#include "tst_kvercmp.h"
+#include "tst_fs.h"
+#include "tst_pid.h"
+#include "tst_cmd.h"
+#include "tst_cpu.h"
+#include "tst_clone.h"
+#include "old_device.h"
+#include "old_tmpdir.h"
+#include "tst_minmax.h"
+#include "tst_get_bad_addr.h"
+#include "tst_path_has_mnt_flags.h"
+
+/*
+ * Ensure that NUMSIGS is defined.
+ * It should be defined in signal.h or sys/signal.h on
+ * UNICOS/mk and IRIX systems. On UNICOS systems,
+ * it is not defined, thus it is being set to UNICOS's NSIG.
+ * Note: IRIX's NSIG (signals are 1-(NSIG-1))
+ * is not same meaning as UNICOS/UMK's NSIG (signals 1-NSIG)
+ */
+#ifndef NUMSIGS
+#define NUMSIGS NSIG
+#endif
+
+
+/* defines for unexpected signal setup routine (set_usig.c) */
+#define FORK 1 /* SIGCHLD is to be ignored */
+#define NOFORK 0 /* SIGCHLD is to be caught */
+#define DEF_HANDLER SIG_ERR /* tells set_usig() to use default signal handler */
+
+/*
+ * The following defines are used to control tst_res and t_result reporting.
+ */
+
+#define TOUTPUT "TOUTPUT" /* The name of the environment variable */
+ /* that can be set to one of the following */
+ /* strings to control tst_res output */
+ /* If not set, TOUT_VERBOSE_S is assumed */
+
+/*
+ * fork() can't be used on uClinux systems, so use FORK_OR_VFORK instead,
+ * which will run vfork() on uClinux.
+ * mmap() doesn't support MAP_PRIVATE on uClinux systems, so use
+ * MAP_PRIVATE_EXCEPT_UCLINUX instead, which will skip the option on uClinux.
+ * If MAP_PRIVATE really is required, the test can not be run on uClinux.
+ */
+#ifdef UCLINUX
+# define FORK_OR_VFORK tst_vfork
+# define MAP_PRIVATE_EXCEPT_UCLINUX 0
+/* tst_old_flush() + vfork() */
+pid_t tst_vfork(void);
+#else
+# define FORK_OR_VFORK tst_fork
+# define MAP_PRIVATE_EXCEPT_UCLINUX MAP_PRIVATE
+#endif
+
+/*
+ * Macro to use for making functions called only once in
+ * multi-threaded tests such as init or cleanup function.
+ * The first call to @name_fn function by any thread shall
+ * call the @exec_fn. Subsequent calls shall not call @exec_fn.
+ * *_fn functions must not take any arguments.
+ */
+#define TST_DECLARE_ONCE_FN(name_fn, exec_fn) \
+ void name_fn(void) \
+ { \
+ static pthread_once_t ltp_once = PTHREAD_ONCE_INIT; \
+ pthread_once(&ltp_once, exec_fn); \
+ }
+
+/*
+ * lib/forker.c
+ */
+extern int Forker_pids[];
+extern int Forker_npids;
+
+typedef struct {
+ char *option; /* Valid option string (one option only) like "a:" */
+ int *flag; /* Pointer to location to set true if option given */
+ char **arg; /* Pointer to location to place argument, if needed */
+} option_t;
+
+/* lib/tst_parse_opts.c */
+void tst_parse_opts(int argc, char *argv[], const option_t *user_optarg,
+ void (*user_help)(void));
+
+/* lib/tst_res.c */
+const char *strttype(int ttype);
+
+void tst_resm_(const char *file, const int lineno, int ttype,
+ const char *arg_fmt, ...)
+ __attribute__ ((format (printf, 4, 5)));
+#define tst_resm(ttype, arg_fmt, ...) \
+ tst_resm_(__FILE__, __LINE__, (ttype), \
+ (arg_fmt), ##__VA_ARGS__)
+
+void tst_resm_hexd_(const char *file, const int lineno, int ttype,
+ const void *buf, size_t size, const char *arg_fmt, ...)
+ __attribute__ ((format (printf, 6, 7)));
+#define tst_resm_hexd(ttype, buf, size, arg_fmt, ...) \
+ tst_resm_hexd_(__FILE__, __LINE__, (ttype), (buf), (size), \
+ (arg_fmt), ##__VA_ARGS__)
+
+void tst_brkm_(const char *file, const int lineno, int ttype,
+ void (*func)(void), const char *arg_fmt, ...)
+ __attribute__ ((format (printf, 5, 6))) LTP_ATTRIBUTE_NORETURN;
+
+#ifdef LTPLIB
+# include "ltp_priv.h"
+# define tst_brkm(flags, cleanup, fmt, ...) do { \
+ if (tst_test) \
+ tst_brk_(__FILE__, __LINE__, flags, fmt, ##__VA_ARGS__); \
+ else \
+ tst_brkm_(__FILE__, __LINE__, flags, cleanup, fmt, ##__VA_ARGS__); \
+ } while (0)
+#else
+# define tst_brkm(flags, cleanup, fmt, ...) do { \
+ tst_brkm_(__FILE__, __LINE__, flags, cleanup, fmt, ##__VA_ARGS__); \
+ } while (0)
+#endif
+
+void tst_require_root(void);
+void tst_exit(void) LTP_ATTRIBUTE_NORETURN;
+void tst_old_flush(void);
+
+/*
+ * tst_old_flush() + fork
+ * NOTE: tst_fork() will reset T_exitval to 0 for child process.
+ */
+pid_t tst_fork(void);
+
+/* lib/tst_res.c */
+/*
+ * In case we need do real test work in child process parent process can use
+ * tst_record_childstatus() to make child process's test results propagated to
+ * parent process correctly.
+ *
+ * The child can use tst_resm(), tst_brkm() followed by the tst_exit() or
+ * plain old exit() (with TPASS, TFAIL and TBROK).
+ *
+ * WARNING: Be wary that the child cleanup function passed to tst_brkm()
+ * must clean only resources the child has allocated. E.g. the
+ * child cleanup is different function from the parent cleanup.
+ */
+void tst_record_childstatus(void (*cleanup)(void), pid_t child);
+
+extern int tst_count;
+
+/* lib/tst_sig.c */
+void tst_sig(int fork_flag, void (*handler)(), void (*cleanup)());
+
+/* lib/self_exec.c */
+void maybe_run_child(void (*child)(), const char *fmt, ...);
+int self_exec(const char *argv0, const char *fmt, ...);
+
+/* lib/tst_mkfs.c
+ *
+ * @dev: path to a device
+ * @fs_type: filesystem type
+ * @fs_opts: NULL or NULL terminated array of mkfs options
+ * @extra_opt: extra mkfs option which is passed after the device name
+ */
+#define tst_mkfs(cleanup, dev, fs_type, fs_opts, extra_opts) \
+ tst_mkfs_(__FILE__, __LINE__, cleanup, dev, fs_type, \
+ fs_opts, extra_opts)
+void tst_mkfs_(const char *file, const int lineno, void (cleanup_fn)(void),
+ const char *dev, const char *fs_type,
+ const char *const fs_opts[], const char *const extra_opts[]);
+
+/* lib/tst_res.c
+ * tst_strsig converts signal's value to corresponding string.
+ * tst_strerrno converts errno to corresponding string.
+ */
+const char *tst_strsig(int sig);
+const char *tst_strerrno(int err);
+
+#ifdef TST_USE_COMPAT16_SYSCALL
+#define TCID_BIT_SUFFIX "_16"
+#elif TST_USE_NEWER64_SYSCALL
+#define TCID_BIT_SUFFIX "_64"
+#else
+#define TCID_BIT_SUFFIX ""
+#endif
+#define TCID_DEFINE(ID) char *TCID = (#ID TCID_BIT_SUFFIX)
+
+#endif /* __TEST_H__ */
diff --git a/src/kernel/tests/include/old/tlibio.h b/src/kernel/tests/include/old/tlibio.h
new file mode 100644
index 0000000..0fe9ce9
--- /dev/null
+++ b/src/kernel/tests/include/old/tlibio.h
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like. Any license provided herein, whether implied or
+ * otherwise, applies only to this software file. Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+ * Mountain View, CA 94043, or:
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
+ * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
+ */
+
+#define LIO_IO_SYNC 00001 /* read/write */
+#define LIO_IO_ASYNC 00002 /* reada/writea/aio_write/aio_read */
+#define LIO_IO_SLISTIO 00004 /* single stride sync listio */
+#define LIO_IO_ALISTIO 00010 /* single stride async listio */
+#define LIO_IO_SYNCV 00020 /* single-buffer readv/writev */
+#define LIO_IO_SYNCP 00040 /* pread/pwrite */
+
+#ifdef sgi
+#define LIO_IO_ATYPES 00077 /* all io types */
+#define LIO_IO_TYPES 00061 /* all io types, non-async */
+#endif /* sgi */
+#if defined(__linux__) && !defined(__UCLIBC__)
+#define LIO_IO_TYPES 00061 /* all io types */
+#define LIO_IO_ATYPES 00077 /* all io types */
+#endif
+#if defined(__sun) || defined(__hpux) || defined(_AIX) || defined(__UCLIBC__)
+#define LIO_IO_TYPES 00021 /* all io types except pread/pwrite */
+#endif /* linux */
+#ifdef CRAY
+#define LIO_IO_TYPES 00017 /* all io types */
+#endif /* CRAY */
+
+#ifndef LIO_IO_ATYPES
+#define LIO_IO_ATYPES LIO_IO_TYPES
+#endif
+
+#define LIO_WAIT_NONE 00010000 /* return asap -- use with care */
+#define LIO_WAIT_ACTIVE 00020000 /* spin looking at iosw fields, or EINPROGRESS */
+#define LIO_WAIT_RECALL 00040000 /* call recall(2)/aio_suspend(3) */
+#define LIO_WAIT_SIGPAUSE 00100000 /* call pause */
+#define LIO_WAIT_SIGACTIVE 00200000 /* spin waiting for signal */
+#if defined(sgi) || defined(__linux__)
+#define LIO_WAIT_CBSUSPEND 00400000 /* aio_suspend waiting for callback */
+#define LIO_WAIT_SIGSUSPEND 01000000 /* aio_suspend waiting for signal */
+#define LIO_WAIT_ATYPES 01760000 /* all async wait types, except nowait */
+#define LIO_WAIT_TYPES 00020000 /* all sync wait types (sorta) */
+#endif /* sgi */
+#if defined(__sun) || defined(__hpux) || defined(_AIX)
+#define LIO_WAIT_TYPES 00300000 /* all wait types, except nowait */
+#endif /* linux */
+#ifdef CRAY
+#define LIO_WAIT_TYPES 00360000 /* all wait types, except nowait */
+#endif /* CRAY */
+
+/* meta wait io */
+/* 00 000 0000 */
+
+#if defined(sgi) || defined(__linux__)
+/* all callback wait types */
+#define LIO_WAIT_CBTYPES (LIO_WAIT_CBSUSPEND)
+/* all signal wait types */
+#define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE|LIO_WAIT_SIGACTIVE|LIO_WAIT_SIGSUSPEND)
+/* all aio_{read,write} or lio_listio */
+#define LIO_IO_ASYNC_TYPES (LIO_IO_ASYNC|LIO_IO_SLISTIO|LIO_IO_ALISTIO)
+#endif /* sgi */
+#if defined(__sun) || defined(__hpux) || defined(_AIX)
+/* all signal wait types */
+#define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE)
+#endif /* linux */
+#ifdef CRAY
+/* all signal wait types */
+#define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE|LIO_WAIT_SIGACTIVE)
+#endif /* CRAY */
+
+/*
+ * This bit provides a way to randomly pick an io type and wait method.
+ * lio_read_buffer() and lio_write_buffer() functions will call
+ * lio_random_methods() with the given method.
+ */
+#define LIO_RANDOM 010000000
+
+/*
+ * This bit provides a way for the programmer to use async i/o with
+ * signals and to use their own signal handler. By default,
+ * the signal will only be given to the system call if the wait
+ * method is LIO_WAIT_SIGPAUSE or LIO_WAIT_SIGACTIVE.
+ * Whenever these wait methods are used, libio signal handler
+ * will be used.
+ */
+#define LIO_USE_SIGNAL 020000000
+
+/*
+ * prototypes/structures for functions in the libio.c module. See comments
+ * in that module, or man page entries for information on the individual
+ * functions.
+ */
+
+int stride_bounds(int offset, int stride, int nstrides,
+ int bytes_per_stride, int *min_byte, int *max_byte);
+
+int lio_set_debug(int level);
+int lio_parse_io_arg1(char *string);
+void lio_help1(char *prefex);
+int lio_parse_io_arg2(char *string, char **badtoken);
+void lio_help2(char *prefex);
+int lio_write_buffer(int fd, int method, char *buffer, int size,
+ int sig, char **errmsg, long wrd);
+
+int lio_read_buffer(int fd, int method, char *buffer, int size,
+ int sig, char **errmsg, long wrd);
+int lio_random_methods(long mask);
+
+#if CRAY
+#include <sys/iosw.h>
+int lio_wait4asyncio(int method, int fd, struct iosw **statptr);
+int lio_check_asyncio(char *io_type, int size, struct iosw *status);
+#endif /* CRAY */
+#if defined (sgi)
+#include <aio.h>
+int lio_wait4asyncio(int method, int fd, aiocb_t *aiocbp);
+int lio_check_asyncio(char *io_type, int size, aiocb_t *aiocbp, int method);
+#endif /* sgi */
+#if defined(__linux__) && !defined(__UCLIBC__)
+#include <aio.h>
+int lio_wait4asyncio(int method, int fd, struct aiocb *aiocbp);
+int lio_check_asyncio(char *io_type, int size, struct aiocb *aiocbp, int method);
+#endif
+
+/*
+ * Define the structure that contains the infomation that is used
+ * by the parsing and help functions.
+ */
+struct lio_info_type {
+ char *token;
+ int bits;
+ char *desc;
+};
+
+
diff --git a/src/kernel/tests/include/old/usctest.h b/src/kernel/tests/include/old/usctest.h
new file mode 100644
index 0000000..9b9446d
--- /dev/null
+++ b/src/kernel/tests/include/old/usctest.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ * Author: William Roske
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like. Any license provided herein, whether implied or
+ * otherwise, applies only to this software file. Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+ * Mountain View, CA 94043, or:
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
+ * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
+ */
+
+#ifndef __USCTEST_H__
+#define __USCTEST_H__
+
+/*
+ * Ensure that PATH_MAX is defined
+ */
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+/***********************************************************************
+ * The following globals are defined in parse_opts.c but must be
+ * externed here because they are used in the macros defined below.
+ ***********************************************************************/
+extern int STD_LOOP_COUNT; /* changed by -in to set loop count to n */
+
+extern long TEST_RETURN;
+extern int TEST_ERRNO;
+
+/***********************************************************************
+ * TEST: calls a system call
+ *
+ * parameters:
+ * SCALL = system call and parameters to execute
+ *
+ ***********************************************************************/
+#define TEST(SCALL) \
+ do { \
+ errno = 0; \
+ TEST_RETURN = SCALL; \
+ TEST_ERRNO = errno; \
+ } while (0)
+
+/***********************************************************************
+ * TEST_VOID: calls a system call
+ *
+ * parameters:
+ * SCALL = system call and parameters to execute
+ *
+ * Note: This is IDENTICAL to the TEST() macro except that it is intended
+ * for use with syscalls returning no values (void syscall()). The
+ * Typecasting nothing (void) into an unsigned integer causes compilation
+ * errors.
+ *
+ ***********************************************************************/
+#define TEST_VOID(SCALL) do { errno = 0; SCALL; TEST_ERRNO = errno; } while (0)
+
+/***********************************************************************
+ * TEST_PAUSE: Pause for SIGUSR1 if the pause flag is set.
+ * Just continue when signal comes in.
+ *
+ * parameters:
+ * none
+ *
+ ***********************************************************************/
+#define TEST_PAUSE usc_global_setup_hook();
+int usc_global_setup_hook();
+
+/***********************************************************************
+ * TEST_LOOPING now call the usc_test_looping function.
+ * The function will return 1 if the test should continue
+ * iterating.
+ *
+ ***********************************************************************/
+#define TEST_LOOPING usc_test_looping
+int usc_test_looping(int counter);
+
+#endif /* __USCTEST_H__ */