shared/tests: add tests for libnm-core-aux

These tests cannot (easily) be under "shared/nm-libnm-core-aux/tests"
because libnm/libnm-core requires code under shared while
"nm-libnm-core-aux" requires libnm/libnm-core. With autotools that is
not problem, but with meson we include sub directories in a particular
order and there is no way to foward declare stuff (AFAIK). To avoid
the circular dependency, add the tests to "clients/common/tests", which
is always built last.
This commit is contained in:
Thomas Haller 2019-04-21 10:11:16 +02:00
parent 911f2dfe56
commit 7a25f67af7
6 changed files with 120 additions and 28 deletions

8
.gitignore vendored
View File

@ -63,9 +63,11 @@ test-*.trs
/clients/cli/nmcli
/clients/common/settings-docs.h
/clients/common/tests/test-general
/clients/common/tests/test-libnm-core-aux
/clients/nm-online
/clients/tui/newt/libnmt-newt.a
/clients/tui/nmtui
/clients/nm-online
/data/NetworkManager.service
/data/NetworkManager-wait-online.service
@ -146,8 +148,8 @@ test-*.trs
/examples/C/qt/list-connections
/examples/C/qt/change-ipv4-addresses
/shared/nm-version-macros.h
/shared/nm-utils/tests/test-shared-general
/shared/nm-version-macros.h
/introspection/org.freedesktop.NetworkManager*.[ch]
@ -278,8 +280,6 @@ test-*.trs
/src/tests/test-utils
/src/tests/test-wired-defname
/clients/common/tests/test-general
/vapi/*.vapi
# The following names are no longer present on this branch,

View File

@ -4103,6 +4103,8 @@ clients_common_tests_test_general_LDADD = \
$(clients_common_tests_test_general_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
###############################################################################
EXTRA_DIST += \
clients/common/tests/wg-test0.conf \
clients/common/tests/wg-test1.conf \
@ -4110,6 +4112,40 @@ EXTRA_DIST += \
clients/common/tests/wg-test3.conf \
$(NULL)
###############################################################################
check_programs += clients/common/tests/test-libnm-core-aux
clients_common_tests_test_libnm_core_aux_CPPFLAGS = \
$(dflt_cppflags) \
-I$(builddir)/shared \
-I$(srcdir)/shared \
-I$(builddir)/libnm-core \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm \
-I$(srcdir)/libnm \
-DNETWORKMANAGER_COMPILATION_TEST \
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \
$(CODE_COVERAGE_CFLAGS) \
$(GLIB_CFLAGS) \
$(SANITIZER_LIB_CFLAGS) \
$(NULL)
clients_common_tests_test_libnm_core_aux_LDFLAGS = \
$(CODE_COVERAGE_LDFLAGS) \
$(SANITIZER_EXEC_LDFLAGS) \
$(NULL)
clients_common_tests_test_libnm_core_aux_LDADD = \
shared/nm-libnm-core-aux/libnm-libnm-core-aux.la \
libnm/libnm.la \
shared/nm-glib-aux/libnm-glib-aux.la \
$(GLIB_LIBS) \
$(NULL)
$(clients_common_tests_test_libnm_core_aux_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
$(clients_common_tests_test_libnm_core_aux_OBJECTS): $(libnm_lib_h_pub_mkenums)
###############################################################################
# clients/cli
###############################################################################

View File

@ -1,23 +1,42 @@
test_unit = 'test-general'
deps = [
libnm_dep,
libnmc_dep,
libnmc_base_dep,
libnm_core_dep,
]
exe = executable(
'clients-' + test_unit,
test_unit + '.c',
dependencies: deps,
'clients-test-general',
'test-general.c',
dependencies: [
libnm_dep,
libnmc_dep,
libnmc_base_dep,
libnm_core_dep,
],
c_args: clients_cflags + [
'-DNETWORKMANAGER_COMPILATION_TEST',
],
)
test(
'clients/' + test_unit,
'clients/common/tests/test-general',
test_script,
args: test_args + [exe.full_path()],
)
###############################################################################
exe = executable(
'test-libnm-core-aux',
[ 'test-libnm-core-aux.c', ],
c_args: [
'-DNETWORKMANAGER_COMPILATION_TEST',
'-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT',
],
dependencies: [
libnm_dep,
shared_nm_libnm_core_aux_dep,
shared_nm_libnm_core_intern_dep,
],
)
test(
'clients/common/tests/test-libnm-core-aux',
test_script,
args: test_args + [exe.full_path()]
)

View File

@ -0,0 +1,35 @@
/*
* 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 2019 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nm-libnm-core-aux/nm-libnm-core-aux.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 ();
}

View File

@ -287,18 +287,21 @@ libnm_systemd_shared_no_logging_dep = declare_dependency(
###############################################################################
test_shared_general = executable(
'nm-utils/tests/test-shared-general',
[ 'nm-utils/tests/test-shared-general.c', ],
c_args: [
'-DNETWORKMANAGER_COMPILATION_TEST',
'-DNETWORKMANAGER_COMPILATION=(NM_NETWORKMANAGER_COMPILATION_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG)',
exe = executable(
'nm-utils/tests/test-shared-general',
[ 'nm-utils/tests/test-shared-general.c' ],
c_args: [
'-DNETWORKMANAGER_COMPILATION_TEST',
'-DNETWORKMANAGER_COMPILATION=(NM_NETWORKMANAGER_COMPILATION_GLIB|NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG)',
],
dependencies: [
shared_nm_glib_aux_dep,
shared_c_siphash_dep,
],
dependencies: shared_nm_glib_aux_dep,
link_with: shared_c_siphash,
)
test(
'shared/nm-utils/test-shared-general',
test_script,
args: test_args + [test_shared_general.full_path()]
'shared/nm-utils/tests/test-shared-general',
test_script,
args: test_args + [exe.full_path()]
)

View File

@ -461,4 +461,3 @@ int main (int argc, char **argv)
return g_test_run ();
}