1 /* Manual regression test for syslog support
3 * Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
4 * Copyright © 2011 Nokia Corporation
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation files
8 * (the "Software"), to deal in the Software without restriction,
9 * including without limitation the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 #define DBUS_COMPILATION /* this test uses libdbus-internal */
34 #include <dbus/dbus.h>
35 #include <dbus/dbus-sysdeps.h>
47 /* hopefully clear enough that people don't think these messages in syslog
49 #define MESSAGE "regression test for _dbus_system_log(): "
52 test_syslog (Fixture *f,
55 if (g_test_trap_fork (0, 0))
57 _dbus_init_system_log (FALSE);
58 _dbus_system_log (DBUS_SYSTEM_LOG_FATAL, MESSAGE "%d", 23);
59 /* should not be reached: exit 0 so the assertion in the main process
64 g_test_trap_assert_failed ();
65 g_test_trap_assert_stderr ("*" MESSAGE "23\n*");
67 if (g_test_trap_fork (0, 0))
69 _dbus_init_system_log (FALSE);
70 _dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42);
71 _dbus_system_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666);
75 g_test_trap_assert_passed ();
76 g_test_trap_assert_stderr ("*" MESSAGE "42\n*" MESSAGE "666\n*");
78 /* manual test (this is the best we can do on Windows) */
79 _dbus_init_system_log (FALSE);
80 _dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42);
81 _dbus_system_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666);
94 g_test_init (&argc, &argv, NULL);
95 g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
97 g_test_add ("/syslog", Fixture, NULL, setup, test_syslog, teardown);