[PATCH 1/5] tests: add reboot.test

Fei Jie feij.fnst at cn.fujitsu.com
Tue Apr 26 08:03:07 UTC 2016


* 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  |  1 +
 tests/Makefile.am |  2 ++
 tests/reboot.c    | 37 +++++++++++++++++++++++++++++++++++++
 tests/reboot.test |  6 ++++++
 4 files changed, 46 insertions(+)
 create mode 100644 tests/reboot.c
 create mode 100755 tests/reboot.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 9cac19d..88dd092 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -143,6 +143,7 @@ readdir
 readlink
 readlinkat
 readv
+reboot
 recvmsg
 rename
 renameat
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6aa5d0e..067310f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 0000000..eedc2a6
--- /dev/null
+++ b/tests/reboot.c
@@ -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
index 0000000..a97dd21
--- /dev/null
+++ b/tests/reboot.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check reboot syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff
-- 
1.8.3.1







More information about the Strace-devel mailing list