Implement dumping of vmsplice syscall
* syscall.c (dumpio): Add SEN_vmsplice. * NEWS: Mention this. * tests/vmsplice.c: New file. * tests/vmsplice.test: New test. * tests/.gitignore: Add vmsplice. * tests/Makefile.am (check_PROGRAMS): Likewise. (TESTS): Add vmsplice.test.
This commit is contained in:
parent
6c93254614
commit
13870c5482
1
NEWS
1
NEWS
@ -11,6 +11,7 @@ Noteworthy changes in release ?.?? (????-??-??)
|
||||
* Implemented caching of netlink conversations to reduce amount of time
|
||||
spent in decoding socket details in -yy mode.
|
||||
* Implemented decoding of copy_file_range syscall.
|
||||
* Implemented dumping of vmsplice syscall.
|
||||
|
||||
* Bug fixes
|
||||
* Fixed build on arc, metag, nios2, or1k, and tile architectures.
|
||||
|
@ -707,6 +707,7 @@ dumpio(struct tcb *tcp)
|
||||
dumpstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
|
||||
break;
|
||||
case SEN_writev:
|
||||
case SEN_vmsplice:
|
||||
dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
|
||||
break;
|
||||
case SEN_sendmsg:
|
||||
|
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
@ -121,6 +121,7 @@ userfaultfd
|
||||
utime
|
||||
utimensat
|
||||
vfork-f
|
||||
vmsplice
|
||||
wait
|
||||
xattr
|
||||
xet_robust_list
|
||||
|
@ -169,6 +169,7 @@ check_PROGRAMS = \
|
||||
utime \
|
||||
utimensat \
|
||||
vfork-f \
|
||||
vmsplice \
|
||||
wait \
|
||||
xattr \
|
||||
xet_robust_list \
|
||||
@ -312,6 +313,7 @@ TESTS = \
|
||||
utime.test \
|
||||
utimensat.test \
|
||||
vfork-f.test \
|
||||
vmsplice.test \
|
||||
wait.test \
|
||||
xattr.test \
|
||||
xet_robust_list.test \
|
||||
|
106
tests/vmsplice.c
Normal file
106
tests/vmsplice.c
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* This file is part of vmsplice strace test.
|
||||
*
|
||||
* Copyright (c) 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>
|
||||
|
||||
#if defined __NR_vmsplice
|
||||
|
||||
# include <assert.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
# include <sys/uio.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
tprintf("%s", "");
|
||||
|
||||
int fds[2];
|
||||
if (pipe(fds))
|
||||
perror_msg_and_fail("pipe");
|
||||
assert(0 == fds[0]);
|
||||
assert(1 == fds[1]);
|
||||
|
||||
static const char w0_c[] = "012";
|
||||
const char *w0_d = hexdump_strdup(w0_c);
|
||||
void *w0 = tail_memdup(w0_c, LENGTH_OF(w0_c));
|
||||
|
||||
static const char w1_c[] = "34567";
|
||||
const char *w1_d = hexdump_strdup(w1_c);
|
||||
void *w1 = tail_memdup(w1_c, LENGTH_OF(w1_c));
|
||||
|
||||
static const char w2_c[] = "89abcde";
|
||||
const char *w2_d = hexdump_strdup(w2_c);
|
||||
void *w2 = tail_memdup(w2_c, LENGTH_OF(w2_c));
|
||||
|
||||
const struct iovec iov_[] = {
|
||||
{
|
||||
.iov_base = w0,
|
||||
.iov_len = LENGTH_OF(w0_c)
|
||||
}, {
|
||||
.iov_base = w1,
|
||||
.iov_len = LENGTH_OF(w1_c)
|
||||
}, {
|
||||
.iov_base = w2,
|
||||
.iov_len = LENGTH_OF(w2_c)
|
||||
}
|
||||
};
|
||||
const struct iovec *iov = tail_memdup(iov_, sizeof(iov_));
|
||||
const unsigned int len =
|
||||
LENGTH_OF(w0_c) + LENGTH_OF(w1_c) + LENGTH_OF(w2_c);
|
||||
|
||||
tprintf("vmsplice(1, [{\"%s\", %u}, {\"%s\", %u}"
|
||||
", {\"%s\", %u}], %u, %s) = %u\n"
|
||||
" * %u bytes in buffer 0\n"
|
||||
" | 00000 %-49s %-16s |\n"
|
||||
" * %u bytes in buffer 1\n"
|
||||
" | 00000 %-49s %-16s |\n"
|
||||
" * %u bytes in buffer 2\n"
|
||||
" | 00000 %-49s %-16s |\n",
|
||||
w0_c, LENGTH_OF(w0_c), w1_c, LENGTH_OF(w1_c),
|
||||
w2_c, LENGTH_OF(w2_c), ARRAY_SIZE(iov_),
|
||||
"SPLICE_F_NONBLOCK", len,
|
||||
LENGTH_OF(w0_c), w0_d, w0_c,
|
||||
LENGTH_OF(w1_c), w1_d, w1_c, LENGTH_OF(w2_c), w2_d, w2_c);
|
||||
|
||||
const long rc = syscall(__NR_vmsplice, 1, iov, ARRAY_SIZE(iov_), 2);
|
||||
if (rc < 0)
|
||||
perror_msg_and_skip("vmsplice");
|
||||
assert(rc == (int) len);
|
||||
|
||||
tprintf("+++ exited with 0 +++\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SKIP_MAIN_UNDEFINED("__NR_vmsplice")
|
||||
|
||||
#endif
|
11
tests/vmsplice.test
Executable file
11
tests/vmsplice.test
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check decoding of vmsplice syscall.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
|
||||
run_prog > /dev/null
|
||||
OUT="$LOG.out"
|
||||
run_strace -ewrite=1 -evmsplice $args > "$OUT"
|
||||
match_diff "$LOG" "$OUT"
|
||||
rm -f "$OUT"
|
Loading…
Reference in New Issue
Block a user