]> granicus.if.org Git - strace/commitdiff
tests: check decoding of fault injected exit_group syscall
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 27 Nov 2016 00:02:18 +0000 (00:02 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 27 Nov 2016 19:40:33 +0000 (19:40 +0000)
* tests/answer.c: New file.
* tests/fault_injection-exit_group.expected: Likewise.
* tests/fault_injection-exit_group.test: New test.
* tests/.gitignore: Add answer.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add fault_injection-exit_group.test.
(EXTRA_DIST): Add fault_injection-exit_group.expected.

tests/.gitignore
tests/Makefile.am
tests/answer.c [new file with mode: 0644]
tests/fault_injection-exit_group.expected [new file with mode: 0644]
tests/fault_injection-exit_group.test [new file with mode: 0755]

index f176406262c9d309026a5c347fc832174184886a..ebd626fbab66f6a1e25da4636b2024c3f4e999b3 100644 (file)
@@ -14,6 +14,7 @@ addkey
 adjtimex
 aio
 alarm
+answer
 attach-f-p
 attach-p-cmd-cmd
 attach-p-cmd-p
index d75249534a5ed59c9df9784b31fb29c4e4a22b2e..24f29cbfb7b94d295051ca3f68fb3e9e4d1a4b29 100644 (file)
@@ -74,6 +74,7 @@ check_PROGRAMS = \
        adjtimex \
        aio \
        alarm \
+       answer \
        attach-f-p \
        attach-p-cmd-cmd \
        attach-p-cmd-p \
@@ -496,6 +497,7 @@ DECODER_TESTS = \
        fallocate.test \
        fanotify_init.test \
        fanotify_mark.test \
+       fault_injection-exit_group.test \
        fchdir.test \
        fchmod.test \
        fchmodat.test \
@@ -832,6 +834,7 @@ EXTRA_DIST = init.sh run.sh match.awk \
             count-f.expected \
             eventfd.expected \
             fadvise.h \
+            fault_injection-exit_group.expected \
             filter-unavailable.expected \
             fstatat.c \
             fstatx.c \
diff --git a/tests/answer.c b/tests/answer.c
new file mode 100644 (file)
index 0000000..8d5387e
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Check decoding of fault injected exit_group syscall.
+ *
+ * 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 <unistd.h>
+#include <asm/unistd.h>
+#include "kernel_types.h"
+
+int
+main(void)
+{
+       static const kernel_ulong_t answer =
+               (kernel_ulong_t) 0xbadc0ded0000002aULL;
+
+       syscall(__NR_exit_group, answer);
+       syscall(__NR_exit, answer);
+
+       return 1;
+}
diff --git a/tests/fault_injection-exit_group.expected b/tests/fault_injection-exit_group.expected
new file mode 100644 (file)
index 0000000..dd9d4e4
--- /dev/null
@@ -0,0 +1,3 @@
+exit_group(42)                          = -1 ENOSYS (Function not implemented) (INJECTED)
+exit(42)                                = ?
++++ exited with 42 +++
diff --git a/tests/fault_injection-exit_group.test b/tests/fault_injection-exit_group.test
new file mode 100755 (executable)
index 0000000..b2a22b4
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Check decoding of fault injected exit_group syscall.
+#
+# 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.
+
+. "${srcdir=.}/init.sh"
+
+> "$LOG" || fail_ "failed to write $LOG"
+set -- -eexit,exit_group -efault=exit_group:error=ENOSYS ./answer
+
+$STRACE -o "$LOG" "$@"
+rc=$?
+[ $rc -eq 42 ] ||
+       dump_log_and_fail_with "$STRACE $* failed with code $rc"
+
+match_diff