diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-03-08 07:35:32 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-03-08 09:11:14 -0400 |
commit | d4dee0ebe39627e9d3b90c312f770d7ba73a46f5 (patch) | |
tree | b5613010981c5561febfd3b6dd07076b375a5364 | |
parent | libsandbox: handle symlinks properly (diff) | |
download | sandbox-d4dee0ebe39627e9d3b90c312f770d7ba73a46f5.tar.gz sandbox-d4dee0ebe39627e9d3b90c312f770d7ba73a46f5.tar.bz2 sandbox-d4dee0ebe39627e9d3b90c312f770d7ba73a46f5.zip |
tests: add symlink tests and unify code
Add test cases for symlink behavior and unify some of the test code to
make adding more test cases even easier.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
42 files changed, 327 insertions, 66 deletions
@@ -46,6 +46,8 @@ Makefile.in /tests/*_tst /tests/atconfig /tests/atlocal +/tests/get-group +/tests/get-user /tests/package.m4 /tests/testsuite /tests/testsuite.dir/ diff --git a/configure.ac b/configure.ac index a8a3216..02ce109 100644 --- a/configure.ac +++ b/configure.ac @@ -48,10 +48,12 @@ AC_CHECK_HEADERS_ONCE([ \ errno.h \ execinfo.h \ fcntl.h \ + grp.h \ libgen.h \ limits.h \ memory.h \ pthread.h \ + pwd.h \ siginfo.h \ signal.h \ sigsegv.h \ @@ -27,6 +27,9 @@ #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif +#ifdef HAVE_GRP_H +# include <grp.h> +#endif #ifdef HAVE_LIBGEN_H # include <libgen.h> #endif @@ -39,6 +42,9 @@ #ifdef HAVE_PTHREAD_H # include <pthread.h> #endif +#ifdef HAVE_PWD_H +# include <pwd.h> +#endif #ifdef HAVE_SIGINFO_H # include <siginfo.h> #endif diff --git a/libsbutil/get_sandbox_log.c b/libsbutil/get_sandbox_log.c index 3fa0835..c300a24 100644 --- a/libsbutil/get_sandbox_log.c +++ b/libsbutil/get_sandbox_log.c @@ -21,18 +21,23 @@ static void _get_sb_log(char *path, const char *env, const char *prefix) sandbox_log_env = getenv(env); - /* THIS CHUNK BREAK THINGS BY DOING THIS: - * SANDBOX_LOG=/tmp/sandbox-app-admin/superadduser-1.0.7-11063.log - */ - if ((NULL != sandbox_log_env) && - (NULL != strchr(sandbox_log_env, '/'))) - sandbox_log_env = NULL; - - snprintf(path, SB_PATH_MAX, "%s%s%s%s%d%s", + if (sandbox_log_env && is_env_on(ENV_SANDBOX_TESTING)) { + /* When testing, just use what the env says to */ + strncpy(path, sandbox_log_env, SB_PATH_MAX); + } else { + /* THIS CHUNK BREAK THINGS BY DOING THIS: + * SANDBOX_LOG=/tmp/sandbox-app-admin/superadduser-1.0.7-11063.log + */ + if ((NULL != sandbox_log_env) && + (NULL != strchr(sandbox_log_env, '/'))) + sandbox_log_env = NULL; + + snprintf(path, SB_PATH_MAX, "%s%s%s%s%d%s", SANDBOX_LOG_LOCATION, prefix, (sandbox_log_env == NULL ? "" : sandbox_log_env), (sandbox_log_env == NULL ? "" : "-"), getpid(), LOG_FILE_EXT); + } restore_errno(); } diff --git a/tests/Makefile.am b/tests/Makefile.am index 568e2d9..5255f24 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,6 +8,9 @@ EXTRA_DIST = atlocal.in package.m4.in $(AT_FILES) $(TESTSUITE) \ INCLUDES = -I$(top_srcdir) check_PROGRAMS = \ + get-group \ + get-user \ + \ access-0 \ chmod-0 \ chown-0 \ @@ -50,7 +53,14 @@ check_PROGRAMS = \ sb_printf_tst dist_check_SCRIPTS = \ - access.sh \ + access-1.sh \ + chmod-1.sh \ + chown-1.sh \ + fchmodat-1.sh \ + fchownat-1.sh \ + fchownat-2.sh \ + lchown-1.sh \ + script-0 \ script-0.sh \ script-1.sh \ script-2.sh \ diff --git a/tests/access-1.sh b/tests/access-1.sh new file mode 100755 index 0000000..efa1e18 --- /dev/null +++ b/tests/access-1.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# We should not trigger sandbox on write requests with access() + +addwrite $PWD + +export SANDBOX_LOG=$PWD/sb.log +access-0 -1 rwx / || exit 1 +test ! -e sb.log diff --git a/tests/access.at b/tests/access.at new file mode 100644 index 0000000..1ef7e74 --- /dev/null +++ b/tests/access.at @@ -0,0 +1,2 @@ +m4_defun([SB_SECTION],[access]) +SB_CHECK(1) diff --git a/tests/access.sh b/tests/access.sh deleted file mode 100755 index d1c5cfb..0000000 --- a/tests/access.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./access-0 0 rwx / diff --git a/tests/atlocal.in b/tests/atlocal.in index 6dda46e..6929e50 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -1,3 +1,6 @@ -export abs_top_srcdir abs_top_builddir abs_builddir -export PATH=$abs_top_srcdir/src:$abs_top_builddir/src:$abs_builddir:$PATH +export abs_top_srcdir abs_top_builddir abs_srcdir abs_builddir +export PATH=$abs_top_srcdir/src:$abs_top_builddir/src:$abs_builddir:$abs_srcdir:$PATH export AWK="@AWK@" + +export SB_UID=$(get-user) +export SB_GID=$(get-group) diff --git a/tests/chmod-1.sh b/tests/chmod-1.sh new file mode 100755 index 0000000..9a81d19 --- /dev/null +++ b/tests/chmod-1.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# make sure symlinks with chmod() work properly + +addwrite $PWD + +rm -rf deny link sb.log +mkdir deny +touch deny/file +ln -s deny/file link + +# this *should not* trigger a sandbox violation +chmod-0 0 link 0666 || exit 1 + +# this *should* trigger a sandbox violation +adddeny $PWD/deny +export SANDBOX_LOG=$PWD/sb.log +unset SANDBOX_VERBOSE +chmod-0 -1 link 0666 || exit 1 +test -s sb.log diff --git a/tests/chmod.at b/tests/chmod.at new file mode 100644 index 0000000..21abe75 --- /dev/null +++ b/tests/chmod.at @@ -0,0 +1,2 @@ +m4_defun([SB_SECTION],[chmod]) +SB_CHECK(1) diff --git a/tests/chown-1.sh b/tests/chown-1.sh new file mode 100755 index 0000000..28292a0 --- /dev/null +++ b/tests/chown-1.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# make sure symlinks with chown() work properly + +addwrite $PWD + +rm -rf deny link +mkdir deny +touch deny/file +ln -s deny/file link + +# this *should not* trigger a sandbox violation +chown-0 0 link ${SB_UID} ${SB_GID} || exit 1 + +# this *should* trigger a sandbox violation +adddeny $PWD/deny +export SANDBOX_LOG=$PWD/sb.log +unset SANDBOX_VERBOSE +chown-0 -1 link ${SB_UID} ${SB_GID} || exit 1 +test -s sb.log diff --git a/tests/chown.at b/tests/chown.at new file mode 100644 index 0000000..3493d07 --- /dev/null +++ b/tests/chown.at @@ -0,0 +1,2 @@ +m4_defun([SB_SECTION],[chown]) +SB_CHECK(1) diff --git a/tests/faccessat-0.c b/tests/faccessat-0.c index 20f8e03..6c9d023 100644 --- a/tests/faccessat-0.c +++ b/tests/faccessat-0.c @@ -8,7 +8,7 @@ #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *file = s; \ @@ -18,7 +18,6 @@ sscanf(s, "%i", &mode); \ \ s = argv[i++]; \ - int flags = 0; \ - sscanf(s, "%i", &flags); + int flags = at_get_flags(s); #include "test-skel-0.c" diff --git a/tests/fchmodat-0.c b/tests/fchmodat-0.c index b4fa90f..94cd924 100644 --- a/tests/fchmodat-0.c +++ b/tests/fchmodat-0.c @@ -8,7 +8,7 @@ #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *file = s; \ @@ -18,7 +18,6 @@ sscanf(s, "%i", &mode); \ \ s = argv[i++]; \ - int flags = 0; \ - sscanf(s, "%i", &flags); + int flags = at_get_flags(s); #include "test-skel-0.c" diff --git a/tests/fchmodat-1.sh b/tests/fchmodat-1.sh new file mode 100755 index 0000000..bd3766d --- /dev/null +++ b/tests/fchmodat-1.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# make sure symlinks with fchmodat() work properly + +addwrite $PWD + +rm -rf deny link +mkdir deny +touch deny/file +ln -s deny/file link + +# this *should not* trigger a sandbox violation +fchmodat-0 0 AT_FDCWD link 0666 0 || exit 1 + +# this *should* trigger a sandbox violation +adddeny $PWD/deny +export SANDBOX_LOG=$PWD/sb.log +unset SANDBOX_VERBOSE +fchmodat-0 -1 AT_FDCWD link 0666 0 || exit 1 +test -s sb.log diff --git a/tests/fchmodat.at b/tests/fchmodat.at new file mode 100644 index 0000000..cd90740 --- /dev/null +++ b/tests/fchmodat.at @@ -0,0 +1,2 @@ +m4_defun([SB_SECTION],[fchmodat]) +SB_CHECK(1) diff --git a/tests/fchownat-0.c b/tests/fchownat-0.c index 5cfef45..9243b20 100644 --- a/tests/fchownat-0.c +++ b/tests/fchownat-0.c @@ -4,11 +4,11 @@ #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 ARG_USE "<dirfd> <file> <uid> <gid> <flags>" #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *file = s; \ @@ -20,7 +20,6 @@ gid_t gid = atoi(s); \ \ s = argv[i++]; \ - int flags = 0; \ - sscanf(s, "%i", &flags); + int flags = at_get_flags(s); #include "test-skel-0.c" diff --git a/tests/fchownat-1.sh b/tests/fchownat-1.sh new file mode 100755 index 0000000..3f3d117 --- /dev/null +++ b/tests/fchownat-1.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# make sure symlinks with fchownat(AT_SYMLINK_NOFOLLOW) work properly + +addwrite $PWD + +rm -rf deny link +mkdir deny +touch deny/file +ln -s deny/file link + +adddeny $PWD/deny + +# this should not fail +exec fchownat-0 0 AT_FDCWD link ${SB_UID} ${SB_GID} AT_SYMLINK_NOFOLLOW diff --git a/tests/fchownat-2.sh b/tests/fchownat-2.sh new file mode 100755 index 0000000..997c4c4 --- /dev/null +++ b/tests/fchownat-2.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# make sure symlinks with fchownat() work properly + +addwrite $PWD + +rm -rf deny link +mkdir deny +touch deny/file +ln -s deny/file link + +# this *should not* trigger a sandbox violation +fchownat-0 0 AT_FDCWD link ${SB_UID} ${SB_GID} 0 || exit 1 + +# this *should* trigger a sandbox violation +adddeny $PWD/deny +export SANDBOX_LOG=$PWD/sb.log +unset SANDBOX_VERBOSE +fchownat-0 -1 AT_FDCWD link ${SB_UID} ${SB_GID} 0 || exit 1 +test -s sb.log diff --git a/tests/fchownat.at b/tests/fchownat.at new file mode 100644 index 0000000..476dbe5 --- /dev/null +++ b/tests/fchownat.at @@ -0,0 +1,3 @@ +m4_defun([SB_SECTION],[fchownat]) +SB_CHECK(1) +SB_CHECK(2) diff --git a/tests/futimesat-0.c b/tests/futimesat-0.c index 0fdc5ef..4249a1d 100644 --- a/tests/futimesat-0.c +++ b/tests/futimesat-0.c @@ -8,7 +8,7 @@ #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *file = s; \ diff --git a/tests/get-group.c b/tests/get-group.c new file mode 100644 index 0000000..8138967 --- /dev/null +++ b/tests/get-group.c @@ -0,0 +1,43 @@ +#include "tests.h" + +static int usage(int status) +{ + fputs( + "Usage: get-group [args]\n" + " `get-group` return current gid\n" + " `get-group file` return gid of file\n" + " `get-group -group` return gid of group name\n" + , status ? stderr : stdout + ); + return status; +} + +int main(int argc, char *argv[]) +{ + switch (argc) { + case 1: + printf("%i\n", getgid()); + return 0; + + case 2: + if (!strcmp(argv[1], "-h")) + return usage(0); + + if (*argv[1] == '-') { + const char *name = argv[1] + 1; + struct group *grp = getgrnam(name); + if (!grp) + errp("getgrnam(%s) failed", name); + printf("%i\n", grp->gr_gid); + } else { + const char *file = argv[1]; + struct stat st; + if (lstat(file, &st)) + errp("lstat(%s) failed", file); + printf("%i\n", st.st_gid); + } + return 0; + } + + return usage(1); +} diff --git a/tests/get-user.c b/tests/get-user.c new file mode 100644 index 0000000..f85e299 --- /dev/null +++ b/tests/get-user.c @@ -0,0 +1,43 @@ +#include "tests.h" + +static int usage(int status) +{ + fputs( + "Usage: get-user [args]\n" + " `get-user` return current uid\n" + " `get-user file` return uid of file\n" + " `get-user -user` return uid of user name\n" + , status ? stderr : stdout + ); + return status; +} + +int main(int argc, char *argv[]) +{ + switch (argc) { + case 1: + printf("%i\n", getuid()); + return 0; + + case 2: + if (!strcmp(argv[1], "-h")) + return usage(0); + + if (*argv[1] == '-') { + const char *name = argv[1] + 1; + struct passwd *pwd = getpwnam(name); + if (!pwd) + errp("getpwnam(%s) failed", name); + printf("%i\n", pwd->pw_uid); + } else { + const char *file = argv[1]; + struct stat st; + if (lstat(file, &st)) + errp("lstat(%s) failed", file); + printf("%i\n", st.st_uid); + } + return 0; + } + + return usage(1); +} diff --git a/tests/lchown-1.sh b/tests/lchown-1.sh new file mode 100755 index 0000000..c7cc4a4 --- /dev/null +++ b/tests/lchown-1.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# make sure symlinks with lchown() work properly + +addwrite $PWD + +rm -rf deny link +mkdir deny +touch deny/file +ln -s deny/file link + +adddeny $PWD/deny + +# this should not fail +exec lchown-0 0 link ${SB_UID} ${SB_GID} diff --git a/tests/lchown.at b/tests/lchown.at new file mode 100644 index 0000000..158de15 --- /dev/null +++ b/tests/lchown.at @@ -0,0 +1,2 @@ +m4_defun([SB_SECTION],[lchown]) +SB_CHECK(1) diff --git a/tests/linkat-0.c b/tests/linkat-0.c index 4489168..8c1af52 100644 --- a/tests/linkat-0.c +++ b/tests/linkat-0.c @@ -8,19 +8,18 @@ #define process_args() \ s = argv[i++]; \ - int olddirfd = atoi(s); \ + int olddirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *oldpath = s; \ \ s = argv[i++]; \ - int newdirfd = atoi(s); \ + int newdirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *newpath = s; \ \ s = argv[i++]; \ - int flags = 0; \ - sscanf(s, "%i", &flags); + int flags = at_get_flags(s); #include "test-skel-0.c" diff --git a/tests/local.at b/tests/local.at index 3ae6933..8df87c1 100644 --- a/tests/local.at +++ b/tests/local.at @@ -1 +1,13 @@ -m4_defun([AT_SB_CHECK],[AT_CHECK([sandbox.sh $1],[$2],[$3],[$4],[$5],[$6])]) +m4_defun([SB_RUN],[env SANDBOX_BEEP=0 SANDBOX_LOG="$PWD/sandbox.log" sandbox.sh]) + +m4_defun([AT_SB_CHECK],[AT_CHECK([SB_RUN $1],[$2],[$3],[$4],[$5],[$6])]) + +m4_defun([SB_CHECK],[dnl +AT_SETUP([SB_SECTION/$1]) +AT_XFAIL_IF([]SB_SECTION[-0 >/dev/null ; test $? -eq 77]) +AT_SB_CHECK( + [. $abs_top_srcdir/tests/]SB_SECTION[-$1.sh], + [0], + m4_ifval($2,$2,[ignore]), + m4_ifval($3,$3,[ignore])) +AT_CLEANUP]) diff --git a/tests/mkdirat-0.c b/tests/mkdirat-0.c index 37f26ff..925bfb5 100644 --- a/tests/mkdirat-0.c +++ b/tests/mkdirat-0.c @@ -8,7 +8,7 @@ #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *path = s; \ diff --git a/tests/mkfifoat-0.c b/tests/mkfifoat-0.c index eb13fb4..2a00336 100644 --- a/tests/mkfifoat-0.c +++ b/tests/mkfifoat-0.c @@ -8,7 +8,7 @@ #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *file = s; \ diff --git a/tests/mknodat-0.c b/tests/mknodat-0.c index 6d71ebf..98e1f83 100644 --- a/tests/mknodat-0.c +++ b/tests/mknodat-0.c @@ -10,7 +10,7 @@ #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *file = s; \ diff --git a/tests/openat-0.c b/tests/openat-0.c index 351044d..9434342 100644 --- a/tests/openat-0.c +++ b/tests/openat-0.c @@ -8,13 +8,12 @@ #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *file = s; \ \ s = argv[i++]; \ - int flags; \ - sscanf(s, "%i", &flags); + int flags = at_get_flags(s); #include "test-skel-0.c" diff --git a/tests/openat64-0.c b/tests/openat64-0.c index a4004ae..d1a835c 100644 --- a/tests/openat64-0.c +++ b/tests/openat64-0.c @@ -8,13 +8,12 @@ #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *file = s; \ \ s = argv[i++]; \ - int flags; \ - sscanf(s, "%i", &flags); + int flags = at_get_flags(s); #include "test-skel-0.c" diff --git a/tests/renameat-0.c b/tests/renameat-0.c index e5c4357..fcb5c88 100644 --- a/tests/renameat-0.c +++ b/tests/renameat-0.c @@ -8,13 +8,13 @@ #define process_args() \ s = argv[i++]; \ - int olddirfd = atoi(s); \ + int olddirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *oldpath = s; \ \ s = argv[i++]; \ - int newdirfd = atoi(s); \ + int newdirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *newpath = s; diff --git a/tests/sb_printf_tst.c b/tests/sb_printf_tst.c index d189a30..443c2c2 100644 --- a/tests/sb_printf_tst.c +++ b/tests/sb_printf_tst.c @@ -19,11 +19,11 @@ int main(int argc, char *argv[]) T("%d", 123); T("%d", -123); T("%u", 1000); - T("%zi", argc); - T("%zi", -argc); - T("%zd", 123); - T("%zd", -123); - T("%zu", 1000); + T("%zi", (ssize_t)argc); + T("%zi", (ssize_t)-argc); + T("%zd", (ssize_t)123); + T("%zd", (ssize_t)-123); + T("%zu", (size_t)1000); T("%x", argc); T("%x", 0xabcdef); @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) T("%s", "CoW"); T("%s", "!HI!"); - size_t i; + int i; for (i = 0; i < 6; ++i) T("%s%*s%s", "{pre}", i, "cow", "{post}"); diff --git a/tests/script-0 b/tests/script-0 new file mode 100755 index 0000000..4153f30 --- /dev/null +++ b/tests/script-0 @@ -0,0 +1,3 @@ +#!/bin/sh +# dummy for local.at:SB_CHECK() +exit 0 diff --git a/tests/script.at b/tests/script.at index 47e2798..3b40b29 100644 --- a/tests/script.at +++ b/tests/script.at @@ -1,12 +1,4 @@ -m4_defun([SB_CHECK],[dnl -AT_SETUP([scripts/$1]) -AT_CHECK( - [env SANDBOX_BEEP=0 sandbox.sh . $abs_top_srcdir/tests/script-$1.sh], - [0], - m4_ifval($2,$2,[ignore]), - m4_ifval($3,$3,[ignore])) -AT_CLEANUP]) - +m4_defun([SB_SECTION],[script]) SB_CHECK(0) SB_CHECK(1,, [touch: cannot touch `/a/b/c/d/e/f/g/no/real/path/so/dont/make/it': No such file or directory ]) diff --git a/tests/symlinkat-0.c b/tests/symlinkat-0.c index 0f1618b..f668829 100644 --- a/tests/symlinkat-0.c +++ b/tests/symlinkat-0.c @@ -11,7 +11,7 @@ char *oldpath = s; \ \ s = argv[i++]; \ - int newdirfd = atoi(s); \ + int newdirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *newpath = s; diff --git a/tests/test-skel-0.c b/tests/test-skel-0.c index c782704..0fcb17b 100644 --- a/tests/test-skel-0.c +++ b/tests/test-skel-0.c @@ -4,6 +4,25 @@ # define CONFIG 1 #endif +int at_get_fd(const char *str_dirfd) +{ + if (!strcmp(str_dirfd, "AT_FDCWD")) + return AT_FDCWD; + else + return atoi(str_dirfd); +} + +int at_get_flags(const char *str_flags) +{ + if (!strcmp(str_flags, "AT_SYMLINK_NOFOLLOW")) + return AT_SYMLINK_NOFOLLOW; + else { + int flags = 0; + sscanf(str_flags, "%i", &flags); + return flags; + } +} + int main(int argc, char *argv[]) { #if CONFIG @@ -23,12 +42,12 @@ int main(int argc, char *argv[]) char *s; s = argv[i++]; - int ret = atoi(s); + long ret = atoi(s); process_args(); - int actual_ret = (int)FUNC(FUNC_IMP); - printf("%s: " SFUNC "(" FUNC_STR ") = %i (wanted %i)\n", + long actual_ret = (long)FUNC(FUNC_IMP); + printf("%s: " SFUNC "(" FUNC_STR ") = %li (wanted %li)\n", (actual_ret == ret) ? "PASS" : "FAIL", FUNC_IMP, actual_ret, ret); if (actual_ret != ret) ++test_ret; @@ -37,6 +56,6 @@ int main(int argc, char *argv[]) return test_ret; #else puts("not implemented"); - return 0; + return 77; #endif } diff --git a/tests/testsuite.at b/tests/testsuite.at index 4e55441..e305e25 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -1,5 +1,11 @@ AT_INIT +m4_include(access.at) +m4_include(chmod.at) +m4_include(chown.at) +m4_include(fchmodat.at) +m4_include(fchownat.at) +m4_include(lchown.at) m4_include(libsigsegv.at) m4_include(sb_printf.at) m4_include(script.at) diff --git a/tests/unlinkat-0.c b/tests/unlinkat-0.c index b836b08..3653965 100644 --- a/tests/unlinkat-0.c +++ b/tests/unlinkat-0.c @@ -8,13 +8,12 @@ #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *path = s; \ \ s = argv[i++]; \ - int flags; \ - sscanf(s, "%i", &flags); + int flags = at_get_flags(s); #include "test-skel-0.c" diff --git a/tests/utimensat-0.c b/tests/utimensat-0.c index 34e1339..ad510a0 100644 --- a/tests/utimensat-0.c +++ b/tests/utimensat-0.c @@ -8,7 +8,7 @@ #define process_args() \ s = argv[i++]; \ - int dirfd = atoi(s); \ + int dirfd = at_get_fd(s); \ \ s = argv[i++]; \ char *file = s; \ @@ -17,7 +17,6 @@ const struct timespec *times = NULL; \ \ s = argv[i++]; \ - int flags; \ - sscanf(s, "%i", &flags); + int flags = at_get_flags(s); #include "test-skel-0.c" |