From: Dmitry V. Levin Date: Tue, 26 Apr 2016 16:11:48 +0000 (+0000) Subject: tests: check decoding of renameat2 syscall X-Git-Tag: v4.12~274 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f41eaebddfa23e550aba4550a894bd18c41a7cb2;p=strace tests: check decoding of renameat2 syscall * tests/renameat2.c: New file. * tests/renameat2.test: New test. * tests/.gitignore: Add renameat2. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add renameat2.test. --- diff --git a/tests/.gitignore b/tests/.gitignore index c7db886e..9195b5b7 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -149,6 +149,7 @@ reboot recvmsg rename renameat +renameat2 restart_syscall rmdir rt_sigpending diff --git a/tests/Makefile.am b/tests/Makefile.am index 25092e90..a418b03f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -200,7 +200,8 @@ check_PROGRAMS = \ reboot \ recvmsg \ rename \ - renameat\ + renameat \ + renameat2 \ restart_syscall \ rmdir \ rt_sigpending \ @@ -463,6 +464,7 @@ DECODER_TESTS = \ recvmsg.test \ rename.test \ renameat.test \ + renameat2.test \ rmdir.test \ rt_sigpending.test \ rt_sigprocmask.test \ diff --git a/tests/renameat2.c b/tests/renameat2.c new file mode 100644 index 00000000..28a1b5ba --- /dev/null +++ b/tests/renameat2.c @@ -0,0 +1,62 @@ +/* + * Check decoding of renameat2 syscall. + * + * Copyright (c) 2015-2016 Dmitry V. Levin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "tests.h" +#include + +#ifdef __NR_renameat2 + +# include +# include + +int +main(void) +{ + static const char oldpath[] = "renameat2_oldpath"; + static const char newpath[] = "renameat2_newpath"; + const unsigned long olddirfd = + (unsigned long) 0xfacefeedffffffff; + const unsigned long newdirfd = + (unsigned long) 0xfacefeed00000000 | -100U; + + long rc = syscall(__NR_renameat2, + olddirfd, oldpath, newdirfd, newpath, 1); + printf("renameat2(%d, \"%s\", AT_FDCWD, \"%s\", RENAME_NOREPLACE)" + " = %ld %s (%m)\n", + (int) olddirfd, oldpath, newpath, rc, errno2name()); + + puts("+++ exited with 0 +++"); + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_renameat2") + +#endif diff --git a/tests/renameat2.test b/tests/renameat2.test new file mode 100755 index 00000000..4c176bbd --- /dev/null +++ b/tests/renameat2.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check renameat2 syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff