From 4759527fef0c99a8a02d46cd8a61e8ddfdc7a8a0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 20 Jul 2016 09:38:09 +0100 Subject: [PATCH] syslog test: extend assertions to cover new functionality Signed-off-by: Simon McVittie --- test/internals/syslog.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/internals/syslog.c b/test/internals/syslog.c index 36442fe..bccb191 100644 --- a/test/internals/syslog.c +++ b/test/internals/syslog.c @@ -72,17 +72,45 @@ test_syslog (Fixture *f, _dbus_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); _dbus_log (DBUS_SYSTEM_LOG_WARNING, MESSAGE "%d", 45); _dbus_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666); + + _dbus_init_system_log ("test-syslog-stderr", DBUS_LOG_MODE_STDERR); + _dbus_log (DBUS_SYSTEM_LOG_INFO, + MESSAGE "this should not appear in the syslog"); + _dbus_init_system_log ("test-syslog-both", DBUS_LOG_MODE_SYSTEM_LOG); + _dbus_log (DBUS_SYSTEM_LOG_INFO, + MESSAGE "this should appear in the syslog and on stderr"); + _dbus_init_system_log ("test-syslog-only", DBUS_LOG_MODE_SYSTEM_LOG_ONLY); + _dbus_log (DBUS_SYSTEM_LOG_INFO, + MESSAGE "this should appear in the syslog only"); + exit (0); } g_test_trap_assert_passed (); - g_test_trap_assert_stderr ("*" MESSAGE "42\n*" MESSAGE "45\n*" MESSAGE "666\n*"); + g_test_trap_assert_stderr ("*" MESSAGE "42\n" + "*" MESSAGE "45\n" + "*" MESSAGE "666\n" + "*test-syslog-stderr*" MESSAGE + "this should not appear in the syslog\n" + "*test-syslog-both*" MESSAGE + "this should appear in the syslog and " + "on stderr\n"); + g_test_trap_assert_stderr_unmatched ("*this should appear in the syslog " + "only*"); + g_test_trap_assert_stderr_unmatched ("*test-syslog-only*"); #endif /* manual test (this is the best we can do on Windows) */ _dbus_init_system_log ("test-syslog", DBUS_LOG_MODE_SYSTEM_LOG); _dbus_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); _dbus_log (DBUS_SYSTEM_LOG_WARNING, MESSAGE "%d", 45); _dbus_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666); + + _dbus_init_system_log ("test-syslog-stderr", DBUS_LOG_MODE_STDERR); + _dbus_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "this should not appear in the syslog"); + _dbus_init_system_log ("test-syslog-both", DBUS_LOG_MODE_SYSTEM_LOG); + _dbus_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "this should appear in the syslog and on stderr"); + _dbus_init_system_log ("test-syslog-only", DBUS_LOG_MODE_SYSTEM_LOG_ONLY); + _dbus_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "this should appear in the syslog only"); } static void -- 2.8.1