From: Dmitry V. Levin Date: Sat, 13 Feb 2016 22:42:52 +0000 (+0000) Subject: tests: add tee.test X-Git-Tag: v4.12~549 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c93254614ae11d708378544fa64d79e0b1e13b2;p=strace tests: add tee.test * tests/tee.c: New file. * tests/tee.test: New test. * tests/.gitignore: Add tee. * tests/Makefile.am (check_PROGRAMS): Likewise. (TESTS): Add tee.test. --- diff --git a/tests/.gitignore b/tests/.gitignore index 73b83400..fe05d1ed 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -99,6 +99,7 @@ stat stat64 statfs sysinfo +tee time timer_create timer_xettime diff --git a/tests/Makefile.am b/tests/Makefile.am index 3907637a..4b443fcc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -147,6 +147,7 @@ check_PROGRAMS = \ stat64 \ statfs \ sysinfo \ + tee \ time \ timer_create \ timer_xettime \ @@ -290,6 +291,7 @@ TESTS = \ statfs.test \ sun_path.test \ sysinfo.test \ + tee.test \ time.test \ timer_create.test \ timer_xettime.test \ diff --git a/tests/tee.c b/tests/tee.c new file mode 100644 index 00000000..abdf3830 --- /dev/null +++ b/tests/tee.c @@ -0,0 +1,62 @@ +/* + * This file is part of tee strace test. + * + * Copyright (c) 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 + +#if defined __NR_tee + +# include +# include +# include +# include + +int +main(void) +{ + const long int fd_in = (long int) 0xdeadbeefffffffff; + const long int fd_out = (long int) 0xdeadbeeffffffffe; + const size_t len = (size_t) 0xdeadbef3facefed3ULL; + const unsigned int flags = 15; + + assert(syscall(__NR_tee, fd_in, fd_out, + len, flags) == -1); + printf("tee(%d, %d, %zu, %s) = -1 %s (%m)\n", + (int) fd_in, (int) fd_out, len, + "SPLICE_F_MOVE|SPLICE_F_NONBLOCK|SPLICE_F_MORE|SPLICE_F_GIFT", + errno == ENOSYS ? "ENOSYS" : "EBADF"); + puts("+++ exited with 0 +++"); + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_tee") + +#endif diff --git a/tests/tee.test b/tests/tee.test new file mode 100755 index 00000000..1bc7b3ae --- /dev/null +++ b/tests/tee.test @@ -0,0 +1,11 @@ +#!/bin/sh + +# Check tee syscall decoding. + +. "${srcdir=.}/init.sh" + +run_prog > /dev/null +OUT="$LOG.out" +run_strace -etee $args > "$OUT" +match_diff "$LOG" "$OUT" +rm -f "$OUT"