strace/tests/syslog.c
Fei Jie 9a88371122 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.
2016-03-25 09:46:19 +00:00

40 lines
642 B
C

#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