]> granicus.if.org Git - strace/commitdiff
tests: add syslog.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Fri, 25 Mar 2016 09:46:19 +0000 (17:46 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 25 Mar 2016 09:46:19 +0000 (09:46 +0000)
* tests/syslog.c: New file.
* tests/syslog.test: New test.
* tests/.gitignore: Add syslog.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add syslog.test.

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

index d1fb6d496e4c59e188ac11bdef4135c303db28d9..60b642f4bc01570dff7260693c9cb1dc0925b067 100644 (file)
@@ -120,6 +120,7 @@ stat
 stat64
 statfs
 sysinfo
+syslog
 tee
 time
 timer_create
index a08025c3bbfc552f1c4b5e9901280458f2bf1ff6..06b385453a0f79b9e2fb6df603c22c02287fb19a 100644 (file)
@@ -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 (file)
index 0000000..1475db5
--- /dev/null
@@ -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 (executable)
index 0000000..cc43806
--- /dev/null
@@ -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"