From: Fei Jie Date: Fri, 25 Mar 2016 09:46:19 +0000 (+0800) Subject: tests: add syslog.test X-Git-Tag: v4.12~499 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a8837112201f2a7a81d1335c951d9989136e621;p=strace tests: add syslog.test * 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. --- diff --git a/tests/.gitignore b/tests/.gitignore index d1fb6d49..60b642f4 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 a08025c3..06b38545 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 00000000..1475db50 --- /dev/null +++ b/tests/syslog.c @@ -0,0 +1,39 @@ +#include "tests.h" +#include + +#ifdef __NR_syslog + +# include +# include +# include + +# 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 00000000..cc438068 --- /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"