From: Fei Jie Date: Tue, 26 Apr 2016 08:03:07 +0000 (+0800) Subject: tests: add reboot.test X-Git-Tag: v4.12~283 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=68d171d13386289e6ddd206dac46877f4443e3dc;p=strace tests: add reboot.test * 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. --- diff --git a/tests/.gitignore b/tests/.gitignore index 9cac19d7..88dd092c 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 6aa5d0e5..067310f2 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 00000000..eedc2a69 --- /dev/null +++ b/tests/reboot.c @@ -0,0 +1,37 @@ +#include "tests.h" +#include + +#ifdef __NR_reboot + +# include +# include +# include + +# 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 00000000..a97dd21a --- /dev/null +++ b/tests/reboot.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check reboot syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff