aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2008-11-11 08:23:51 +0000
committerMike Frysinger <vapier@gentoo.org>2008-11-11 08:23:51 +0000
commitd3953761f66476d7a0e6a38ede57661b4d190589 (patch)
treefe376d0a19f6c0633221f70c7a4fc0db7b025c26
parentmove build flags to configure rather than Makefile (diff)
downloadsandbox-d3953761f66476d7a0e6a38ede57661b4d190589.tar.gz
sandbox-d3953761f66476d7a0e6a38ede57661b4d190589.tar.bz2
sandbox-d3953761f66476d7a0e6a38ede57661b4d190589.zip
tests: initial test framework
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--Makefile.am4
-rw-r--r--configure.ac7
-rw-r--r--headers.h3
-rw-r--r--tests/Makefile.am58
-rw-r--r--tests/access-0.c19
-rwxr-xr-xtests/access.sh2
-rw-r--r--tests/atlocal2
-rw-r--r--tests/atlocal.in2
-rw-r--r--tests/chmod-0.c16
-rw-r--r--tests/chown-0.c18
-rw-r--r--tests/creat-0.c16
-rw-r--r--tests/creat64-0.c16
-rw-r--r--tests/faccessat-0.c23
-rw-r--r--tests/fchmodat-0.c23
-rw-r--r--tests/fchownat-0.c25
-rw-r--r--tests/fopen-0.c15
-rw-r--r--tests/fopen64-0.c15
-rw-r--r--tests/futimesat-0.c18
-rw-r--r--tests/lchown-0.c18
-rw-r--r--tests/link-0.c15
-rw-r--r--tests/linkat-0.c25
-rw-r--r--tests/local.at19
-rw-r--r--tests/lutimes-0.c15
-rw-r--r--tests/mkdir-0.c16
-rw-r--r--tests/mkdirat-0.c19
-rw-r--r--tests/mkfifo-0.c16
-rw-r--r--tests/mkfifoat-0.c19
-rw-r--r--tests/mknod-0.c20
-rw-r--r--tests/mknodat-0.c23
-rw-r--r--tests/open-0.c16
-rw-r--r--tests/open64-0.c16
-rw-r--r--tests/openat-0.c19
-rw-r--r--tests/openat64-0.c19
-rw-r--r--tests/opendir-0.c12
-rw-r--r--tests/package.m4.in5
-rw-r--r--tests/rename-0.c15
-rw-r--r--tests/renameat-0.c21
-rw-r--r--tests/rmdir-0.c12
-rw-r--r--tests/symlink-0.c15
-rw-r--r--tests/symlinkat-0.c18
-rw-r--r--tests/test-skel-0.c33
-rw-r--r--tests/tests.h5
-rw-r--r--tests/testsuite.at8
-rw-r--r--tests/truncate-0.c16
-rw-r--r--tests/truncate64-0.c16
-rw-r--r--tests/unlink-0.c12
-rw-r--r--tests/unlinkat-0.c19
-rw-r--r--tests/utime-0.c15
-rw-r--r--tests/utimensat-0.c22
-rw-r--r--tests/utimes-0.c15
50 files changed, 815 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 3aaf38c..0d2912a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,10 +6,12 @@ SUBDIRS = \
data \
libsbutil \
libsandbox \
- src
+ src \
+ tests
libsandbox: libsbutil
src: libsbutil
+tests: src
EXTRA_DIST = headers.h localdecls.h ChangeLog.0
diff --git a/configure.ac b/configure.ac
index 5235aae..c742274 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,7 @@ AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_AWK
AC_CHECK_PROGS([READELF], [readelf eu-readelf], [false])
+AM_MISSING_PROG([AUTOM4TE], [autom4te])
AC_ENABLE_SHARED
AC_DISABLE_STATIC
@@ -46,6 +47,7 @@ AC_CHECK_HEADERS_ONCE([ \
stdlib.h \
string.h \
strings.h \
+ syscall.h \
unistd.h \
utime.h \
sys/file.h \
@@ -237,6 +239,8 @@ if test "$GCC" = yes; then
CFLAGS="$CFLAGS -Wall"
fi
+AC_CONFIG_TESTDIR([tests])
+
AC_OUTPUT([
Makefile
scripts/Makefile
@@ -245,4 +249,7 @@ AC_OUTPUT([
libsbutil/Makefile
libsandbox/Makefile
src/Makefile
+ tests/atlocal
+ tests/Makefile
+ tests/package.m4
])
diff --git a/headers.h b/headers.h
index 9e2f15a..c39398f 100644
--- a/headers.h
+++ b/headers.h
@@ -60,6 +60,9 @@
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
+#ifdef HAVE_SYSCALL_H
+# include <syscall.h>
+#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..c86d4ff
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,58 @@
+EXTRA_DIST = atlocal.in package.m4.in $(AT_FILES) $(TESTSUITE)
+AT_FILES = local.at testsuite.at
+TESTSUITE = $(srcdir)/testsuite
+DISTCLEANFILES = atconfig
+
+check_PROGRAMS = \
+ access-0 \
+ chmod-0 \
+ chown-0 \
+ creat-0 \
+ creat64-0 \
+ faccessat-0 \
+ fchmodat-0 \
+ fchownat-0 \
+ fopen-0 \
+ fopen64-0 \
+ futimesat-0 \
+ lchown-0 \
+ link-0 \
+ linkat-0 \
+ lutimes-0 \
+ mkdir-0 \
+ mkdirat-0 \
+ mkfifo-0 \
+ mkfifoat-0 \
+ mknod-0 \
+ mknodat-0 \
+ open-0 \
+ open64-0 \
+ openat-0 \
+ openat64-0 \
+ opendir-0 \
+ rename-0 \
+ renameat-0 \
+ symlink-0 \
+ symlinkat-0 \
+ truncate-0 \
+ truncate64-0 \
+ unlink-0 \
+ unlinkat-0 \
+ utime-0 \
+ utimensat-0 \
+ utimes-0
+
+check-local: atconfig atlocal $(TESTSUITE)
+ $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
+
+installcheck-local: atconfig atlocal $(TESTSUITE)
+ $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' $(TESTSUITEFLAGS)
+
+clean-local:
+ test ! -f '$(TESTSUITE)' || \
+ $(SHELL) '$(TESTSUITE)' --clean
+
+AUTOTEST = $(AUTOM4TE) --language=autotest
+$(TESTSUITE): $(AT_FILES)
+ $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
+ mv $@.tmp $@
diff --git a/tests/access-0.c b/tests/access-0.c
new file mode 100644
index 0000000..32a9862
--- /dev/null
+++ b/tests/access-0.c
@@ -0,0 +1,19 @@
+#define FUNC access
+#define SFUNC "access"
+#define FUNC_STR "\"%s\", %x"
+#define FUNC_IMP file, mode
+#define ARG_CNT 2
+#define ARG_USE "<file> <mode>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ int mode = 0; \
+ if (strchr(s, 'r')) mode |= R_OK; \
+ if (strchr(s, 'w')) mode |= W_OK; \
+ if (strchr(s, 'x')) mode |= X_OK; \
+ if (strchr(s, 'f')) mode = F_OK;
+
+#include "test-skel-0.c"
diff --git a/tests/access.sh b/tests/access.sh
new file mode 100755
index 0000000..d1c5cfb
--- /dev/null
+++ b/tests/access.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+./access-0 0 rwx /
diff --git a/tests/atlocal b/tests/atlocal
new file mode 100644
index 0000000..1731900
--- /dev/null
+++ b/tests/atlocal
@@ -0,0 +1,2 @@
+export PATH=$abs_top_builddir/src:$abs_builddir:$PATH
+export LD_LIBRARY_PATH=$abs_top_builddir/libsandbox/.libs${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}
diff --git a/tests/atlocal.in b/tests/atlocal.in
new file mode 100644
index 0000000..1731900
--- /dev/null
+++ b/tests/atlocal.in
@@ -0,0 +1,2 @@
+export PATH=$abs_top_builddir/src:$abs_builddir:$PATH
+export LD_LIBRARY_PATH=$abs_top_builddir/libsandbox/.libs${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}
diff --git a/tests/chmod-0.c b/tests/chmod-0.c
new file mode 100644
index 0000000..583ed5d
--- /dev/null
+++ b/tests/chmod-0.c
@@ -0,0 +1,16 @@
+#define FUNC chmod
+#define SFUNC "chmod"
+#define FUNC_STR "\"%s\", %o"
+#define FUNC_IMP file, mode
+#define ARG_CNT 2
+#define ARG_USE "<file> <mode>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ mode_t mode; \
+ sscanf(s, "%i", &mode);
+
+#include "test-skel-0.c"
diff --git a/tests/chown-0.c b/tests/chown-0.c
new file mode 100644
index 0000000..3a8c997
--- /dev/null
+++ b/tests/chown-0.c
@@ -0,0 +1,18 @@
+#define FUNC chown
+#define SFUNC "chown"
+#define FUNC_STR "\"%s\", %i, %i"
+#define FUNC_IMP file, uid, gid
+#define ARG_CNT 3
+#define ARG_USE "<file> <uid> <gid>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ uid_t uid = atoi(s); \
+ \
+ s = argv[i++]; \
+ gid_t gid = atoi(s);
+
+#include "test-skel-0.c"
diff --git a/tests/creat-0.c b/tests/creat-0.c
new file mode 100644
index 0000000..822f870
--- /dev/null
+++ b/tests/creat-0.c
@@ -0,0 +1,16 @@
+#define FUNC creat
+#define SFUNC "creat"
+#define FUNC_STR "\"%s\", %o"
+#define FUNC_IMP file, mode
+#define ARG_CNT 2
+#define ARG_USE "<file> <mode>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ mode_t mode; \
+ sscanf(s, "%i", &mode);
+
+#include "test-skel-0.c"
diff --git a/tests/creat64-0.c b/tests/creat64-0.c
new file mode 100644
index 0000000..a7e957e
--- /dev/null
+++ b/tests/creat64-0.c
@@ -0,0 +1,16 @@
+#define FUNC creat64
+#define SFUNC "creat64"
+#define FUNC_STR "\"%s\", %o"
+#define FUNC_IMP file, mode
+#define ARG_CNT 2
+#define ARG_USE "<file> <mode>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ mode_t mode; \
+ sscanf(s, "%i", &mode);
+
+#include "test-skel-0.c"
diff --git a/tests/faccessat-0.c b/tests/faccessat-0.c
new file mode 100644
index 0000000..6dee61c
--- /dev/null
+++ b/tests/faccessat-0.c
@@ -0,0 +1,23 @@
+#define FUNC faccessat
+#define SFUNC "faccessat"
+#define FUNC_STR "%i, \"%s\", %x, %x"
+#define FUNC_IMP dirfd, file, mode, flags
+#define ARG_CNT 4
+#define ARG_USE "<dirfd> <file> <mode> <flags>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ int mode = 0; \
+ sscanf(s, "%i", &mode); \
+ \
+ s = argv[i++]; \
+ int flags = 0; \
+ sscanf(s, "%i", &flags);
+
+#include "test-skel-0.c"
diff --git a/tests/fchmodat-0.c b/tests/fchmodat-0.c
new file mode 100644
index 0000000..554a17b
--- /dev/null
+++ b/tests/fchmodat-0.c
@@ -0,0 +1,23 @@
+#define FUNC fchmodat
+#define SFUNC "fchmodat"
+#define FUNC_STR "%i, \"%s\", %o, %x"
+#define FUNC_IMP dirfd, file, mode, flags
+#define ARG_CNT 4
+#define ARG_USE "<dirfd> <file> <mode> <flags>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ mode_t mode; \
+ sscanf(s, "%i", &mode); \
+ \
+ s = argv[i++]; \
+ int flags = 0; \
+ sscanf(s, "%i", &flags);
+
+#include "test-skel-0.c"
diff --git a/tests/fchownat-0.c b/tests/fchownat-0.c
new file mode 100644
index 0000000..eef70bb
--- /dev/null
+++ b/tests/fchownat-0.c
@@ -0,0 +1,25 @@
+#define FUNC fchownat
+#define SFUNC "fchownat"
+#define FUNC_STR "%i, \"%s\", %i, %i, %x"
+#define FUNC_IMP dirfd, file, uid, gid, flags
+#define ARG_CNT 5
+#define ARG_USE "<dirfd> <file> <uid> <gid>, <flags>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ uid_t uid = atoi(s); \
+ \
+ s = argv[i++]; \
+ gid_t gid = atoi(s); \
+ \
+ s = argv[i++]; \
+ int flags = 0; \
+ sscanf(s, "%i", &flags);
+
+#include "test-skel-0.c"
diff --git a/tests/fopen-0.c b/tests/fopen-0.c
new file mode 100644
index 0000000..fc10e89
--- /dev/null
+++ b/tests/fopen-0.c
@@ -0,0 +1,15 @@
+#define FUNC fopen
+#define SFUNC "fopen"
+#define FUNC_STR "\"%s\", \"%s\""
+#define FUNC_IMP file, mode
+#define ARG_CNT 2
+#define ARG_USE "<file> <mode>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ char *mode = s;
+
+#include "test-skel-0.c"
diff --git a/tests/fopen64-0.c b/tests/fopen64-0.c
new file mode 100644
index 0000000..eb2fe44
--- /dev/null
+++ b/tests/fopen64-0.c
@@ -0,0 +1,15 @@
+#define FUNC fopen64
+#define SFUNC "fopen64"
+#define FUNC_STR "\"%s\", \"%s\""
+#define FUNC_IMP file, mode
+#define ARG_CNT 2
+#define ARG_USE "<file> <mode>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ char *mode = s;
+
+#include "test-skel-0.c"
diff --git a/tests/futimesat-0.c b/tests/futimesat-0.c
new file mode 100644
index 0000000..a341e20
--- /dev/null
+++ b/tests/futimesat-0.c
@@ -0,0 +1,18 @@
+#define FUNC futimesat
+#define SFUNC "futimesat"
+#define FUNC_STR "%i, \"%s\", %p"
+#define FUNC_IMP dirfd, file, times
+#define ARG_CNT 3
+#define ARG_USE "<dirfd> <file> <times:=NULL>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ const struct timeval *times = NULL;
+
+#include "test-skel-0.c"
diff --git a/tests/lchown-0.c b/tests/lchown-0.c
new file mode 100644
index 0000000..73c6a18
--- /dev/null
+++ b/tests/lchown-0.c
@@ -0,0 +1,18 @@
+#define FUNC lchown
+#define SFUNC "lchown"
+#define FUNC_STR "\"%s\", %i, %i"
+#define FUNC_IMP file, uid, gid
+#define ARG_CNT 3
+#define ARG_USE "<file> <uid> <gid>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ uid_t uid = atoi(s); \
+ \
+ s = argv[i++]; \
+ gid_t gid = atoi(s);
+
+#include "test-skel-0.c"
diff --git a/tests/link-0.c b/tests/link-0.c
new file mode 100644
index 0000000..f5e4f88
--- /dev/null
+++ b/tests/link-0.c
@@ -0,0 +1,15 @@
+#define FUNC link
+#define SFUNC "link"
+#define FUNC_STR "\"%s\", \"%s\""
+#define FUNC_IMP oldpath, newpath
+#define ARG_CNT 2
+#define ARG_USE "<oldpath> <newpath>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *oldpath = s; \
+ \
+ s = argv[i++]; \
+ char *newpath = s;
+
+#include "test-skel-0.c"
diff --git a/tests/linkat-0.c b/tests/linkat-0.c
new file mode 100644
index 0000000..97391e5
--- /dev/null
+++ b/tests/linkat-0.c
@@ -0,0 +1,25 @@
+#define FUNC linkat
+#define SFUNC "linkat"
+#define FUNC_STR "%i, \"%s\", %i, \"%s\", %x"
+#define FUNC_IMP olddirfd, oldpath, newdirfd, newpath, flags
+#define ARG_CNT 5
+#define ARG_USE "<olddirfd> <oldpath> <newdirfd> <newpath> <flags>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int olddirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *oldpath = s; \
+ \
+ s = argv[i++]; \
+ int newdirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *newpath = s; \
+ \
+ s = argv[i++]; \
+ int flags = 0; \
+ sscanf(s, "%i", &flags);
+
+#include "test-skel-0.c"
diff --git a/tests/local.at b/tests/local.at
new file mode 100644
index 0000000..4c5d44e
--- /dev/null
+++ b/tests/local.at
@@ -0,0 +1,19 @@
+m4_defun([LDR_BINARY], [ldr])
+
+m4_defun([LDR_UART_LOADER], [fake-loadee])
+
+m4_defun([LDR_FILTER_VARS], [sed -e "s:$abs_srcdir/::g" -e 's: *$[]::'])
+
+m4_defun([LDRS_DIR], [$abs_srcdir/ldrs])
+m4_defun([ELFS_DIR], [$abs_srcdir/elfs])
+
+m4_defun([AT_LDR_CHECK],[dnl
+ AT_CHECK([
+($1) > stdout 2> stderr
+ret=$[]?
+LDR_FILTER_VARS stdout
+LDR_FILTER_VARS stderr 1>&2
+(exit $[]ret)
+],
+[$2],[$3],[$4],[$5],[$6])
+])
diff --git a/tests/lutimes-0.c b/tests/lutimes-0.c
new file mode 100644
index 0000000..aadf2e1
--- /dev/null
+++ b/tests/lutimes-0.c
@@ -0,0 +1,15 @@
+#define FUNC lutimes
+#define SFUNC "lutimes"
+#define FUNC_STR "\"%s\", %p"
+#define FUNC_IMP file, times
+#define ARG_CNT 2
+#define ARG_USE "<file> <times:=NULL>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ const struct timeval *times = NULL;
+
+#include "test-skel-0.c"
diff --git a/tests/mkdir-0.c b/tests/mkdir-0.c
new file mode 100644
index 0000000..e1f5fc3
--- /dev/null
+++ b/tests/mkdir-0.c
@@ -0,0 +1,16 @@
+#define FUNC mkdir
+#define SFUNC "mkdir"
+#define FUNC_STR "\"%s\", %o"
+#define FUNC_IMP path, mode
+#define ARG_CNT 2
+#define ARG_USE "<path> <mode>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *path = s; \
+ \
+ s = argv[i++]; \
+ mode_t mode; \
+ sscanf(s, "%i", &mode);
+
+#include "test-skel-0.c"
diff --git a/tests/mkdirat-0.c b/tests/mkdirat-0.c
new file mode 100644
index 0000000..d1cffd2
--- /dev/null
+++ b/tests/mkdirat-0.c
@@ -0,0 +1,19 @@
+#define FUNC mkdirat
+#define SFUNC "mkdirat"
+#define FUNC_STR "%i, \"%s\", %o"
+#define FUNC_IMP dirfd, path, mode
+#define ARG_CNT 2
+#define ARG_USE "<dirfd> <path> <mode>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *path = s; \
+ \
+ s = argv[i++]; \
+ mode_t mode; \
+ sscanf(s, "%i", &mode);
+
+#include "test-skel-0.c"
diff --git a/tests/mkfifo-0.c b/tests/mkfifo-0.c
new file mode 100644
index 0000000..4eeb021
--- /dev/null
+++ b/tests/mkfifo-0.c
@@ -0,0 +1,16 @@
+#define FUNC mkfifo
+#define SFUNC "mkfifo"
+#define FUNC_STR "\"%s\", %o"
+#define FUNC_IMP file, mode
+#define ARG_CNT 2
+#define ARG_USE "<file> <mode>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ mode_t mode; \
+ sscanf(s, "%i", &mode);
+
+#include "test-skel-0.c"
diff --git a/tests/mkfifoat-0.c b/tests/mkfifoat-0.c
new file mode 100644
index 0000000..4a6e355
--- /dev/null
+++ b/tests/mkfifoat-0.c
@@ -0,0 +1,19 @@
+#define FUNC mkfifoat
+#define SFUNC "mkfifoat"
+#define FUNC_STR "%i, \"%s\", %o"
+#define FUNC_IMP dirfd, file, mode
+#define ARG_CNT 3
+#define ARG_USE "<dirfd> <file> <mode>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ mode_t mode; \
+ sscanf(s, "%i", &mode);
+
+#include "test-skel-0.c"
diff --git a/tests/mknod-0.c b/tests/mknod-0.c
new file mode 100644
index 0000000..faef6a8
--- /dev/null
+++ b/tests/mknod-0.c
@@ -0,0 +1,20 @@
+#define FUNC mknod
+#define SFUNC "mknod"
+#define FUNC_STR "\"%s\", %o, %x"
+#define FUNC_IMP file, mode, dev
+#define ARG_CNT 3
+#define ARG_USE "<file> <mode> <dev>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ mode_t mode; \
+ sscanf(s, "%i", &mode); \
+ \
+ s = argv[i++]; \
+ dev_t dev; \
+ sscanf(s, "%i", &dev);
+
+#include "test-skel-0.c"
diff --git a/tests/mknodat-0.c b/tests/mknodat-0.c
new file mode 100644
index 0000000..bfd7e50
--- /dev/null
+++ b/tests/mknodat-0.c
@@ -0,0 +1,23 @@
+#define FUNC mknodat
+#define SFUNC "mknodat"
+#define FUNC_STR "%i, \"%s\", %o, %x"
+#define FUNC_IMP dirfd, file, mode, dev
+#define ARG_CNT 4
+#define ARG_USE "<dirfd> <file> <mode> <dev>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ mode_t mode; \
+ sscanf(s, "%i", &mode); \
+ \
+ s = argv[i++]; \
+ dev_t dev; \
+ sscanf(s, "%i", &dev);
+
+#include "test-skel-0.c"
diff --git a/tests/open-0.c b/tests/open-0.c
new file mode 100644
index 0000000..79ab0d3
--- /dev/null
+++ b/tests/open-0.c
@@ -0,0 +1,16 @@
+#define FUNC open
+#define SFUNC "open"
+#define FUNC_STR "\"%s\", %o"
+#define FUNC_IMP file, flags
+#define ARG_CNT 2
+#define ARG_USE "<file> <flags>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ int flags; \
+ sscanf(s, "%i", &flags);
+
+#include "test-skel-0.c"
diff --git a/tests/open64-0.c b/tests/open64-0.c
new file mode 100644
index 0000000..27329c3
--- /dev/null
+++ b/tests/open64-0.c
@@ -0,0 +1,16 @@
+#define FUNC open64
+#define SFUNC "open64"
+#define FUNC_STR "\"%s\", %o"
+#define FUNC_IMP file, flags
+#define ARG_CNT 2
+#define ARG_USE "<file> <flags>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ int flags; \
+ sscanf(s, "%i", &flags);
+
+#include "test-skel-0.c"
diff --git a/tests/openat-0.c b/tests/openat-0.c
new file mode 100644
index 0000000..1ae2e08
--- /dev/null
+++ b/tests/openat-0.c
@@ -0,0 +1,19 @@
+#define FUNC openat
+#define SFUNC "openat"
+#define FUNC_STR "%i, \"%s\", %o"
+#define FUNC_IMP dirfd, file, flags
+#define ARG_CNT 3
+#define ARG_USE "<dirfd> <file> <flags>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ int flags; \
+ sscanf(s, "%i", &flags);
+
+#include "test-skel-0.c"
diff --git a/tests/openat64-0.c b/tests/openat64-0.c
new file mode 100644
index 0000000..df14390
--- /dev/null
+++ b/tests/openat64-0.c
@@ -0,0 +1,19 @@
+#define FUNC openat64
+#define SFUNC "openat64"
+#define FUNC_STR "%i, \"%s\", %o"
+#define FUNC_IMP dirfd, file, flags
+#define ARG_CNT 3
+#define ARG_USE "<dirfd> <file> <flags>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ int flags; \
+ sscanf(s, "%i", &flags);
+
+#include "test-skel-0.c"
diff --git a/tests/opendir-0.c b/tests/opendir-0.c
new file mode 100644
index 0000000..e7fe670
--- /dev/null
+++ b/tests/opendir-0.c
@@ -0,0 +1,12 @@
+#define FUNC opendir
+#define SFUNC "opendir"
+#define FUNC_STR "\"%s\""
+#define FUNC_IMP path
+#define ARG_CNT 1
+#define ARG_USE "<path>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *path = s;
+
+#include "test-skel-0.c"
diff --git a/tests/package.m4.in b/tests/package.m4.in
new file mode 100644
index 0000000..199b01b
--- /dev/null
+++ b/tests/package.m4.in
@@ -0,0 +1,5 @@
+m4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])
+m4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])
+m4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])
+m4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])
+m4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])
diff --git a/tests/rename-0.c b/tests/rename-0.c
new file mode 100644
index 0000000..aa50f37
--- /dev/null
+++ b/tests/rename-0.c
@@ -0,0 +1,15 @@
+#define FUNC rename
+#define SFUNC "rename"
+#define FUNC_STR "\"%s\", \"%s\""
+#define FUNC_IMP oldpath, newpath
+#define ARG_CNT 2
+#define ARG_USE "<oldpath> <newpath>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *oldpath = s; \
+ \
+ s = argv[i++]; \
+ char *newpath = s;
+
+#include "test-skel-0.c"
diff --git a/tests/renameat-0.c b/tests/renameat-0.c
new file mode 100644
index 0000000..1f776fa
--- /dev/null
+++ b/tests/renameat-0.c
@@ -0,0 +1,21 @@
+#define FUNC renameat
+#define SFUNC "renameat"
+#define FUNC_STR "%i, \"%s\", %i, \"%s\""
+#define FUNC_IMP olddirfd, oldpath, newdirfd, newpath
+#define ARG_CNT 4
+#define ARG_USE "<olddirfd> <oldpath> <newdirfd> <newpath>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int olddirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *oldpath = s; \
+ \
+ s = argv[i++]; \
+ int newdirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *newpath = s;
+
+#include "test-skel-0.c"
diff --git a/tests/rmdir-0.c b/tests/rmdir-0.c
new file mode 100644
index 0000000..d51dc2e
--- /dev/null
+++ b/tests/rmdir-0.c
@@ -0,0 +1,12 @@
+#define FUNC rmdir
+#define SFUNC "rmdir"
+#define FUNC_STR "\"%s\""
+#define FUNC_IMP path
+#define ARG_CNT 1
+#define ARG_USE "<path>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *path = s;
+
+#include "test-skel-0.c"
diff --git a/tests/symlink-0.c b/tests/symlink-0.c
new file mode 100644
index 0000000..6ddfd0c
--- /dev/null
+++ b/tests/symlink-0.c
@@ -0,0 +1,15 @@
+#define FUNC symlink
+#define SFUNC "symlink"
+#define FUNC_STR "\"%s\", \"%s\""
+#define FUNC_IMP oldpath, newpath
+#define ARG_CNT 2
+#define ARG_USE "<oldpath> <newpath>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *oldpath = s; \
+ \
+ s = argv[i++]; \
+ char *newpath = s;
+
+#include "test-skel-0.c"
diff --git a/tests/symlinkat-0.c b/tests/symlinkat-0.c
new file mode 100644
index 0000000..cbeaa36
--- /dev/null
+++ b/tests/symlinkat-0.c
@@ -0,0 +1,18 @@
+#define FUNC symlinkat
+#define SFUNC "symlinkat"
+#define FUNC_STR "\"%s\", %i, \"%s\""
+#define FUNC_IMP oldpath, newdirfd, newpath
+#define ARG_CNT 3
+#define ARG_USE "<oldpath> <newdirfd> <newpath>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *oldpath = s; \
+ \
+ s = argv[i++]; \
+ int newdirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *newpath = s;
+
+#include "test-skel-0.c"
diff --git a/tests/test-skel-0.c b/tests/test-skel-0.c
new file mode 100644
index 0000000..c7450eb
--- /dev/null
+++ b/tests/test-skel-0.c
@@ -0,0 +1,33 @@
+#include "tests.h"
+
+int main(int argc, char *argv[])
+{
+ int i, test_ret;
+
+ if ((argc - 1) % (ARG_CNT + 1) || argc == 1) {
+ printf(
+ "usage: " SFUNC " <tests>\n"
+ "test: < <ret> " ARG_USE " >\n"
+ );
+ exit(1);
+ }
+
+ test_ret = 0;
+ i = 1;
+ while (i < argc) {
+ char *s;
+
+ s = argv[i++];
+ int ret = atoi(s);
+
+ process_args();
+
+ int actual_ret = (int)FUNC(FUNC_IMP);
+ printf("%s: " SFUNC "(" FUNC_STR ") = %i (wanted %i)\n",
+ (actual_ret == ret) ? "PASS" : "FAIL",
+ FUNC_IMP, actual_ret, ret);
+ if (actual_ret != ret) ++test_ret;
+ }
+
+ return test_ret;
+}
diff --git a/tests/tests.h b/tests/tests.h
new file mode 100644
index 0000000..7cc3be2
--- /dev/null
+++ b/tests/tests.h
@@ -0,0 +1,5 @@
+#include "headers.h"
+
+#define _msg(std, fmt, args...) fprintf(std, "%s:%s():%i: " fmt "\n", __FILE__, __func__, __LINE__, ##args)
+#define _stderr_msg(fmt, args...) _msg(stderr, fmt, ##args)
+#define err(fmt, args...) ({ _stderr_msg(fmt, ##args); exit(1); })
diff --git a/tests/testsuite.at b/tests/testsuite.at
new file mode 100644
index 0000000..21de75d
--- /dev/null
+++ b/tests/testsuite.at
@@ -0,0 +1,8 @@
+AT_INIT
+
+dnl m4_include(create.at)
+dnl m4_include(dump.at)
+dnl m4_include(load.at)
+dnl m4_include(show.at)
+dnl m4_include(source.at)
+dnl m4_include(usage.at)
diff --git a/tests/truncate-0.c b/tests/truncate-0.c
new file mode 100644
index 0000000..918c7bd
--- /dev/null
+++ b/tests/truncate-0.c
@@ -0,0 +1,16 @@
+#define FUNC truncate
+#define SFUNC "truncate"
+#define FUNC_STR "\"%s\", %i"
+#define FUNC_IMP path, length
+#define ARG_CNT 2
+#define ARG_USE "<oldpath> <newpath>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *path = s; \
+ \
+ s = argv[i++]; \
+ off_t length; \
+ sscanf(s, "%i", &length);
+
+#include "test-skel-0.c"
diff --git a/tests/truncate64-0.c b/tests/truncate64-0.c
new file mode 100644
index 0000000..f22c525
--- /dev/null
+++ b/tests/truncate64-0.c
@@ -0,0 +1,16 @@
+#define FUNC truncate64
+#define SFUNC "truncate64"
+#define FUNC_STR "\"%s\", %i"
+#define FUNC_IMP path, length
+#define ARG_CNT 2
+#define ARG_USE "<oldpath> <newpath>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *path = s; \
+ \
+ s = argv[i++]; \
+ off64_t length; \
+ sscanf(s, "%i", &length);
+
+#include "test-skel-0.c"
diff --git a/tests/unlink-0.c b/tests/unlink-0.c
new file mode 100644
index 0000000..2afb7dc
--- /dev/null
+++ b/tests/unlink-0.c
@@ -0,0 +1,12 @@
+#define FUNC unlink
+#define SFUNC "unlink"
+#define FUNC_STR "\"%s\""
+#define FUNC_IMP path
+#define ARG_CNT 1
+#define ARG_USE "<path>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *path = s;
+
+#include "test-skel-0.c"
diff --git a/tests/unlinkat-0.c b/tests/unlinkat-0.c
new file mode 100644
index 0000000..bb46349
--- /dev/null
+++ b/tests/unlinkat-0.c
@@ -0,0 +1,19 @@
+#define FUNC unlinkat
+#define SFUNC "unlinkat"
+#define FUNC_STR "%i, \"%s\", %x"
+#define FUNC_IMP dirfd, path, flags
+#define ARG_CNT 3
+#define ARG_USE "<dirfd> <path> <flags>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *path = s; \
+ \
+ s = argv[i++]; \
+ int flags; \
+ sscanf(s, "%i", &flags);
+
+#include "test-skel-0.c"
diff --git a/tests/utime-0.c b/tests/utime-0.c
new file mode 100644
index 0000000..6a51007
--- /dev/null
+++ b/tests/utime-0.c
@@ -0,0 +1,15 @@
+#define FUNC utime
+#define SFUNC "utime"
+#define FUNC_STR "\"%s\", %p"
+#define FUNC_IMP file, times
+#define ARG_CNT 2
+#define ARG_USE "<file> <times:=NULL>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ const struct utimbuf *times = NULL;
+
+#include "test-skel-0.c"
diff --git a/tests/utimensat-0.c b/tests/utimensat-0.c
new file mode 100644
index 0000000..25f7af1
--- /dev/null
+++ b/tests/utimensat-0.c
@@ -0,0 +1,22 @@
+#define FUNC utimensat
+#define SFUNC "utimensat"
+#define FUNC_STR "%i, \"%s\", %p, %x"
+#define FUNC_IMP dirfd, file, times, flags
+#define ARG_CNT 2
+#define ARG_USE "<file> <times:=NULL>"
+
+#define process_args() \
+ s = argv[i++]; \
+ int dirfd = atoi(s); \
+ \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ const struct timespec *times = NULL; \
+ \
+ s = argv[i++]; \
+ int flags; \
+ sscanf(s, "%i", &flags);
+
+#include "test-skel-0.c"
diff --git a/tests/utimes-0.c b/tests/utimes-0.c
new file mode 100644
index 0000000..191b5b9
--- /dev/null
+++ b/tests/utimes-0.c
@@ -0,0 +1,15 @@
+#define FUNC utimes
+#define SFUNC "utimes"
+#define FUNC_STR "\"%s\", %p"
+#define FUNC_IMP file, times
+#define ARG_CNT 2
+#define ARG_USE "<file> <times:=NULL>"
+
+#define process_args() \
+ s = argv[i++]; \
+ char *file = s; \
+ \
+ s = argv[i++]; \
+ const struct timeval *times = NULL;
+
+#include "test-skel-0.c"