]> granicus.if.org Git - strace/commitdiff
tests: add a test for "resuming interrupted nanosleep"
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 7 Apr 2015 21:18:23 +0000 (21:18 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 7 Apr 2015 23:01:47 +0000 (23:01 +0000)
* 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
tests/restart_syscall.expected [new file with mode: 0644]
tests/restart_syscall.test [new file with mode: 0755]
tests/restart_syscall_unknown.expected [new file with mode: 0644]

index e5dae02a8740733d198ed9cd1e9be8f74d716771..7ace705b422f5e4ddc373d789a5cdafcc0192397 100644 (file)
@@ -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 (file)
index 0000000..af9267d
--- /dev/null
@@ -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 (executable)
index 0000000..5ae3a1d
--- /dev/null
@@ -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 (file)
index 0000000..5f16895
--- /dev/null
@@ -0,0 +1,2 @@
+restart_syscall(<... resuming interrupted system call ...>) = 0
++++ exited with 0 +++