From 25c804ce42261b24b19d35c637bf2745c237ee07 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 7 Apr 2015 21:18:23 +0000 Subject: [PATCH] tests: add a test for "resuming interrupted nanosleep" * tests/restart_syscall.test: New test. * tests/restart_syscall.expected: New file. * tests/restart_syscall_unknown.expected: Likewise. * tests/Makefile.am (TESTS): Add restart_syscall.test. (EXTRA_DIST): Add restart_syscall.expected (TEST_LOG_COMPILER): Change to "env". (OS, ARCH, AM_TEST_LOG_FLAGS): Define. and restart_syscall_unknown.expected. --- tests/Makefile.am | 8 +++++++- tests/restart_syscall.expected | 2 ++ tests/restart_syscall.test | 25 +++++++++++++++++++++++++ tests/restart_syscall_unknown.expected | 2 ++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tests/restart_syscall.expected create mode 100755 tests/restart_syscall.test create mode 100644 tests/restart_syscall_unknown.expected diff --git a/tests/Makefile.am b/tests/Makefile.am index e5dae02a..7ace705b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,7 @@ # Automake input for strace tests. +OS = linux +ARCH = @arch@ AM_CFLAGS = $(WARN_CFLAGS) AM_CPPFLAGS = -I$(top_builddir)/$(OS)/$(ARCH) \ -I$(top_srcdir)/$(OS)/$(ARCH) \ @@ -91,11 +93,13 @@ TESTS = \ detach-sleeping.test \ detach-stopped.test \ detach-running.test \ + restart_syscall.test \ strace-k.test net-fd.log: net.log -TEST_LOG_COMPILER = $(srcdir)/run.sh +TEST_LOG_COMPILER = env +AM_TEST_LOG_FLAGS = STRACE_ARCH=$(ARCH) $(srcdir)/run.sh EXTRA_DIST = init.sh run.sh match.awk \ caps.awk \ @@ -112,6 +116,8 @@ EXTRA_DIST = init.sh run.sh match.awk \ net-yy-accept.awk \ net-yy-connect.awk \ pipe.expected \ + restart_syscall.expected \ + restart_syscall_unknown.expected \ select.awk \ sigaction.awk \ statfs.expected \ diff --git a/tests/restart_syscall.expected b/tests/restart_syscall.expected new file mode 100644 index 00000000..af9267de --- /dev/null +++ b/tests/restart_syscall.expected @@ -0,0 +1,2 @@ +restart_syscall(<... resuming interrupted nanosleep ...>) = 0 ++++ exited with 0 +++ diff --git a/tests/restart_syscall.test b/tests/restart_syscall.test new file mode 100755 index 00000000..5ae3a1d5 --- /dev/null +++ b/tests/restart_syscall.test @@ -0,0 +1,25 @@ +#!/bin/sh + +# Check how "resuming interrupted nanosleep" works. + +. "${srcdir=.}/init.sh" + +check_prog sleep +check_prog grep +run_strace -enanosleep sleep 1 +grep nanosleep < "$LOG" > /dev/null || + framework_skip_ 'sleep does not use nanosleep' + +./set_ptracer_any sleep 2 & +sleep 1 +run_strace -q -erestart_syscall -p $! + +case "$STRACE_ARCH" in + alpha|mips|or1k|s390|s390x) + # These architectures use the same register + # both for syscall number and syscall return code. + match_diff "$LOG" "$srcdir/restart_syscall_unknown.expected" + ;; + *) match_diff + ;; +esac diff --git a/tests/restart_syscall_unknown.expected b/tests/restart_syscall_unknown.expected new file mode 100644 index 00000000..5f168953 --- /dev/null +++ b/tests/restart_syscall_unknown.expected @@ -0,0 +1,2 @@ +restart_syscall(<... resuming interrupted system call ...>) = 0 ++++ exited with 0 +++ -- 2.40.0