]> granicus.if.org Git - strace/commitdiff
tests: add reboot.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Tue, 26 Apr 2016 08:03:07 +0000 (16:03 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 26 Apr 2016 10:11:41 +0000 (10:11 +0000)
* tests/reboot.c: New file.
* tests/reboot.test: New test.
* tests/.gitignore: Add reboot.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add reboot.test.

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

index 9cac19d7746b059dcf8ce4ee619bd06d9cffd16c..88dd092c5a707c14524764109a77109435b215bf 100644 (file)
@@ -143,6 +143,7 @@ readdir
 readlink
 readlinkat
 readv
+reboot
 recvmsg
 rename
 renameat
index 6aa5d0e56e758168046833189263506a643a7e85..067310f2a0017a6f44a265a564ce0baecda4d52f 100644 (file)
@@ -195,6 +195,7 @@ check_PROGRAMS = \
        readlink \
        readlinkat \
        readv \
+       reboot \
        recvmsg \
        rename \
        renameat\
@@ -450,6 +451,7 @@ DECODER_TESTS = \
        readlink.test \
        readlinkat.test \
        readv.test \
+       reboot.test \
        recvmsg.test \
        rename.test \
        renameat.test \
diff --git a/tests/reboot.c b/tests/reboot.c
new file mode 100644 (file)
index 0000000..eedc2a6
--- /dev/null
@@ -0,0 +1,37 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_reboot
+
+# include <stdio.h>
+# include <linux/reboot.h>
+# include <unistd.h>
+
+# define INVALID_MAGIC 319887762
+# define INVALID_CMD 0x01234568
+
+int
+main(void)
+{
+       static const char buf[] = "reboot";
+       long rc = syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, \
+                 INVALID_MAGIC, LINUX_REBOOT_CMD_RESTART2, buf);
+       printf("reboot(LINUX_REBOOT_MAGIC1, %#x /* LINUX_REBOOT_MAGIC_??? */,"
+              " LINUX_REBOOT_CMD_RESTART2, \"%s\") = %ld %s (%m)\n",
+              INVALID_MAGIC, buf, rc, errno2name());
+
+       rc = syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, \
+            LINUX_REBOOT_MAGIC2, INVALID_CMD);
+       printf("reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,"
+              " %#x /* LINUX_REBOOT_CMD_??? */) = %ld %s (%m)\n",
+              INVALID_CMD, rc, errno2name());
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_reboot")
+
+#endif
diff --git a/tests/reboot.test b/tests/reboot.test
new file mode 100755 (executable)
index 0000000..a97dd21
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check reboot syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff