From 21f3abb2b4ccf6093baabb36c8cdcc64871c1823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 12 Nov 2003 16:37:46 +0000 Subject: [PATCH] Added a test for the syslog functionality. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5336 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/kernel/libroot/Jamfile | 1 + src/tests/kernel/libroot/posix/Jamfile | 12 +++++ src/tests/kernel/libroot/posix/SyslogTest.cpp | 49 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 src/tests/kernel/libroot/posix/Jamfile create mode 100644 src/tests/kernel/libroot/posix/SyslogTest.cpp diff --git a/src/tests/kernel/libroot/Jamfile b/src/tests/kernel/libroot/Jamfile index 4db66d05dc..1659e7016d 100644 --- a/src/tests/kernel/libroot/Jamfile +++ b/src/tests/kernel/libroot/Jamfile @@ -1,3 +1,4 @@ SubDir OBOS_TOP src tests kernel libroot ; SubInclude OBOS_TOP src tests kernel libroot os ; +SubInclude OBOS_TOP src tests kernel libroot posix ; diff --git a/src/tests/kernel/libroot/posix/Jamfile b/src/tests/kernel/libroot/posix/Jamfile new file mode 100644 index 0000000000..1509423c6b --- /dev/null +++ b/src/tests/kernel/libroot/posix/Jamfile @@ -0,0 +1,12 @@ +SubDir OBOS_TOP src tests kernel libroot posix ; + +UsePrivateHeaders syslog_daemon ; + +SimpleTest SyslogTest + : SyslogTest.cpp syslog.cpp + ; + +# Tell Jam where to find these sources +SEARCH on [ FGristFiles + syslog.cpp + ] = [ FDirName $(OBOS_TOP) src kernel libroot posix ] ; diff --git a/src/tests/kernel/libroot/posix/SyslogTest.cpp b/src/tests/kernel/libroot/posix/SyslogTest.cpp new file mode 100644 index 0000000000..2e94aacc94 --- /dev/null +++ b/src/tests/kernel/libroot/posix/SyslogTest.cpp @@ -0,0 +1,49 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + + +#include +#include + +#include +#include +#include +#include + + +int +main(int argc, char **argv) +{ + port_id port = find_port(SYSLOG_PORT_NAME); + if (port < B_OK) + fprintf(stderr, "The (new) syslog_daemon should be running!\n"); + + openlog_team("SyslogTest", LOG_PID, LOG_USER); + + log_team(LOG_ERR, "this is %.", "a test"); + + int mask = setlogmask_team(LOG_MASK(LOG_CRIT)); + printf("team mask == %d\n", mask); + + log_team(LOG_WARNING, "this is a warning (hidden)"); + log_team(LOG_CRIT, "this is a critical condition (visible)"); + + setlogmask(mask); + syslog(LOG_WARNING, "thread warning (visible)"); + syslog(LOG_CRIT, "thread critical condition (visible)"); + + setlogmask(LOG_MASK(LOG_WARNING)); + log_team(LOG_WARNING | LOG_MAIL, "2. this is a warning from the MAIL facility (visible)"); + log_team(LOG_CRIT, "2. this is a critical condition (visible)"); + + openlog(NULL, LOG_PERROR, LOG_USER); + syslog(LOG_WARNING, "thread/perror warning (visible in stderr as well)"); + syslog(LOG_CRIT, "thread/perror critical condition (hidden)"); + + openlog(NULL, LOG_CONS, LOG_DAEMON); + syslog(LOG_WARNING, "thread/cons warning (visible in stderr only when there is no syslog_daemon)"); + + return 0; +}