mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 18:54:36 +00:00
libnm: add testable libnm/nm-libnm-utils.c file
Previously, internal parts of libnm were not testable. Instead, add "libnm/nm-libnm-utils.c" and "libnm/libnm-utils.la" to contain code that can be statically linked with a new test "libnm/tests/test-general".
This commit is contained in:
parent
72104ea10a
commit
8df944c7e4
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -182,6 +182,7 @@ test-*.trs
|
||||||
/libnm/nm-settings-docs.xml
|
/libnm/nm-settings-docs.xml
|
||||||
/libnm/nm-settings-docs-overrides.xml
|
/libnm/nm-settings-docs-overrides.xml
|
||||||
/libnm/nm-settings-keyfile-docs.xml
|
/libnm/nm-settings-keyfile-docs.xml
|
||||||
|
/libnm/tests/test-general
|
||||||
/libnm/tests/test-nm-client
|
/libnm/tests/test-nm-client
|
||||||
/libnm/tests/test-remote-settings-client
|
/libnm/tests/test-remote-settings-client
|
||||||
/libnm/tests/test-secret-agent
|
/libnm/tests/test-secret-agent
|
||||||
|
|
45
Makefile.am
45
Makefile.am
|
@ -737,6 +737,7 @@ libnm_lib_h_pub_nointrospect = \
|
||||||
libnm_lib_h_pub_mkenums = \
|
libnm_lib_h_pub_mkenums = \
|
||||||
libnm/nm-enum-types.h
|
libnm/nm-enum-types.h
|
||||||
libnm_lib_h_priv = \
|
libnm_lib_h_priv = \
|
||||||
|
libnm/nm-libnm-utils.h \
|
||||||
libnm/nm-dbus-helpers.h \
|
libnm/nm-dbus-helpers.h \
|
||||||
libnm/nm-device-private.h \
|
libnm/nm-device-private.h \
|
||||||
libnm/nm-dhcp4-config.h \
|
libnm/nm-dhcp4-config.h \
|
||||||
|
@ -793,6 +794,14 @@ libnm_lib_c_real = \
|
||||||
libnm_lib_c_mkenums = \
|
libnm_lib_c_mkenums = \
|
||||||
libnm/nm-enum-types.c
|
libnm/nm-enum-types.c
|
||||||
|
|
||||||
|
libnm_lib_cppflags = \
|
||||||
|
$(dflt_cppflags_libnm_core) \
|
||||||
|
-I$(srcdir)/libnm \
|
||||||
|
-I$(builddir)/libnm \
|
||||||
|
-DG_LOG_DOMAIN=\""libnm"\" \
|
||||||
|
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
|
||||||
|
-DNMRUNDIR=\"$(nmrundir)\"
|
||||||
|
|
||||||
libnminclude_HEADERS += \
|
libnminclude_HEADERS += \
|
||||||
$(libnm_lib_h_pub_real) \
|
$(libnm_lib_h_pub_real) \
|
||||||
$(libnm_lib_h_pub_nointrospect)
|
$(libnm_lib_h_pub_nointrospect)
|
||||||
|
@ -802,6 +811,23 @@ nodist_libnminclude_HEADERS += \
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
lib_LTLIBRARIES += libnm/libnm-utils.la
|
||||||
|
|
||||||
|
libnm_libnm_utils_la_CPPFLAGS = \
|
||||||
|
$(libnm_lib_cppflags)
|
||||||
|
|
||||||
|
libnm_libnm_utils_la_SOURCES = \
|
||||||
|
libnm/nm-libnm-utils.c
|
||||||
|
|
||||||
|
libnm_libnm_utils_la_LIBADD = \
|
||||||
|
libnm-core/libnm-core.la \
|
||||||
|
introspection/libnmdbus.la \
|
||||||
|
$(GLIB_LIBS)
|
||||||
|
|
||||||
|
$(libnm_libnm_utils_la_OBJECTS) : $(libnm_lib_h_pub_mkenums)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
lib_LTLIBRARIES += libnm/libnm.la
|
lib_LTLIBRARIES += libnm/libnm.la
|
||||||
|
|
||||||
GLIB_GENERATED += \
|
GLIB_GENERATED += \
|
||||||
|
@ -820,13 +846,8 @@ $(libnm_libnm_la_OBJECTS): $(libnm_lib_h_pub_mkenum
|
||||||
$(libnm_tests_libnm_vpn_plugin_utils_test_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
$(libnm_tests_libnm_vpn_plugin_utils_test_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
||||||
|
|
||||||
libnm_libnm_la_CPPFLAGS = \
|
libnm_libnm_la_CPPFLAGS = \
|
||||||
$(dflt_cppflags_libnm_core) \
|
$(libnm_lib_cppflags) \
|
||||||
-I$(srcdir)/libnm \
|
$(LIBUDEV_CFLAGS)
|
||||||
-I$(builddir)/libnm \
|
|
||||||
$(LIBUDEV_CFLAGS) \
|
|
||||||
-DG_LOG_DOMAIN=\""libnm"\" \
|
|
||||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
|
|
||||||
-DNMRUNDIR=\"$(nmrundir)\"
|
|
||||||
|
|
||||||
libnm_libnm_la_SOURCES = \
|
libnm_libnm_la_SOURCES = \
|
||||||
$(libnm_lib_h_pub_real) \
|
$(libnm_lib_h_pub_real) \
|
||||||
|
@ -844,6 +865,7 @@ EXTRA_libnm_libnm_la_DEPENDENCIES = \
|
||||||
libnm_libnm_la_LIBADD = \
|
libnm_libnm_la_LIBADD = \
|
||||||
libnm-core/libnm-core.la \
|
libnm-core/libnm-core.la \
|
||||||
introspection/libnmdbus.la \
|
introspection/libnmdbus.la \
|
||||||
|
libnm/libnm-utils.la \
|
||||||
$(DL_LIBS) \
|
$(DL_LIBS) \
|
||||||
$(GLIB_LIBS) \
|
$(GLIB_LIBS) \
|
||||||
$(UUID_LIBS) \
|
$(UUID_LIBS) \
|
||||||
|
@ -950,6 +972,7 @@ EXTRA_DIST += \
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
libnm_tests_programs = \
|
libnm_tests_programs = \
|
||||||
|
libnm/tests/test-general \
|
||||||
libnm/tests/test-nm-client \
|
libnm/tests/test-nm-client \
|
||||||
libnm/tests/test-remote-settings-client \
|
libnm/tests/test-remote-settings-client \
|
||||||
libnm/tests/test-secret-agent
|
libnm/tests/test-secret-agent
|
||||||
|
@ -967,10 +990,14 @@ libnm_tests_ldadd = \
|
||||||
libnm/libnm.la \
|
libnm/libnm.la \
|
||||||
$(GLIB_LIBS)
|
$(GLIB_LIBS)
|
||||||
|
|
||||||
|
libnm_tests_test_general_CPPFLAGS = $(libnm_tests_cppflags)
|
||||||
libnm_tests_test_nm_client_CPPFLAGS = $(libnm_tests_cppflags)
|
libnm_tests_test_nm_client_CPPFLAGS = $(libnm_tests_cppflags)
|
||||||
libnm_tests_test_remote_settings_client_CPPFLAGS = $(libnm_tests_cppflags)
|
libnm_tests_test_remote_settings_client_CPPFLAGS = $(libnm_tests_cppflags)
|
||||||
libnm_tests_test_secret_agent_CPPFLAGS = $(libnm_tests_cppflags)
|
libnm_tests_test_secret_agent_CPPFLAGS = $(libnm_tests_cppflags)
|
||||||
|
|
||||||
|
libnm_tests_test_general_SOURCES = \
|
||||||
|
libnm/tests/test-general.c
|
||||||
|
|
||||||
libnm_tests_test_nm_client_SOURCES = \
|
libnm_tests_test_nm_client_SOURCES = \
|
||||||
shared/nm-test-utils-impl.c \
|
shared/nm-test-utils-impl.c \
|
||||||
shared/nm-test-libnm-utils.h \
|
shared/nm-test-libnm-utils.h \
|
||||||
|
@ -986,10 +1013,14 @@ libnm_tests_test_secret_agent_SOURCES = \
|
||||||
shared/nm-test-libnm-utils.h \
|
shared/nm-test-libnm-utils.h \
|
||||||
libnm/tests/test-secret-agent.c
|
libnm/tests/test-secret-agent.c
|
||||||
|
|
||||||
|
libnm_tests_test_general_LDADD = \
|
||||||
|
libnm/libnm-utils.la \
|
||||||
|
$(libnm_tests_ldadd)
|
||||||
libnm_tests_test_nm_client_LDADD = $(libnm_tests_ldadd)
|
libnm_tests_test_nm_client_LDADD = $(libnm_tests_ldadd)
|
||||||
libnm_tests_test_remote_settings_client_LDADD = $(libnm_tests_ldadd)
|
libnm_tests_test_remote_settings_client_LDADD = $(libnm_tests_ldadd)
|
||||||
libnm_tests_test_secret_agent_LDADD = $(libnm_tests_ldadd)
|
libnm_tests_test_secret_agent_LDADD = $(libnm_tests_ldadd)
|
||||||
|
|
||||||
|
$(libnm_tests_test_general_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
||||||
$(libnm_tests_test_nm_client_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
$(libnm_tests_test_nm_client_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
||||||
$(libnm_tests_test_remote_settings_client_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
$(libnm_tests_test_remote_settings_client_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
||||||
$(libnm_tests_test_secret_agent_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
$(libnm_tests_test_secret_agent_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
||||||
|
|
27
libnm/nm-libnm-utils.c
Normal file
27
libnm/nm-libnm-utils.c
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Copyright 2007 - 2008 Novell, Inc.
|
||||||
|
* Copyright 2007 - 2017 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nm-default.h"
|
||||||
|
|
||||||
|
#include "nm-libnm-utils.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
26
libnm/nm-libnm-utils.h
Normal file
26
libnm/nm-libnm-utils.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Copyright 2017 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __NM_LIBNM_UTILS_H__
|
||||||
|
#define __NM_LIBNM_UTILS_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __NM_LIBNM_UTILS_H__ */
|
34
libnm/tests/test-general.c
Normal file
34
libnm/tests/test-general.c
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* -*- 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 SC 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 2017 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nm-default.h"
|
||||||
|
|
||||||
|
#include "nm-utils/nm-test-utils.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
NMTST_DEFINE ();
|
||||||
|
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
nmtst_init (&argc, &argv, TRUE);
|
||||||
|
|
||||||
|
return g_test_run ();
|
||||||
|
}
|
Loading…
Reference in a new issue