]> granicus.if.org Git - strace/commitdiff
tests: add tee.test
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 13 Feb 2016 22:42:52 +0000 (22:42 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 14 Feb 2016 00:36:38 +0000 (00:36 +0000)
* tests/tee.c: New file.
* tests/tee.test: New test.
* tests/.gitignore: Add tee.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add tee.test.

tests/.gitignore
tests/Makefile.am
tests/tee.c [new file with mode: 0644]
tests/tee.test [new file with mode: 0755]

index 73b8340015b00a1efd5b411d1082004cb3963682..fe05d1ed1446283bc88f06a7260b79065c1d77d9 100644 (file)
@@ -99,6 +99,7 @@ stat
 stat64
 statfs
 sysinfo
+tee
 time
 timer_create
 timer_xettime
index 3907637a84297778932ab3d20ffe23a0755101d4..4b443fccd0fbed471c4515db8e010daaff24012c 100644 (file)
@@ -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 (file)
index 0000000..abdf383
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * This file is part of tee 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_tee
+
+# include <assert.h>
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+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 (executable)
index 0000000..1bc7b3a
--- /dev/null
@@ -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"