[PATCH 3/3] tests: add syslog.test

Fei Jie feij.fnst at cn.fujitsu.com
Tue Mar 15 08:38:36 UTC 2016


* tests/syslog.c: New file.
* tests/syslog.test: New test.
* tests/.gitignore: Add syslog.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add syslog.test.
---
 tests/.gitignore  |  1 +
 tests/Makefile.am |  2 ++
 tests/syslog.c    | 30 ++++++++++++++++++++++++++++++
 tests/syslog.test | 11 +++++++++++
 4 files changed, 44 insertions(+)
 create mode 100644 tests/syslog.c
 create mode 100755 tests/syslog.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 8312930..e58e47c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -119,6 +119,7 @@ stat
 stat64
 statfs
 sysinfo
+syslog
 tee
 time
 timer_create
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2a2f3a3..71dc6aa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -167,6 +167,7 @@ check_PROGRAMS = \
 	stat64 \
 	statfs \
 	sysinfo \
+	syslog \
 	tee \
 	time \
 	timer_create \
@@ -336,6 +337,7 @@ TESTS = \
 	statfs.test \
 	sun_path.test \
 	sysinfo.test \
+	syslog.test \
 	tee.test \
 	time.test \
 	timer_create.test \
diff --git a/tests/syslog.c b/tests/syslog.c
new file mode 100644
index 0000000..af45d49
--- /dev/null
+++ b/tests/syslog.c
@@ -0,0 +1,30 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_syslog
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+# define SYSLOG_ACTION_READ 2
+
+static char buf[1024];
+
+int
+main(void)
+{
+	int rc = syscall(__NR_syslog, SYSLOG_ACTION_READ, buf, -1);
+	printf("syslog(SYSLOG_ACTION_READ, %p, -1) = %d %s (%m)\n",
+	       buf, rc,
+	       errno == ENOSYS ? "ENOSYS" : "EINVAL");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_syslog")
+
+#endif
diff --git a/tests/syslog.test b/tests/syslog.test
new file mode 100755
index 0000000..cc43806
--- /dev/null
+++ b/tests/syslog.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check syslog syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -esyslog -a36 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1







More information about the Strace-devel mailing list