diff options
| author | Michael Biebl <biebl@debian.org> | 2018-06-04 00:08:31 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-06-04 00:08:31 +0200 |
| commit | 0dd9df69fdbd475c48a0c8d5b0a1882550fe7321 (patch) | |
| tree | 249cf25643b1fe408e10679bb61613bc6540e894 /src/tests | |
| parent | 2e94a3b93171ab3fb95bf689aab1664d23988809 (diff) | |
| parent | 04bc9e1cd3544445d883ad29ea108c1645c8e7b7 (diff) | |
Update upstream source from tag 'upstream/1.11.4'
Update to upstream version '1.11.4' with Debian dir d0638aa2e32d5bae4e8daa021b9a66b7c4d6647e
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/config/meson.build | 7 | ||||
| -rw-r--r-- | src/tests/config/test-config.c | 60 | ||||
| -rw-r--r-- | src/tests/meson.build | 2 | ||||
| -rw-r--r-- | src/tests/test-general-with-expect.c | 1 | ||||
| -rw-r--r-- | src/tests/test-general.c | 5 | ||||
| -rw-r--r-- | src/tests/test-ip4-config.c | 6 | ||||
| -rw-r--r-- | src/tests/test-ip6-config.c | 6 |
7 files changed, 42 insertions, 45 deletions
diff --git a/src/tests/config/meson.build b/src/tests/config/meson.build index fb40d9a9..f542c453 100644 --- a/src/tests/config/meson.build +++ b/src/tests/config/meson.build @@ -7,16 +7,11 @@ sources = files( test_config_dir = meson.current_source_dir() -cflags = [ - '-DSRCDIR="@0@"'.format(test_config_dir), - '-DBUILDDIR="@0@"'.format(test_config_dir) -] - exe = executable( test_unit, sources, dependencies: test_nm_dep, - c_args: cflags + c_args: nm_build_cflags, ) test( diff --git a/src/tests/config/test-config.c b/src/tests/config/test-config.c index 50215756..75fef4fa 100644 --- a/src/tests/config/test-config.c +++ b/src/tests/config/test-config.c @@ -30,6 +30,9 @@ #include "nm-test-utils-core.h" +#define TEST_DIR NM_BUILD_SRCDIR"/src/tests/config" +#define BUILD_DIR NM_BUILD_BUILDDIR"/src/tests/config" + /*****************************************************************************/ static void @@ -133,9 +136,9 @@ test_config_simple (void) gs_unref_object NMDevice *dev51 = nm_test_device_new ("00:00:00:00:00:51"); gs_unref_object NMDevice *dev52 = nm_test_device_new ("00:00:00:00:00:52"); - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", NULL); + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", NULL); - g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, SRCDIR "/NetworkManager.conf"); + g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, TEST_DIR "/NetworkManager.conf"); g_assert_cmpstr (_config_get_dhcp_client_a (config), ==, "dhclient"); g_assert_cmpstr (nm_config_get_log_level (config), ==, "INFO"); g_assert_cmpint (nm_config_data_get_connectivity_interval (nm_config_get_data_orig (config)), ==, 100); @@ -164,12 +167,10 @@ test_config_simple (void) g_assert_cmpstr (value, ==, "51"); g_free (value); - value = nm_config_data_get_connection_default (nm_config_get_data_orig (config), "ipv6.route-metric", NULL); g_assert_cmpstr (value, ==, NULL); g_free (value); - value = nm_config_data_get_connection_default (nm_config_get_data_orig (config), "ipv4.route-metric", NULL); g_assert_cmpstr (value, ==, "50"); g_free (value); @@ -186,7 +187,6 @@ test_config_simple (void) g_assert_cmpstr (value, ==, "52"); g_free (value); - value = nm_config_data_get_connection_default (nm_config_get_data_orig (config), "dummy.test1", dev51); g_assert_cmpstr (value, ==, "yes"); g_free (value); @@ -209,7 +209,7 @@ test_config_non_existent (void) { GError *error = NULL; - setup_config (&error, SRCDIR "/no-such-file", "", NULL, "/no/such/dir", "", NULL); + setup_config (&error, TEST_DIR "/no-such-file", "", NULL, "/no/such/dir", "", NULL); g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND); g_clear_error (&error); } @@ -219,7 +219,7 @@ test_config_parse_error (void) { GError *error = NULL; - setup_config (&error, SRCDIR "/bad.conf", "", NULL, "/no/such/dir", "", NULL); + setup_config (&error, TEST_DIR "/bad.conf", "", NULL, "/no/such/dir", "", NULL); g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE); g_clear_error (&error); } @@ -230,12 +230,12 @@ test_config_override (void) gs_unref_object NMConfig *config = NULL; gs_strfreev char **plugins = NULL; - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", "--plugins", "alpha,beta,gamma,delta", "--connectivity-interval", "12", NULL); - g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, SRCDIR "/NetworkManager.conf"); + g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, TEST_DIR "/NetworkManager.conf"); g_assert_cmpstr (_config_get_dhcp_client_a (config), ==, "dhclient"); g_assert_cmpstr (nm_config_get_log_level (config), ==, "INFO"); g_assert_cmpint (nm_config_data_get_connectivity_interval (nm_config_get_data_orig (config)), ==, 12); @@ -256,7 +256,7 @@ test_config_global_dns (void) NMGlobalDnsDomain *domain; const char *const*strv; - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", NULL); dns = nm_config_data_get_global_dns_config (nm_config_get_data_orig (config)); @@ -311,7 +311,7 @@ test_config_global_dns (void) g_object_unref (config); /* Check that a file without a default domain section gives a NULL configuration */ - config = setup_config (NULL, SRCDIR "/global-dns-invalid.conf", "", NULL, + config = setup_config (NULL, TEST_DIR "/global-dns-invalid.conf", "", NULL, "/no/such/dir", "", NULL); dns = nm_config_data_get_global_dns_config (nm_config_get_data_orig (config)); g_assert (!dns); @@ -322,12 +322,12 @@ static void test_config_connectivity_check (void) { #if WITH_CONCHECK - const char *CONFIG_INTERN = BUILDDIR"/test-connectivity-check-intern.conf"; + const char *CONFIG_INTERN = BUILD_DIR"/test-connectivity-check-intern.conf"; NMConfig *config; NMConnectivity *connectivity; g_assert (g_file_set_contents (CONFIG_INTERN, "", 0, NULL)); - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", CONFIG_INTERN, NULL, + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", CONFIG_INTERN, NULL, "/no/such/dir", "", NULL); connectivity = nm_connectivity_get(); @@ -374,7 +374,7 @@ test_config_no_auto_default (void) g_assert_cmpint (nwrote, ==, 18); nm_close (fd); - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", "--no-auto-default", state_file, NULL); @@ -396,7 +396,7 @@ test_config_no_auto_default (void) g_object_unref (config); - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", "--no-auto-default", state_file, NULL); @@ -424,9 +424,9 @@ test_config_confdir (void) char *value; GSList *specs; - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL); + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL); - g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, SRCDIR "/NetworkManager.conf"); + g_assert_cmpstr (nm_config_data_get_config_main_file (nm_config_get_data_orig (config)), ==, TEST_DIR "/NetworkManager.conf"); g_assert_cmpstr (_config_get_dhcp_client_a (config), ==, "dhcpcd"); g_assert_cmpstr (nm_config_get_log_level (config), ==, "INFO"); g_assert_cmpstr (nm_config_get_log_domains (config), ==, "PLATFORM,DNS,WIFI"); @@ -527,8 +527,8 @@ test_config_confdir_parse_error (void) { GError *error = NULL; - /* Using SRCDIR as the conf dir will pick up bad.conf */ - setup_config (&error, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR, "", NULL); + /* Using TEST_DIR as the conf dir will pick up bad.conf */ + setup_config (&error, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR, "", NULL); g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE); g_clear_error (&error); } @@ -811,8 +811,8 @@ static void test_config_set_values (void) { gs_unref_object NMConfig *config = NULL; - const char *CONFIG_USER = BUILDDIR"/test-set-values-user.conf"; - const char *CONFIG_INTERN = BUILDDIR"/test-set-values-intern.conf"; + const char *CONFIG_USER = BUILD_DIR"/test-set-values-user.conf"; + const char *CONFIG_INTERN = BUILD_DIR"/test-set-values-intern.conf"; const char *atomic_section_prefixes[] = { "atomic-prefix-1.", "atomic-prefix-2.", @@ -896,7 +896,7 @@ test_config_signal (void) NMConfigChangeFlags expected; gs_unref_object NMConfigData *config_data_orig = NULL; - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL); + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL); config_data_orig = g_object_ref (nm_config_get_data_orig (config)); @@ -917,7 +917,6 @@ test_config_signal (void) NMTST_EXPECT_NM_INFO ("config: signal: SIGHUP (no changes from disk)*"); nm_config_reload (config, expected); - /* test with subscribing two signals... * * This test exposes glib bug https://bugzilla.redhat.com/show_bug.cgi?id=1260577 @@ -931,7 +930,6 @@ test_config_signal (void) nm_config_reload (config, NM_CONFIG_CHANGE_CAUSE_SIGUSR2); g_signal_handlers_disconnect_by_func (config, _test_signal_config_changed_cb2, &expected); - g_signal_handlers_disconnect_by_func (config, _test_signal_config_changed_cb, &expected); g_assert (config_data_orig == nm_config_get_data (config)); @@ -950,19 +948,19 @@ test_config_enable (void) _nm_config_match_env = g_strdup ("something-else"); _nm_config_match_nm_version = nm_encode_version (1, 3, 4); - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL); + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL); assert_config_value (nm_config_get_data_orig (config), "test-group-config-enable-1", "key1", NULL); g_clear_object (&config); _nm_config_match_nm_version = nm_encode_version (1, 5, 32); - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL); + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL); assert_config_value (nm_config_get_data_orig (config), "test-group-config-enable-1", "key1", "enabled"); g_clear_object (&config); _nm_config_match_nm_version = nm_encode_version (1, 5, 3); g_clear_pointer (&_nm_config_match_env, g_free); _nm_config_match_env = g_strdup ("test-match-env-1"); - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", NULL); + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL); assert_config_value (nm_config_get_data_orig (config), "test-group-config-enable-1", "key1", "enabled"); g_clear_object (&config); @@ -982,14 +980,14 @@ test_config_state_file (void) gboolean ret; gs_free char *file_data = NULL; gsize file_size; - const char *const TMP_FILE = BUILDDIR "/tmp.state"; + const char *const TMP_FILE = BUILD_DIR "/tmp.state"; - ret = g_file_get_contents (SRCDIR "/NetworkManager.state", &file_data, &file_size, &error); + ret = g_file_get_contents (TEST_DIR "/NetworkManager.state", &file_data, &file_size, &error); nmtst_assert_success (ret, error); ret = g_file_set_contents (TMP_FILE, file_data, file_size, &error); nmtst_assert_success (ret, error); - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", "--state-file", TMP_FILE, NULL); g_assert (config); @@ -1015,7 +1013,7 @@ test_config_state_file (void) g_object_unref (config); /* Reload configuration */ - config = setup_config (NULL, SRCDIR "/NetworkManager.conf", "", NULL, SRCDIR "/conf.d", "", + config = setup_config (NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", "--state-file", TMP_FILE, NULL); g_assert (config); diff --git a/src/tests/meson.build b/src/tests/meson.build index 386ede87..430ffe43 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -33,7 +33,7 @@ cflags = [ exe = executable( test_unit, - [test_unit + '.c'] + shared_siphash, + [test_unit + '.c'], include_directories: src_inc, dependencies: nm_core_dep, c_args: cflags, diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c index f67c332b..a78b5311 100644 --- a/src/tests/test-general-with-expect.c +++ b/src/tests/test-general-with-expect.c @@ -313,7 +313,6 @@ do_test_nm_utils_kill_child (void) NMTST_EXPECT_NM_DEBUG ("kill child process 'test-s-4' (*): after sending SIGTERM (15) and SIGKILL, process * exited by signal 9 (* usec elapsed)"); test_nm_utils_kill_child_sync_do ("test-s-4", pid4s, SIGTERM, 1, TRUE, &expected_signal_KILL); - NMTST_EXPECT_NM_DEBUG ("kill child process 'test-a-1-1' (*): wait for process to terminate after sending SIGTERM (15) (send SIGKILL in 3000 milliseconds)..."); NMTST_EXPECT_NM_DEBUG ("kill child process 'test-a-1-1' (*): terminated by signal 15 (* usec elapsed)"); test_nm_utils_kill_child_async_do ("test-a-1-1", pid1a_1, SIGTERM, 3000, TRUE, &expected_signal_TERM); diff --git a/src/tests/test-general.c b/src/tests/test-general.c index 38eaf25e..4db05ac8 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -709,7 +709,6 @@ test_connection_no_match_ip4_addr (void) NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); - s_ip4 = nm_connection_get_setting_ip4_config (orig); g_assert (s_ip4); g_object_set (G_OBJECT (s_ip4), @@ -1232,7 +1231,6 @@ _do_test_match_spec_config (const char *file, gint line, const char *spec_str, g GSList *specs2 = g_slist_append (NULL, sss); NMMatchSpecMatchType match_result2; - match_result2 = nm_match_spec_config (specs2, version, NULL); if (match_result == NM_MATCH_SPEC_NO_MATCH) g_assert_cmpint (match_result2, ==, NM_MATCH_SPEC_NO_MATCH); @@ -1289,7 +1287,6 @@ test_match_spec_config (void) do_test_match_spec_config ("nm-version-min:1", 1, 3, 30, NM_MATCH_SPEC_MATCH); do_test_match_spec_config ("nm-version-min:1", 1, 4, 30, NM_MATCH_SPEC_MATCH); - do_test_match_spec_config ("nm-version-max:1.2.3", 0, 2, 30, NM_MATCH_SPEC_NO_MATCH); do_test_match_spec_config ("nm-version-max:1.2.3", 1, 1, 1, NM_MATCH_SPEC_NO_MATCH); do_test_match_spec_config ("nm-version-max:1.2.3", 1, 2, 0, NM_MATCH_SPEC_MATCH); @@ -1624,7 +1621,7 @@ do_test_stable_id_parse (const char *stable_id, else g_assert (stable_id); - stable_type = nm_utils_stable_id_parse (stable_id, "_CONNECTION", "_BOOT", &generated); + stable_type = nm_utils_stable_id_parse (stable_id, "_DEVICE", "_BOOT", "_CONNECTION", &generated); g_assert_cmpint (expected_stable_type, ==, stable_type); diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c index 4c3c344e..9fea6af5 100644 --- a/src/tests/test-ip4-config.c +++ b/src/tests/test-ip4-config.c @@ -319,11 +319,15 @@ test_strip_search_trailing_dot (void) nm_ip4_config_add_search (config, "bar."); nm_ip4_config_add_search (config, "baz.com"); nm_ip4_config_add_search (config, "baz.com."); + nm_ip4_config_add_search (config, "foobar.."); + nm_ip4_config_add_search (config, ".foobar"); + nm_ip4_config_add_search (config, "~."); - g_assert_cmpuint (nm_ip4_config_get_num_searches (config), ==, 3); + g_assert_cmpuint (nm_ip4_config_get_num_searches (config), ==, 4); g_assert_cmpstr (nm_ip4_config_get_search (config, 0), ==, "foo"); g_assert_cmpstr (nm_ip4_config_get_search (config, 1), ==, "bar"); g_assert_cmpstr (nm_ip4_config_get_search (config, 2), ==, "baz.com"); + g_assert_cmpstr (nm_ip4_config_get_search (config, 3), ==, "~"); g_object_unref (config); } diff --git a/src/tests/test-ip6-config.c b/src/tests/test-ip6-config.c index 816a816f..a03d89b0 100644 --- a/src/tests/test-ip6-config.c +++ b/src/tests/test-ip6-config.c @@ -340,11 +340,15 @@ test_strip_search_trailing_dot (void) nm_ip6_config_add_search (config, "bar."); nm_ip6_config_add_search (config, "baz.com"); nm_ip6_config_add_search (config, "baz.com."); + nm_ip6_config_add_search (config, "foobar.."); + nm_ip6_config_add_search (config, ".foobar"); + nm_ip6_config_add_search (config, "~."); - g_assert_cmpuint (nm_ip6_config_get_num_searches (config), ==, 3); + g_assert_cmpuint (nm_ip6_config_get_num_searches (config), ==, 4); g_assert_cmpstr (nm_ip6_config_get_search (config, 0), ==, "foo"); g_assert_cmpstr (nm_ip6_config_get_search (config, 1), ==, "bar"); g_assert_cmpstr (nm_ip6_config_get_search (config, 2), ==, "baz.com"); + g_assert_cmpstr (nm_ip6_config_get_search (config, 3), ==, "~"); g_object_unref (config); } |