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.
This commit is contained in:
2016-04-26 16:11:48 +00:00
parent 96cf7d79b3
commit f41eaebddf
4 changed files with 72 additions and 1 deletions

1
tests/.gitignore vendored
View File

@ -149,6 +149,7 @@ reboot
recvmsg
rename
renameat
renameat2
restart_syscall
rmdir
rt_sigpending

View File

@ -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 \

62
tests/renameat2.c Normal file
View File

@ -0,0 +1,62 @@
/*
* Check decoding of renameat2 syscall.
*
* Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
* 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 <sys/syscall.h>
#ifdef __NR_renameat2
# include <stdio.h>
# include <unistd.h>
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

6
tests/renameat2.test Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# Check renameat2 syscall decoding.
. "${srcdir=.}/init.sh"
run_strace_match_diff