Commit 67134e71 authored by Thomas Haller's avatar Thomas Haller

core: merge branch 'th/build-core'

Add a test "test-systemd" which links against our copy
of systemd code and a minimal core library. For that,
cleanup and split NetworkManagerUtils.h.
parents 60ca6e02 51e29288
......@@ -264,6 +264,7 @@ test-*.trs
/src/tests/test-resolvconf-capture
/src/tests/test-route-manager-fake
/src/tests/test-route-manager-linux
/src/tests/test-systemd
/src/tests/test-utils
/src/tests/test-wired-defname
......
......@@ -184,6 +184,37 @@ libsystemd_nm_la_CPPFLAGS = \
libsystemd_nm_la_LIBADD = \
$(GLIB_LIBS)
######################
# libsystemd-nm-base
######################
if ENABLE_TESTS
noinst_LTLIBRARIES += \
libNetworkManager-base.la
libNetworkManager_base_la_SOURCES = \
nm-core-utils.c \
nm-core-utils.h \
nm-logging.c \
nm-logging.h
libNetworkManager_base_la_CPPFLAGS = \
-I$(top_srcdir)/shared \
-I$(top_builddir)/shared \
-I$(top_srcdir)/libnm-core \
-I$(top_builddir)/libnm-core \
-I$(top_srcdir)/src/platform \
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
-DNO_SYSTEMD_JOURNAL \
-DPREFIX=\"$(prefix)\" \
-DNMSTATEDIR=\"$(nmstatedir)\" \
$(GLIB_CFLAGS)
libNetworkManager_base_la_LIBADD = \
$(top_builddir)/libnm-core/libnm-core.la \
$(GLIB_LIBS)
endif
###########################################
# NetworkManager
###########################################
......@@ -404,6 +435,8 @@ libNetworkManager_la_SOURCES = \
nm-session-monitor.c \
nm-sleep-monitor.h \
nm-types.h \
nm-core-utils.c \
nm-core-utils.h \
NetworkManagerUtils.c \
NetworkManagerUtils.h
......@@ -535,6 +568,8 @@ libnm_iface_helper_la_SOURCES = \
nm-logging.h \
nm-multi-index.c \
nm-multi-index.h \
nm-core-utils.c \
nm-core-utils.h \
NetworkManagerUtils.c \
NetworkManagerUtils.h
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -32,14 +32,18 @@
#include <strings.h>
#include <string.h>
#if defined (NO_SYSTEMD_JOURNAL) && defined (SYSTEMD_JOURNAL)
#undef SYSTEMD_JOURNAL
#define SYSTEMD_JOURNAL 0
#endif
#if SYSTEMD_JOURNAL
#define SD_JOURNAL_SUPPRESS_LOCATION
#include <systemd/sd-journal.h>
#endif
#include "nm-errors.h"
#include "NetworkManagerUtils.h"
#include "nm-linux-platform.h"
#include "nm-core-utils.h"
typedef enum {
LOG_FORMAT_FLAG_NONE = 0,
......@@ -71,6 +75,8 @@ typedef enum {
LOG_FORMAT_FLAG_ALIGN_LOCATION,
} LogFormatFlags;
void (*_nm_logging_clear_platform_logging_cache) (void);
static void
nm_log_handler (const gchar *log_domain,
GLogLevelFlags level,
......@@ -332,11 +338,12 @@ nm_logging_setup (const char *level,
global.logging[i] = new_logging[i];
if ( had_platform_debug
&& _nm_logging_clear_platform_logging_cache
&& !nm_logging_enabled (LOGL_DEBUG, LOGD_PLATFORM)) {
/* when debug logging is enabled, platform will cache all access to
* sysctl. When the user disables debug-logging, we want to clear that
* cache right away. */
_nm_linux_platform_sysctl_clear_cache ();
_nm_logging_clear_platform_logging_cache ();
}
if (unrecognized)
......
......@@ -243,6 +243,8 @@ void nm_logging_syslog_openlog (const char *logging_backend);
#define _LOG2t_err(errsv, ...) G_STMT_START { if (FALSE) { _NMLOG2_err (errsv, LOGL_TRACE, __VA_ARGS__); } } G_STMT_END
#endif
extern void (*_nm_logging_clear_platform_logging_cache) (void);
/*****************************************************************************/
#endif /* __NETWORKMANAGER_LOGGING_H__ */
......@@ -20,6 +20,8 @@
#include "nm-default.h"
#include "nm-fake-platform.h"
#include <errno.h>
#include <unistd.h>
#include <netinet/icmp6.h>
......@@ -27,9 +29,9 @@
#include <linux/rtnetlink.h>
#include "nm-utils.h"
#include "nm-core-utils.h"
#include "nmp-object.h"
#include "NetworkManagerUtils.h"
#include "nm-fake-platform.h"
#include "nm-test-utils.h"
......
......@@ -19,6 +19,8 @@
*/
#include "nm-default.h"
#include "nm-linux-platform.h"
#include <errno.h>
#include <unistd.h>
#include <sys/socket.h>
......@@ -42,18 +44,15 @@
#include <netlink/route/route.h>
#include <gudev/gudev.h>
#include "nm-utils.h"
#include "nm-core-internal.h"
#include "NetworkManagerUtils.h"
#include "nm-linux-platform.h"
#include "nm-setting-vlan.h"
#include "nm-core-utils.h"
#include "nmp-object.h"
#include "nm-platform-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "wifi/wifi-utils.h"
#include "wifi/wifi-utils-wext.h"
#include "nmp-object.h"
/* This is only included for the translation of VLAN flags */
#include "nm-setting-vlan.h"
#define VLAN_FLAG_MVRP 0x8
......@@ -2520,8 +2519,8 @@ sysctl_set (NMPlatform *platform, const char *path, const char *value)
static GSList *sysctl_clear_cache_list;
void
_nm_linux_platform_sysctl_clear_cache (void)
static void
_nm_logging_clear_platform_logging_cache_impl (void)
{
while (sysctl_clear_cache_list) {
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (sysctl_clear_cache_list->data);
......@@ -2541,6 +2540,7 @@ _log_dbg_sysctl_get_impl (NMPlatform *platform, const char *path, const char *co
const char *prev_value = NULL;
if (!priv->sysctl_get_prev_values) {
_nm_logging_clear_platform_logging_cache = _nm_logging_clear_platform_logging_cache_impl;
sysctl_clear_cache_list = g_slist_prepend (sysctl_clear_cache_list, platform);
priv->sysctl_get_prev_values = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
} else
......
......@@ -50,6 +50,4 @@ GType nm_linux_platform_get_type (void);
void nm_linux_platform_setup (void);
void _nm_linux_platform_sysctl_clear_cache (void);
#endif /* __NETWORKMANAGER_LINUX_PLATFORM_H__ */
......@@ -18,6 +18,8 @@
* Copyright (C) 2015 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nm-platform-utils.h"
#include <string.h>
......@@ -30,10 +32,9 @@
#include <linux/version.h>
#include "nm-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-default.h"
#include "nm-setting-wired.h"
#include "nm-core-utils.h"
/******************************************************************
* ethtool
......
......@@ -20,6 +20,8 @@
#include "nm-default.h"
#include "nm-platform.h"
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
......@@ -32,14 +34,13 @@
#include <linux/if_tun.h>
#include <linux/if_tunnel.h>
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-platform.h"
#include "nm-core-internal.h"
#include "nm-core-utils.h"
#include "nm-enum-types.h"
#include "nm-platform-utils.h"
#include "nmp-object.h"
#include "NetworkManagerUtils.h"
#include "nm-enum-types.h"
#include "nm-core-internal.h"
/*****************************************************************************/
......
......@@ -27,11 +27,11 @@
#include <linux/if_link.h>
#include "nm-dbus-interface.h"
#include "nm-default.h"
#include "NetworkManagerUtils.h"
#include "nm-setting-vlan.h"
#include "nm-core-types-internal.h"
#include "nm-core-utils.h"
#include "nm-setting-vlan.h"
#define NM_TYPE_PLATFORM (nm_platform_get_type ())
#define NM_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PLATFORM, NMPlatform))
#define NM_PLATFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PLATFORM, NMPlatformClass))
......
......@@ -20,13 +20,15 @@
#include "nm-default.h"
#include "nmp-object.h"
#include <unistd.h>
#include "nmp-object.h"
#include "nm-platform-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "nm-core-utils.h"
#include "nm-platform-utils.h"
/*********************************************************************************************/
#define _NMLOG_DOMAIN LOGD_PLATFORM
......
......@@ -22,8 +22,8 @@
#include <linux/rtnetlink.h>
#include "nm-core-utils.h"
#include "test-common.h"
#include "NetworkManagerUtils.h"
#include "nm-test-utils.h"
......
......@@ -23,6 +23,7 @@ noinst_PROGRAMS = \
test-route-manager-linux \
test-route-manager-fake \
test-dcb \
test-systemd \
test-resolvconf-capture \
test-wired-defname \
test-utils
......@@ -111,6 +112,20 @@ test_wired_defname_SOURCES = \
test_wired_defname_LDADD = \
$(top_builddir)/src/libNetworkManager.la
####### systemd test #######
test_systemd_CFLAGS = \
"-I$(srcdir)/../" \
"-I$(srcdir)/../platform" \
"-I$(srcdir)/../systemd/src/systemd"
test_systemd_SOURCES = \
test-systemd.c
test_systemd_LDADD = \
$(top_builddir)/src/libNetworkManager-base.la \
$(top_builddir)/src/libsystemd-nm.la
####### utils test #######
test_utils_SOURCES = \
......@@ -143,6 +158,7 @@ TESTS = \
test-resolvconf-capture \
test-general \
test-general-with-expect \
test-systemd \
test-wired-defname \
test-utils
......
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2016 Red Hat, Inc.
*/
#include "nm-default.h"
#include "sd-dhcp-client.h"
#include "nm-test-utils.h"
/*****************************************************************************/
static void
test_dhcp_create (void)
{
sd_dhcp_client *client4 = NULL;
int r;
r = sd_dhcp_client_new (&client4);
g_assert (r == 0);
g_assert (client4);
sd_dhcp_client_unref (client4);
}
/*****************************************************************************/
NMTST_DEFINE ();
int
main (int argc, char **argv)
{
nmtst_init_assert_logging (&argc, &argv, "INFO", "ALL");
g_test_add_func ("/systemd/dhcp/create", test_dhcp_create);
return g_test_run ();
}
......@@ -24,7 +24,7 @@
#include <errno.h>
#include <arpa/inet.h>
#include "NetworkManagerUtils.c"
#include "nm-core-utils.c"
#include "nm-test-utils.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment