diff options
Diffstat (limited to 'src/core/tests/test-systemd.c')
| -rw-r--r-- | src/core/tests/test-systemd.c | 130 |
1 files changed, 31 insertions, 99 deletions
diff --git a/src/core/tests/test-systemd.c b/src/core/tests/test-systemd.c index fa510366..12d2b911 100644 --- a/src/core/tests/test-systemd.c +++ b/src/core/tests/test-systemd.c @@ -3,68 +3,12 @@ * Copyright (C) 2016 Red Hat, Inc. */ -#include "src/core/systemd/nm-default-systemd.h" +#include "libnm-systemd-core/nm-default-systemd-core.h" -#include "systemd/nm-sd.h" -#include "systemd/nm-sd-utils-shared.h" +#include "libnm-systemd-core/nm-sd.h" +#include "libnm-systemd-shared/nm-sd-utils-shared.h" -#include "nm-test-utils-core.h" - -/***************************************************************************** - * Stub implementations of libNetworkManagerBase symbols - *****************************************************************************/ - -gboolean -nm_utils_get_testing_initialized(void) -{ - return TRUE; -} - -void -_nm_utils_set_testing(NMUtilsTestFlags flags) -{ - g_assert_not_reached(); -} - -gint32 -nm_utils_get_monotonic_timestamp_sec(void) -{ - return 1; -} - -NMLogDomain _nm_logging_enabled_state[_LOGL_N_REAL]; - -gboolean -_nm_log_enabled_impl(gboolean mt_require_locking, NMLogLevel level, NMLogDomain domain) -{ - return FALSE; -} - -void -_nm_log_impl(const char *file, - guint line, - const char *func, - gboolean mt_require_locking, - NMLogLevel level, - NMLogDomain domain, - int error, - const char *ifname, - const char *con_uuid, - const char *fmt, - ...) -{} - -gboolean -nm_logging_setup(const char *level, const char *domains, char **bad_domains, GError **error) -{ - return TRUE; -} - -const char * -nm_strerror_native(int errsv) -{ - return g_strerror(errsv); -} +#include "libnm-glib-aux/nm-test-utils.h" /*****************************************************************************/ @@ -178,46 +122,34 @@ test_sd_event(void) static void test_path_equal(void) { -#define _path_equal_check1(path, kill_dots, expected) \ - G_STMT_START \ - { \ - const gboolean _kill_dots = (kill_dots); \ - const char * _path0 = (path); \ - const char * _expected = (expected); \ - gs_free char * _path = g_strdup(_path0); \ - const char * _path_result; \ - \ - if (!_kill_dots && !nm_sd_utils_path_equal(_path0, _expected)) \ - g_error("Paths \"%s\" and \"%s\" don't compare equal", _path0, _expected); \ - \ - _path_result = nm_sd_utils_path_simplify(_path, _kill_dots); \ - g_assert(_path_result == _path); \ - g_assert_cmpstr(_path, ==, _expected); \ - } \ - G_STMT_END - -#define _path_equal_check(path, expected_no_kill_dots, expected_kill_dots) \ - G_STMT_START \ - { \ - _path_equal_check1(path, FALSE, expected_no_kill_dots); \ - _path_equal_check1(path, TRUE, expected_kill_dots ?: expected_no_kill_dots); \ - } \ +#define _path_equal_check(path, expected) \ + G_STMT_START \ + { \ + const char * _path0 = (path); \ + const char * _expected = (expected); \ + gs_free char *_path = g_strdup(_path0); \ + const char * _path_result; \ + \ + _path_result = nm_sd_utils_path_simplify(_path); \ + g_assert(_path_result == _path); \ + g_assert_cmpstr(_path, ==, _expected); \ + } \ G_STMT_END - _path_equal_check("", "", NULL); - _path_equal_check(".", ".", NULL); - _path_equal_check("..", "..", NULL); - _path_equal_check("/..", "/..", NULL); - _path_equal_check("//..", "/..", NULL); - _path_equal_check("/.", "/.", "/"); - _path_equal_check("./", ".", "."); - _path_equal_check("./.", "./.", "."); - _path_equal_check(".///.", "./.", "."); - _path_equal_check(".///./", "./.", "."); - _path_equal_check(".////", ".", "."); - _path_equal_check("//..//foo/", "/../foo", NULL); - _path_equal_check("///foo//./bar/.", "/foo/./bar/.", "/foo/bar"); - _path_equal_check(".//./foo//./bar/.", "././foo/./bar/.", "foo/bar"); + _path_equal_check("", ""); + _path_equal_check(".", "."); + _path_equal_check("..", ".."); + _path_equal_check("/..", "/.."); + _path_equal_check("//..", "/.."); + _path_equal_check("/.", "/"); + _path_equal_check("./", "."); + _path_equal_check("./.", "."); + _path_equal_check(".///.", "."); + _path_equal_check(".///./", "."); + _path_equal_check(".////", "."); + _path_equal_check("//..//foo/", "/../foo"); + _path_equal_check("///foo//./bar/.", "/foo/bar"); + _path_equal_check(".//./foo//./bar/.", "foo/bar"); } /*****************************************************************************/ @@ -327,7 +259,7 @@ NMTST_DEFINE(); int main(int argc, char **argv) { - nmtst_init_assert_logging(&argc, &argv, "INFO", "ALL"); + nmtst_init(&argc, &argv, TRUE); g_test_add_func("/systemd/dhcp/create", test_dhcp_create); g_test_add_func("/systemd/lldp/create", test_lldp_create); |