* tests/dup.c: New file.
* tests/dup.test: New test.
* tests/dup2.c: New file.
* tests/dup2.test: New test.
* tests/dup3.c: New file.
* tests/dup3.test: New test.
* tests/.gitignore: Add dup, dup2, and dup3.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add dup.test, dup2.test, and dup3.test.
clock_nanosleep
clock_xettime
copy_file_range
+dup
+dup2
+dup3
epoll_create1
eventfd
execve
clock_nanosleep \
clock_xettime \
copy_file_range \
+ dup \
+ dup2 \
+ dup3 \
epoll_create1 \
eventfd \
execve \
clock_xettime.test \
copy_file_range.test \
dumpio.test \
+ dup.test \
+ dup2.test \
+ dup3.test \
epoll_create1.test \
eventfd.test \
execve.test \
--- /dev/null
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+ const int fd = -1;
+ int rc = dup(fd);
+ printf("dup(%d) = %d %s (%m)\n",
+ fd, rc,
+ errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
--- /dev/null
+#!/bin/sh
+
+# Check dup syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -edup -a8 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
--- /dev/null
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_dup2
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+ const long int fd_old = (long int) 0xdeadbeefffffffff;
+ const long int fd_new = (long int) 0xdeadbeeffffffffe;
+ int rc = syscall(__NR_dup2, fd_old, fd_new);
+ printf("dup2(%d, %d) = %d %s (%m)\n",
+ (int) fd_old, (int) fd_new, rc,
+ errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_dup2")
+
+#endif
--- /dev/null
+#!/bin/sh
+
+# Check dup2 syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -edup2 -a13 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
--- /dev/null
+#include "tests.h"
+#include <fcntl.h>
+#include <sys/syscall.h>
+
+#if defined __NR_dup3 && defined O_CLOEXEC
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+ const long int fd_old = (long int) 0xdeadbeefffffffff;
+ const long int fd_new = (long int) 0xdeadbeeffffffffe;
+ int rc = syscall(__NR_dup3, fd_old, fd_new, O_CLOEXEC);
+ printf("dup3(%d, %d, O_CLOEXEC) = %d %s (%m)\n",
+ (int) fd_old, (int) fd_new, rc,
+ errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_dup3 && && O_CLOEXEC")
+
+#endif
--- /dev/null
+#!/bin/sh
+
+# Check dup3 syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -edup3 -a24 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"