diff options
| author | Iain Lane <iain@orangesquash.org.uk> | 2018-09-24 09:29:55 +0100 |
|---|---|---|
| committer | Iain Lane <iain@orangesquash.org.uk> | 2018-09-24 09:29:55 +0100 |
| commit | e152ec7bf4ba252ff9d3eb13eabd417b931dac9a (patch) | |
| tree | c323cf856ee0bb8e44590670dd54c19653a55748 /libnm-glib/tests | |
| parent | ee9c73a923909e23a649407be77e25235d769e25 (diff) | |
Import Upstream version 1.12.2
Diffstat (limited to 'libnm-glib/tests')
| -rw-r--r-- | libnm-glib/tests/meson.build | 31 | ||||
| -rw-r--r-- | libnm-glib/tests/test-nm-client.c | 22 | ||||
| -rw-r--r-- | libnm-glib/tests/test-remote-settings-client.c | 21 |
3 files changed, 65 insertions, 9 deletions
diff --git a/libnm-glib/tests/meson.build b/libnm-glib/tests/meson.build new file mode 100644 index 00000000..34779018 --- /dev/null +++ b/libnm-glib/tests/meson.build @@ -0,0 +1,31 @@ +deps = [ + dbus_dep, + dbus_glib_dep, + libnm_glib_dep, + libnm_util_dep, + shared_dep +] + +test_units = [ + 'test-nm-client', + 'test-remote-settings-client' +] + +foreach test_unit: test_units + exe = executable( + test_unit, + [test_unit + '.c'] + shared_nm_test_utils_impl_c, + dependencies: deps, + c_args: + common_cflags + [ + '-DNETWORKMANAGER_COMPILATION_TEST', + ] + + nm_build_cflags, + ) + + test( + 'libnm-glib/' + test_unit, + test_script, + args: test_args + [exe.full_path()] + ) +endforeach diff --git a/libnm-glib/tests/test-nm-client.c b/libnm-glib/tests/test-nm-client.c index b6b5968b..df857215 100644 --- a/libnm-glib/tests/test-nm-client.c +++ b/libnm-glib/tests/test-nm-client.c @@ -155,6 +155,9 @@ test_device_added (void) DeviceAddedInfo info = { loop, FALSE, FALSE, 0, 0 }; sinfo = nmtstc_service_init (); + if (!nmtstc_service_available (sinfo)) + return; + client = nmtstc_nm_client_new (); devices = nm_client_get_devices (client); @@ -312,6 +315,9 @@ test_wifi_ap_added_removed (void) char *expected_path = NULL; sinfo = nmtstc_service_init (); + if (!nmtstc_service_available (sinfo)) + return; + client = nmtstc_nm_client_new (); /*************************************/ @@ -535,6 +541,9 @@ test_wimax_nsp_added_removed (void) char *expected_path = NULL; sinfo = nmtstc_service_init (); + if (!nmtstc_service_available (sinfo)) + return; + client = nmtstc_nm_client_new (); /*************************************/ @@ -720,6 +729,9 @@ test_devices_array (void) GVariant *ret; sinfo = nmtstc_service_init (); + if (!nmtstc_service_available (sinfo)) + return; + client = nmtstc_nm_client_new (); /*************************************/ @@ -820,7 +832,8 @@ manager_running_changed (GObject *client, static void test_client_manager_running (void) { - NMClient *client1, *client2; + gs_unref_object NMClient *client1 = NULL; + gs_unref_object NMClient *client2 = NULL; guint quit_id; int running_changed = 0; GError *error = NULL; @@ -842,6 +855,9 @@ test_client_manager_running (void) /* Now start the test service. */ sinfo = nmtstc_service_init (); + if (!nmtstc_service_available (sinfo)) + return; + client2 = nmtstc_nm_client_new (); /* client2 should know that NM is running, but the previously-created @@ -868,9 +884,6 @@ test_client_manager_running (void) g_assert_cmpint (running_changed, ==, 2); g_assert (!nm_client_get_manager_running (client1)); g_source_remove (quit_id); - - g_object_unref (client1); - g_object_unref (client2); } /*****************************************************************************/ @@ -1078,7 +1091,6 @@ test_connection_invalid (void) nmtst_assert_connection_unnormalizable (connections->pdata[idx[1]], 0, 0); nmtst_assert_connection_verifies_without_normalization (connections->pdata[idx[2]]); - /************************************************************************** * Modify the invalid connection and make it valid *************************************************************************/ diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c index 57bc4faa..031e83f8 100644 --- a/libnm-glib/tests/test-remote-settings-client.c +++ b/libnm-glib/tests/test-remote-settings-client.c @@ -70,6 +70,9 @@ test_add_connection (void) time_t start, now; gboolean done = FALSE; + if (!nmtstc_service_available (sinfo)) + return; + connection = nm_connection_new (); s_con = (NMSettingConnection *) nm_setting_connection_new (); @@ -145,6 +148,9 @@ test_make_invisible (void) gboolean done = FALSE, has_settings = FALSE; char *path; + if (!nmtstc_service_available (sinfo)) + return; + g_assert (remote != NULL); /* Listen for the remove event when the connection becomes invisible */ @@ -212,6 +218,9 @@ test_make_visible (void) char *path; NMRemoteConnection *new = NULL; + if (!nmtstc_service_available (sinfo)) + return; + g_assert (remote != NULL); /* Wait for the new-connection signal when the connection is visible again */ @@ -229,7 +238,6 @@ test_make_visible (void) dbus_g_proxy_begin_call (proxy, "SetVisible", set_visible_cb, NULL, NULL, G_TYPE_BOOLEAN, TRUE, G_TYPE_INVALID); - /* Wait for the settings service to announce the connection again */ start = time (NULL); do { @@ -293,6 +301,9 @@ test_remove_connection (void) gboolean done = FALSE; char *path; + if (!nmtstc_service_available (sinfo)) + return; + /* Find a connection to delete */ list = nm_remote_settings_list_connections (settings); g_assert_cmpint (g_slist_length (list), >, 0); @@ -361,11 +372,14 @@ settings_service_running_changed (GObject *client, static void test_service_running (void) { - NMRemoteSettings *settings2; + gs_unref_object NMRemoteSettings *settings2 = NULL; guint quit_id; int running_changed = 0; gboolean running; + if (!nmtstc_service_available (sinfo)) + return; + loop = g_main_loop_new (NULL, FALSE); g_object_get (G_OBJECT (settings), @@ -404,6 +418,7 @@ test_service_running (void) /* Now restart it */ sinfo = nmtstc_service_init (); + g_assert (nmtstc_service_available (sinfo)); quit_id = g_timeout_add_seconds (5, loop_quit, loop); g_main_loop_run (loop); @@ -414,8 +429,6 @@ test_service_running (void) NM_REMOTE_SETTINGS_SERVICE_RUNNING, &running, NULL); g_assert (running == TRUE); - - g_object_unref (settings2); } /*****************************************************************************/ |