[PATCH v3] tests: add syslog.test

Fei Jie feij.fnst at cn.fujitsu.com
Fri Mar 25 09:46:19 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    | 39 +++++++++++++++++++++++++++++++++++++++
 tests/syslog.test | 11 +++++++++++
 4 files changed, 53 insertions(+)
 create mode 100644 tests/syslog.c
 create mode 100755 tests/syslog.test

diff --git a/tests/.gitignore b/tests/.gitignore
index d1fb6d4..60b642f 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -120,6 +120,7 @@ stat
 stat64
 statfs
 sysinfo
+syslog
 tee
 time
 timer_create
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a08025c..06b3854 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -169,6 +169,7 @@ check_PROGRAMS = \
 	stat64 \
 	statfs \
 	sysinfo \
+	syslog \
 	tee \
 	time \
 	timer_create \
@@ -330,6 +331,7 @@ DECODER_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..1475db5
--- /dev/null
+++ b/tests/syslog.c
@@ -0,0 +1,39 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_syslog
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+# define SYSLOG_ACTION_READ 2
+
+int
+main(void)
+{
+	const char *errno_text;
+	const void *bufp = &errno_text;
+	int rc = syscall(__NR_syslog, SYSLOG_ACTION_READ, bufp, -1);
+	switch (errno) {
+		case ENOSYS:
+			errno_text = "ENOSYS";
+			break;
+		case EPERM:
+			errno_text = "EPERM";
+			break;
+		default:
+			errno_text = "EINVAL";
+	}
+	printf("syslog(SYSLOG_ACTION_READ, %p, -1) = %d %s (%m)\n",
+	       bufp, rc, errno_text);
+
+	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