|
Packit Service |
87a54e |
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Copyright (C) 2010 - 2014 Red Hat, Inc.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit Service |
2bceb2 |
#include "libnm/nm-default-libnm.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include <sys/types.h>
|
|
Packit |
5756e2 |
#include <signal.h>
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-test-libnm-utils.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static struct {
|
|
Packit Service |
a1bd4f |
GMainLoop *loop;
|
|
Packit Service |
a1bd4f |
} gl = {};
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
loop_quit(gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_main_loop_quit((GMainLoop *) user_data);
|
|
Packit Service |
a1bd4f |
return G_SOURCE_REMOVE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
devices_notify_cb(NMClient *c, GParamSpec *pspec, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
gboolean * notified = user_data;
|
|
Packit Service |
a1bd4f |
const GPtrArray *devices;
|
|
Packit Service |
a1bd4f |
NMDevice * device;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(c);
|
|
Packit Service |
a1bd4f |
g_assert(devices);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(devices->len, ==, 1);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
device = g_ptr_array_index(devices, 0);
|
|
Packit Service |
a1bd4f |
g_assert(device);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_device_get_iface(device), ==, "eth0");
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
*notified = TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_device_added(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMClient *client = NULL;
|
|
Packit Service |
a1bd4f |
const GPtrArray * devices;
|
|
Packit Service |
a1bd4f |
NMDevice * device;
|
|
Packit Service |
a1bd4f |
gboolean notified = FALSE;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
sinfo = nmtstc_service_init();
|
|
Packit Service |
a1bd4f |
if (!nmtstc_service_available(sinfo))
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
client = nmtstc_client_new(TRUE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(client);
|
|
Packit Service |
a1bd4f |
g_assert(devices->len == 0);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_signal_connect(client, "notify::devices", (GCallback) devices_notify_cb, ¬ified);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Tell the test service to add a new device */
|
|
Packit Service |
a1bd4f |
nmtstc_service_add_device(sinfo, client, "AddWiredDevice", "eth0");
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* coverity[loop_condition] */
|
|
Packit Service |
a1bd4f |
while (!notified)
|
|
Packit Service |
a1bd4f |
g_main_context_iteration(NULL, TRUE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(client, devices_notify_cb, ¬ified);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(client);
|
|
Packit Service |
a1bd4f |
g_assert(devices);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(devices->len, ==, 1);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
device = g_ptr_array_index(devices, 0);
|
|
Packit Service |
a1bd4f |
g_assert(device);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_device_get_iface(device), ==, "eth0");
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Try deleting the device via the ordinary NM interface, which should fail */
|
|
Packit Service |
a1bd4f |
nm_device_delete(device, NULL, &error);
|
|
Packit Service |
a1bd4f |
g_assert_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_NOT_SOFTWARE);
|
|
Packit Service |
a1bd4f |
g_clear_error(&error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef enum {
|
|
Packit Service |
a1bd4f |
SIGNAL_FIRST = 0x01,
|
|
Packit Service |
a1bd4f |
SIGNAL_SECOND = 0x02,
|
|
Packit Service |
a1bd4f |
SIGNAL_MASK = 0x0F,
|
|
Packit Service |
a1bd4f |
NOTIFY_FIRST = 0x10,
|
|
Packit Service |
a1bd4f |
NOTIFY_SECOND = 0x20,
|
|
Packit Service |
a1bd4f |
NOTIFY_MASK = 0xF0
|
|
Packit |
5756e2 |
} DeviceSignaledAfterInitType;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
device_sai_added_cb(NMClient *c, NMDevice *device, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
guint *result = user_data;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_assert(device);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_device_get_iface(device), ==, "eth0");
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_assert((*result & SIGNAL_MASK) == 0);
|
|
Packit Service |
a1bd4f |
*result |= *result ? SIGNAL_SECOND : SIGNAL_FIRST;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
devices_sai_notify_cb(NMClient *c, GParamSpec *pspec, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
guint * result = user_data;
|
|
Packit Service |
a1bd4f |
const GPtrArray *devices;
|
|
Packit Service |
a1bd4f |
NMDevice * device;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(pspec->name, ==, "devices");
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(c);
|
|
Packit Service |
a1bd4f |
g_assert(devices);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(devices->len, ==, 1);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
device = g_ptr_array_index(devices, 0);
|
|
Packit Service |
a1bd4f |
g_assert(device);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_device_get_iface(device), ==, "eth0");
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_assert((*result & NOTIFY_MASK) == 0);
|
|
Packit Service |
a1bd4f |
*result |= *result ? NOTIFY_SECOND : NOTIFY_FIRST;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_device_added_signal_after_init(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMClient *client = NULL;
|
|
Packit Service |
a1bd4f |
const GPtrArray * devices;
|
|
Packit Service |
a1bd4f |
NMDevice * device;
|
|
Packit Service |
a1bd4f |
guint result = 0;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
sinfo = nmtstc_service_init();
|
|
Packit Service |
a1bd4f |
if (!nmtstc_service_available(sinfo))
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
client = nmtstc_client_new(TRUE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(client);
|
|
Packit Service |
a1bd4f |
g_assert(devices->len == 0);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_signal_connect(client, NM_CLIENT_DEVICE_ADDED, (GCallback) device_sai_added_cb, &result);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_signal_connect(client,
|
|
Packit Service |
a1bd4f |
"notify::" NM_CLIENT_DEVICES,
|
|
Packit Service |
a1bd4f |
(GCallback) devices_sai_notify_cb,
|
|
Packit Service |
a1bd4f |
&result);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Tell the test service to add a new device */
|
|
Packit Service |
a1bd4f |
nmtstc_service_add_device(sinfo, client, "AddWiredDevice", "eth0");
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* Ensure the 'device-added' signal doesn't show up before
|
|
Packit Service |
a1bd4f |
* the 'Devices' property change notification */
|
|
Packit Service |
a1bd4f |
/* coverity[loop_condition] */
|
|
Packit Service |
a1bd4f |
while (!(result & SIGNAL_MASK) && !(result & NOTIFY_MASK))
|
|
Packit Service |
a1bd4f |
g_main_context_iteration(NULL, TRUE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(client, device_sai_added_cb, &result);
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(client, devices_sai_notify_cb, &result);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_assert((result & SIGNAL_MASK) == SIGNAL_SECOND);
|
|
Packit Service |
a1bd4f |
g_assert((result & NOTIFY_MASK) == NOTIFY_FIRST);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(client);
|
|
Packit Service |
a1bd4f |
g_assert(devices);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(devices->len, ==, 1);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
device = g_ptr_array_index(devices, 0);
|
|
Packit Service |
a1bd4f |
g_assert(device);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_device_get_iface(device), ==, "eth0");
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static const char *expected_bssid = "66:55:44:33:22:11";
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
GMainLoop *loop;
|
|
Packit Service |
a1bd4f |
gboolean found;
|
|
Packit Service |
a1bd4f |
char * ap_path;
|
|
Packit Service |
a1bd4f |
gboolean signaled;
|
|
Packit Service |
a1bd4f |
gboolean notified;
|
|
Packit Service |
a1bd4f |
guint quit_id;
|
|
Packit Service |
a1bd4f |
guint quit_count;
|
|
Packit |
5756e2 |
} WifiApInfo;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
wifi_check_quit(WifiApInfo *info)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
info->quit_count--;
|
|
Packit Service |
a1bd4f |
if (info->quit_count == 0) {
|
|
Packit Service |
a1bd4f |
g_source_remove(info->quit_id);
|
|
Packit Service |
a1bd4f |
info->quit_id = 0;
|
|
Packit Service |
a1bd4f |
g_main_loop_quit(info->loop);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
got_ap_path(WifiApInfo *info, const char *path)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
if (info->ap_path)
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(info->ap_path, ==, path);
|
|
Packit Service |
a1bd4f |
else
|
|
Packit Service |
a1bd4f |
info->ap_path = g_strdup(path);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
wifi_ap_added_cb(NMDeviceWifi *w, NMAccessPoint *ap, WifiApInfo *info)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_assert(ap);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_access_point_get_bssid(ap), ==, expected_bssid);
|
|
Packit Service |
a1bd4f |
got_ap_path(info, nm_object_get_path(NM_OBJECT(ap)));
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->signaled = TRUE;
|
|
Packit Service |
a1bd4f |
wifi_check_quit(info);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
wifi_ap_add_notify_cb(NMDeviceWifi *w, GParamSpec *pspec, WifiApInfo *info)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
const GPtrArray *aps;
|
|
Packit Service |
a1bd4f |
NMAccessPoint * ap;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
aps = nm_device_wifi_get_access_points(w);
|
|
Packit Service |
a1bd4f |
g_assert(aps);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(aps->len, ==, 1);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
ap = g_ptr_array_index(aps, 0);
|
|
Packit Service |
a1bd4f |
g_assert(ap);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_access_point_get_bssid(ap), ==, "66:55:44:33:22:11");
|
|
Packit Service |
a1bd4f |
got_ap_path(info, nm_object_get_path(NM_OBJECT(ap)));
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->notified = TRUE;
|
|
Packit Service |
a1bd4f |
wifi_check_quit(info);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
wifi_ap_removed_cb(NMDeviceWifi *w, NMAccessPoint *ap, WifiApInfo *info)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_assert(ap);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(info->ap_path, ==, nm_object_get_path(NM_OBJECT(ap)));
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->signaled = TRUE;
|
|
Packit Service |
a1bd4f |
wifi_check_quit(info);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
wifi_ap_remove_notify_cb(NMDeviceWifi *w, GParamSpec *pspec, WifiApInfo *info)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
const GPtrArray *aps;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
aps = nm_device_wifi_get_access_points(w);
|
|
Packit Service |
a1bd4f |
g_assert(aps->len == 0);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->notified = TRUE;
|
|
Packit Service |
a1bd4f |
wifi_check_quit(info);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_wifi_ap_added_removed(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMClient *client = NULL;
|
|
Packit Service |
a1bd4f |
NMDeviceWifi * wifi;
|
|
Packit Service |
a1bd4f |
WifiApInfo info = {gl.loop, FALSE, FALSE, 0, 0};
|
|
Packit Service |
a1bd4f |
GVariant * ret;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
gs_free char * expected_path = NULL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
sinfo = nmtstc_service_init();
|
|
Packit Service |
a1bd4f |
if (!nmtstc_service_available(sinfo))
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
client = nmtstc_client_new(TRUE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/*************************************/
|
|
Packit Service |
a1bd4f |
/* Add the wifi device */
|
|
Packit Service |
a1bd4f |
wifi = (NMDeviceWifi *) nmtstc_service_add_device(sinfo, client, "AddWifiDevice", "wlan0");
|
|
Packit Service |
a1bd4f |
g_assert(NM_IS_DEVICE_WIFI(wifi));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/*************************************/
|
|
Packit Service |
a1bd4f |
/* Add the wifi AP */
|
|
Packit Service |
a1bd4f |
info.signaled = FALSE;
|
|
Packit Service |
a1bd4f |
info.notified = FALSE;
|
|
Packit Service |
a1bd4f |
info.quit_id = 0;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
ret = g_dbus_proxy_call_sync(sinfo->proxy,
|
|
Packit Service |
a1bd4f |
"AddWifiAp",
|
|
Packit Service |
a1bd4f |
g_variant_new("(sss)", "wlan0", "test-ap", expected_bssid),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NO_AUTO_START,
|
|
Packit Service |
a1bd4f |
3000,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_assert(ret);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(g_variant_get_type_string(ret), ==, "(o)");
|
|
Packit Service |
a1bd4f |
g_variant_get(ret, "(o)", &expected_path);
|
|
Packit Service |
a1bd4f |
g_variant_unref(ret);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_signal_connect(wifi, "access-point-added", (GCallback) wifi_ap_added_cb, &info;;
|
|
Packit Service |
a1bd4f |
info.quit_count = 1;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_signal_connect(wifi, "notify::access-points", (GCallback) wifi_ap_add_notify_cb, &info;;
|
|
Packit Service |
a1bd4f |
info.quit_count++;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Wait for libnm to find the AP */
|
|
Packit Service |
a1bd4f |
info.quit_id = g_timeout_add_seconds(5, loop_quit, gl.loop);
|
|
Packit Service |
a1bd4f |
g_main_loop_run(gl.loop);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert(info.signaled);
|
|
Packit Service |
a1bd4f |
g_assert(info.notified);
|
|
Packit Service |
a1bd4f |
g_assert(info.ap_path);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(info.ap_path, ==, expected_path);
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(wifi, wifi_ap_added_cb, &info;;
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(wifi, wifi_ap_add_notify_cb, &info;;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/*************************************/
|
|
Packit Service |
a1bd4f |
/* Remove the wifi device */
|
|
Packit Service |
a1bd4f |
info.signaled = FALSE;
|
|
Packit Service |
a1bd4f |
info.notified = FALSE;
|
|
Packit Service |
a1bd4f |
info.quit_id = 0;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
ret = g_dbus_proxy_call_sync(sinfo->proxy,
|
|
Packit Service |
a1bd4f |
"RemoveWifiAp",
|
|
Packit Service |
a1bd4f |
g_variant_new("(so)", "wlan0", expected_path),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NO_AUTO_START,
|
|
Packit Service |
a1bd4f |
3000,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
nm_clear_pointer(&ret, g_variant_unref);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_signal_connect(wifi, "access-point-removed", (GCallback) wifi_ap_removed_cb, &info;;
|
|
Packit Service |
a1bd4f |
info.quit_count = 1;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_signal_connect(wifi, "notify::access-points", (GCallback) wifi_ap_remove_notify_cb, &info;;
|
|
Packit Service |
a1bd4f |
info.quit_count++;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Wait for libnm to find the AP */
|
|
Packit Service |
a1bd4f |
info.quit_id = g_timeout_add_seconds(5, loop_quit, gl.loop);
|
|
Packit Service |
a1bd4f |
g_main_loop_run(gl.loop);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert(info.signaled);
|
|
Packit Service |
a1bd4f |
g_assert(info.notified);
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(wifi, wifi_ap_removed_cb, &info;;
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(wifi, wifi_ap_remove_notify_cb, &info;;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_free(info.ap_path);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
GMainLoop *loop;
|
|
Packit Service |
a1bd4f |
gboolean signaled;
|
|
Packit Service |
a1bd4f |
gboolean notified;
|
|
Packit Service |
a1bd4f |
guint quit_count;
|
|
Packit Service |
a1bd4f |
guint quit_id;
|
|
Packit |
5756e2 |
} DaInfo;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
da_check_quit(DaInfo *info)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
info->quit_count--;
|
|
Packit Service |
a1bd4f |
if (info->quit_count == 0) {
|
|
Packit Service |
a1bd4f |
g_source_remove(info->quit_id);
|
|
Packit Service |
a1bd4f |
info->quit_id = 0;
|
|
Packit Service |
a1bd4f |
g_main_loop_quit(info->loop);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
da_device_removed_cb(NMClient *c, NMDevice *device, DaInfo *info)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_device_get_iface(device), ==, "eth0");
|
|
Packit Service |
a1bd4f |
info->signaled = TRUE;
|
|
Packit Service |
a1bd4f |
da_check_quit(info);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
da_devices_notify_cb(NMClient *c, GParamSpec *pspec, DaInfo *info)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
const GPtrArray *devices;
|
|
Packit Service |
a1bd4f |
NMDevice * device;
|
|
Packit Service |
a1bd4f |
guint i;
|
|
Packit Service |
a1bd4f |
const char * iface;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(c);
|
|
Packit Service |
a1bd4f |
g_assert(devices);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(devices->len, ==, 2);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
for (i = 0; i < devices->len; i++) {
|
|
Packit Service |
a1bd4f |
device = g_ptr_array_index(devices, i);
|
|
Packit Service |
a1bd4f |
iface = nm_device_get_iface(device);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_assert(!strcmp(iface, "wlan0") || !strcmp(iface, "eth1"));
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->notified = TRUE;
|
|
Packit Service |
a1bd4f |
da_check_quit(info);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_devices_array(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMClient *client = NULL;
|
|
Packit Service |
a1bd4f |
DaInfo info = {gl.loop};
|
|
Packit Service |
a1bd4f |
NMDevice * wlan0, *eth0, *eth1, *device;
|
|
Packit Service |
a1bd4f |
const GPtrArray * devices;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
GVariant * ret;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
sinfo = nmtstc_service_init();
|
|
Packit Service |
a1bd4f |
if (!nmtstc_service_available(sinfo))
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
client = nmtstc_client_new(TRUE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/*************************************/
|
|
Packit Service |
a1bd4f |
/* Add some devices */
|
|
Packit Service |
a1bd4f |
wlan0 = nmtstc_service_add_device(sinfo, client, "AddWifiDevice", "wlan0");
|
|
Packit Service |
a1bd4f |
eth0 = nmtstc_service_add_device(sinfo, client, "AddWiredDevice", "eth0");
|
|
Packit Service |
a1bd4f |
eth1 = nmtstc_service_add_device(sinfo, client, "AddWiredDevice", "eth1");
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Ensure the devices now exist */
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(client);
|
|
Packit Service |
a1bd4f |
g_assert(devices);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(devices->len, ==, 3);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device = nm_client_get_device_by_iface(client, "wlan0");
|
|
Packit Service |
a1bd4f |
g_assert(NM_IS_DEVICE_WIFI(device));
|
|
Packit Service |
a1bd4f |
g_assert(device == wlan0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device = nm_client_get_device_by_iface(client, "eth0");
|
|
Packit Service |
a1bd4f |
g_assert(NM_IS_DEVICE_ETHERNET(device));
|
|
Packit Service |
a1bd4f |
g_assert(device == eth0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device = nm_client_get_device_by_iface(client, "eth1");
|
|
Packit Service |
a1bd4f |
g_assert(NM_IS_DEVICE_ETHERNET(device));
|
|
Packit Service |
a1bd4f |
g_assert(device == eth1);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/********************************/
|
|
Packit Service |
a1bd4f |
/* Now remove the device in the middle */
|
|
Packit Service |
a1bd4f |
ret = g_dbus_proxy_call_sync(sinfo->proxy,
|
|
Packit Service |
a1bd4f |
"RemoveDevice",
|
|
Packit Service |
a1bd4f |
g_variant_new("(o)", nm_object_get_path(NM_OBJECT(eth0))),
|
|
Packit Service |
a1bd4f |
G_DBUS_CALL_FLAGS_NO_AUTO_START,
|
|
Packit Service |
a1bd4f |
3000,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
&error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_assert(ret);
|
|
Packit Service |
a1bd4f |
g_variant_unref(ret);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_signal_connect(client, "device-removed", (GCallback) da_device_removed_cb, &info;;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_signal_connect(client, "notify::devices", (GCallback) da_devices_notify_cb, &info;;
|
|
Packit Service |
a1bd4f |
info.quit_count = 2;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Wait for libnm to notice the changes */
|
|
Packit Service |
a1bd4f |
info.quit_id = g_timeout_add_seconds(5, loop_quit, gl.loop);
|
|
Packit Service |
a1bd4f |
g_main_loop_run(gl.loop);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(info.quit_count, ==, 0);
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(client, da_device_removed_cb, &info;;
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(client, da_devices_notify_cb, &info;;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Ensure only two are left */
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(client);
|
|
Packit Service |
a1bd4f |
g_assert(devices);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(devices->len, ==, 2);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device = nm_client_get_device_by_iface(client, "wlan0");
|
|
Packit Service |
a1bd4f |
g_assert(NM_IS_DEVICE_WIFI(device));
|
|
Packit Service |
a1bd4f |
g_assert(device == wlan0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device = nm_client_get_device_by_iface(client, "eth1");
|
|
Packit Service |
a1bd4f |
g_assert(NM_IS_DEVICE_ETHERNET(device));
|
|
Packit Service |
a1bd4f |
g_assert(device == eth1);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nm_running_changed(GObject *client, GParamSpec *pspec, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
int *running_changed = user_data;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
(*running_changed)++;
|
|
Packit Service |
a1bd4f |
g_main_loop_quit(gl.loop);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_client_nm_running(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMClient *client1 = NULL;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMClient *client2 = NULL;
|
|
Packit Service |
a1bd4f |
guint quit_id;
|
|
Packit Service |
a1bd4f |
int running_changed = 0;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
client1 = nmtstc_client_new(TRUE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert(!nm_client_get_nm_running(client1));
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_client_get_version(client1), ==, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert(!nm_client_networking_get_enabled(client1));
|
|
Packit Service |
a1bd4f |
/* This will have no effect, but it shouldn't cause any warnings either. */
|
|
Packit Service |
a1bd4f |
nm_client_networking_set_enabled(client1, TRUE, NULL);
|
|
Packit Service |
a1bd4f |
g_assert(!nm_client_networking_get_enabled(client1));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* OTOH, this should result in an error */
|
|
Packit Service |
a1bd4f |
nm_client_set_logging(client1, "DEFAULT", "INFO", &error);
|
|
Packit Service |
a1bd4f |
g_assert_error(error, NM_CLIENT_ERROR, NM_CLIENT_ERROR_MANAGER_NOT_RUNNING);
|
|
Packit Service |
a1bd4f |
g_clear_error(&error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Now start the test service. */
|
|
Packit Service |
a1bd4f |
sinfo = nmtstc_service_init();
|
|
Packit Service |
a1bd4f |
if (!nmtstc_service_available(sinfo))
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
client2 = nmtstc_client_new(FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* client2 should know that NM is running, but the previously-created
|
|
Packit Service |
a1bd4f |
* client1 hasn't gotten the news yet.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
g_assert(!nm_client_get_nm_running(client1));
|
|
Packit Service |
a1bd4f |
g_assert(nm_client_get_nm_running(client2));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_signal_connect(client1,
|
|
Packit Service |
a1bd4f |
"notify::" NM_CLIENT_NM_RUNNING,
|
|
Packit Service |
a1bd4f |
G_CALLBACK(nm_running_changed),
|
|
Packit Service |
a1bd4f |
&running_changed);
|
|
Packit Service |
a1bd4f |
quit_id = g_timeout_add_seconds(5, loop_quit, gl.loop);
|
|
Packit Service |
a1bd4f |
g_main_loop_run(gl.loop);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(running_changed, ==, 1);
|
|
Packit Service |
a1bd4f |
g_assert(nm_client_get_nm_running(client1));
|
|
Packit Service |
a1bd4f |
g_source_remove(quit_id);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* And kill it */
|
|
Packit Service |
a1bd4f |
nm_clear_pointer(&sinfo, nmtstc_service_cleanup);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert(nm_client_get_nm_running(client1));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
quit_id = g_timeout_add_seconds(5, loop_quit, gl.loop);
|
|
Packit Service |
a1bd4f |
g_main_loop_run(gl.loop);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(running_changed, ==, 2);
|
|
Packit Service |
a1bd4f |
g_assert(!nm_client_get_nm_running(client1));
|
|
Packit Service |
a1bd4f |
g_source_remove(quit_id);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
GMainLoop * loop;
|
|
Packit Service |
a1bd4f |
NMActiveConnection *ac;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
int remaining;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NMDevice *device;
|
|
Packit Service |
a1bd4f |
gulong ac_signal_id;
|
|
Packit |
5756e2 |
} TestACInfo;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
assert_ac_and_device(NMClient *client)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
const GPtrArray * devices, *acs, *ac_devices;
|
|
Packit Service |
a1bd4f |
NMDevice * device, *ac_device;
|
|
Packit Service |
a1bd4f |
NMActiveConnection *ac, *device_ac;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
acs = nm_client_get_active_connections(client);
|
|
Packit Service |
a1bd4f |
g_assert(acs != NULL);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(acs->len, ==, 1);
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(client);
|
|
Packit Service |
a1bd4f |
g_assert(devices != NULL);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(devices->len, >=, 1);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
ac = acs->pdata[0];
|
|
Packit Service |
a1bd4f |
ac_devices = nm_active_connection_get_devices(ac);
|
|
Packit Service |
a1bd4f |
g_assert(ac_devices != NULL);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(ac_devices->len, ==, 1);
|
|
Packit Service |
a1bd4f |
ac_device = ac_devices->pdata[0];
|
|
Packit Service |
a1bd4f |
g_assert(ac_device != NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device = devices->pdata[0];
|
|
Packit Service |
a1bd4f |
if (device != ac_device && devices->len > 1)
|
|
Packit Service |
a1bd4f |
device = devices->pdata[1];
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_object_get_path(NM_OBJECT(device)),
|
|
Packit Service |
a1bd4f |
==,
|
|
Packit Service |
a1bd4f |
nm_object_get_path(NM_OBJECT(ac_device)));
|
|
Packit Service |
a1bd4f |
g_assert(device == ac_device);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device_ac = nm_device_get_active_connection(device);
|
|
Packit Service |
a1bd4f |
if (!device_ac) {
|
|
Packit Service |
a1bd4f |
/* the stub NetworkManager service starts activating in an idle handler (delayed). That means, the
|
|
Packit Service |
a1bd4f |
* device may not yet refer to the active connection at this point. */
|
|
Packit Service |
a1bd4f |
} else {
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_object_get_path(NM_OBJECT(ac)),
|
|
Packit Service |
a1bd4f |
==,
|
|
Packit Service |
a1bd4f |
nm_object_get_path(NM_OBJECT(device_ac)));
|
|
Packit Service |
a1bd4f |
g_assert(ac == device_ac);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
add_and_activate_cb(GObject *object, GAsyncResult *result, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMClient * client = NM_CLIENT(object);
|
|
Packit Service |
a1bd4f |
TestACInfo *info = user_data;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->ac = nm_client_add_and_activate_connection_finish(client, result, &error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_assert(info->ac != NULL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
assert_ac_and_device(client);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->remaining--;
|
|
Packit Service |
a1bd4f |
if (!info->remaining)
|
|
Packit Service |
a1bd4f |
g_main_loop_quit(info->loop);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
client_acs_changed_cb(GObject *client, GParamSpec *pspec, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
TestACInfo * info = user_data;
|
|
Packit Service |
a1bd4f |
const GPtrArray *acs;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
acs = nm_client_get_active_connections(NM_CLIENT(client));
|
|
Packit Service |
a1bd4f |
g_assert(acs != NULL);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(acs->len, ==, 1);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->remaining--;
|
|
Packit Service |
a1bd4f |
if (!info->remaining)
|
|
Packit Service |
a1bd4f |
g_main_loop_quit(info->loop);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
device_ac_changed_cb(GObject *device, GParamSpec *pspec, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
TestACInfo *info = user_data;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_assert(nm_device_get_active_connection(NM_DEVICE(device)) != NULL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->remaining--;
|
|
Packit Service |
a1bd4f |
if (!info->remaining)
|
|
Packit Service |
a1bd4f |
g_main_loop_quit(info->loop);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_active_connections(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMClient *client = NULL;
|
|
Packit Service |
a1bd4f |
NMDevice * device;
|
|
Packit Service |
a1bd4f |
NMConnection * conn;
|
|
Packit Service |
a1bd4f |
TestACInfo info = {gl.loop, NULL, 0};
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
sinfo = nmtstc_service_init();
|
|
Packit Service |
a1bd4f |
if (!nmtstc_service_available(sinfo))
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
client = nmtstc_client_new(TRUE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Tell the test service to add a new device */
|
|
Packit Service |
a1bd4f |
device = nmtstc_service_add_device(sinfo, client, "AddWiredDevice", "eth0");
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
conn = nmtst_create_minimal_connection("test-ac", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL);
|
|
Packit Service |
a1bd4f |
nm_client_add_and_activate_connection_async(client,
|
|
Packit Service |
a1bd4f |
conn,
|
|
Packit Service |
a1bd4f |
device,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
add_and_activate_cb,
|
|
Packit Service |
a1bd4f |
&info;;
|
|
Packit Service |
a1bd4f |
g_object_unref(conn);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_signal_connect(client,
|
|
Packit Service |
a1bd4f |
"notify::" NM_CLIENT_ACTIVE_CONNECTIONS,
|
|
Packit Service |
a1bd4f |
G_CALLBACK(client_acs_changed_cb),
|
|
Packit Service |
a1bd4f |
&info;;
|
|
Packit Service |
a1bd4f |
g_signal_connect(device,
|
|
Packit Service |
a1bd4f |
"notify::" NM_DEVICE_ACTIVE_CONNECTION,
|
|
Packit Service |
a1bd4f |
G_CALLBACK(device_ac_changed_cb),
|
|
Packit Service |
a1bd4f |
&info;;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Two signals plus activate_cb */
|
|
Packit Service |
a1bd4f |
info.remaining = 3;
|
|
Packit Service |
a1bd4f |
g_main_loop_run(gl.loop);
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(client, client_acs_changed_cb, &info;;
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(device, device_ac_changed_cb, &info;;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert(info.ac != NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_unref(info.ac);
|
|
Packit Service |
a1bd4f |
g_clear_object(&client);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Ensure that we can correctly resolve the recursive property link between the
|
|
Packit Service |
a1bd4f |
* AC and the Device in a newly-created client.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
client = nmtstc_client_new(TRUE);
|
|
Packit Service |
a1bd4f |
assert_ac_and_device(client);
|
|
Packit Service |
a1bd4f |
g_clear_object(&client);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
client = nmtstc_client_new(TRUE);
|
|
Packit Service |
a1bd4f |
assert_ac_and_device(client);
|
|
Packit Service |
a1bd4f |
g_clear_object(&client);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
client_devices_changed_cb(GObject *client, GParamSpec *pspec, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
TestACInfo * info = user_data;
|
|
Packit Service |
a1bd4f |
const GPtrArray *devices;
|
|
Packit Service |
a1bd4f |
NMDevice * device;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
devices = nm_client_get_devices(NM_CLIENT(client));
|
|
Packit Service |
a1bd4f |
g_assert(devices != NULL);
|
|
Packit Service |
a1bd4f |
if (devices->len < 2)
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(devices->len, ==, 2);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (NM_IS_DEVICE_VLAN(devices->pdata[0]))
|
|
Packit Service |
a1bd4f |
device = devices->pdata[0];
|
|
Packit Service |
a1bd4f |
else if (NM_IS_DEVICE_VLAN(devices->pdata[1]))
|
|
Packit Service |
a1bd4f |
device = devices->pdata[1];
|
|
Packit Service |
a1bd4f |
else
|
|
Packit Service |
a1bd4f |
g_assert_not_reached();
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_device_get_iface(device), ==, "eth0.1");
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!nm_device_get_active_connection(device)) {
|
|
Packit Service |
a1bd4f |
g_assert(info->ac_signal_id == 0);
|
|
Packit Service |
a1bd4f |
info->remaining++;
|
|
Packit Service |
a1bd4f |
info->device = device;
|
|
Packit Service |
a1bd4f |
g_object_add_weak_pointer(G_OBJECT(device), (gpointer *) &info->device);
|
|
Packit Service |
a1bd4f |
info->ac_signal_id = g_signal_connect(device,
|
|
Packit Service |
a1bd4f |
"notify::" NM_DEVICE_ACTIVE_CONNECTION,
|
|
Packit Service |
a1bd4f |
G_CALLBACK(device_ac_changed_cb),
|
|
Packit Service |
a1bd4f |
info);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
info->remaining--;
|
|
Packit Service |
a1bd4f |
if (!info->remaining)
|
|
Packit Service |
a1bd4f |
g_main_loop_quit(info->loop);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
GMainLoop * loop;
|
|
Packit Service |
a1bd4f |
NMRemoteConnection *remote;
|
|
Packit |
5756e2 |
} TestConnectionInfo;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
add_connection_cb(GObject *object, GAsyncResult *result, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
TestConnectionInfo *info = user_data;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->remote = nm_client_add_connection_finish(NM_CLIENT(object), result, &error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_main_loop_quit(info->loop);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
activate_cb(GObject *object, GAsyncResult *result, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMClient * client = NM_CLIENT(object);
|
|
Packit Service |
a1bd4f |
TestACInfo *info = user_data;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->ac = nm_client_activate_connection_finish(client, result, &error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
g_assert(info->ac != NULL);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
assert_ac_and_device(client);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
info->remaining--;
|
|
Packit Service |
a1bd4f |
if (!info->remaining)
|
|
Packit Service |
a1bd4f |
g_main_loop_quit(info->loop);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_activate_virtual(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMClient *client = NULL;
|
|
Packit Service |
a1bd4f |
NMConnection * conn;
|
|
Packit Service |
a1bd4f |
NMSettingConnection * s_con;
|
|
Packit Service |
a1bd4f |
NMSettingVlan * s_vlan;
|
|
Packit Service |
a1bd4f |
TestACInfo info = {gl.loop, NULL, 0};
|
|
Packit Service |
a1bd4f |
TestConnectionInfo conn_info = {gl.loop, NULL};
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
sinfo = nmtstc_service_init();
|
|
Packit Service |
a1bd4f |
if (!nmtstc_service_available(sinfo))
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
client = nmtstc_client_new(TRUE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtstc_service_add_device(sinfo, client, "AddWiredDevice", "eth0");
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
conn = nmtst_create_minimal_connection("test-ac", NULL, NM_SETTING_VLAN_SETTING_NAME, &s_con);
|
|
Packit Service |
a1bd4f |
g_object_set(s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, "eth0.1", NULL);
|
|
Packit Service |
a1bd4f |
s_vlan = nm_connection_get_setting_vlan(conn);
|
|
Packit Service |
a1bd4f |
g_object_set(s_vlan, NM_SETTING_VLAN_ID, 1, NM_SETTING_VLAN_PARENT, "eth0", NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_client_add_connection_async(client, conn, TRUE, NULL, add_connection_cb, &conn_info);
|
|
Packit Service |
a1bd4f |
g_main_loop_run(gl.loop);
|
|
Packit Service |
a1bd4f |
g_object_unref(conn);
|
|
Packit Service |
a1bd4f |
conn = NM_CONNECTION(conn_info.remote);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_client_activate_connection_async(client, conn, NULL, NULL, NULL, activate_cb, &info;;
|
|
Packit Service |
a1bd4f |
g_object_unref(conn);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_signal_connect(client,
|
|
Packit Service |
a1bd4f |
"notify::" NM_CLIENT_ACTIVE_CONNECTIONS,
|
|
Packit Service |
a1bd4f |
G_CALLBACK(client_acs_changed_cb),
|
|
Packit Service |
a1bd4f |
&info;;
|
|
Packit Service |
a1bd4f |
g_signal_connect(client,
|
|
Packit Service |
a1bd4f |
"notify::" NM_CLIENT_DEVICES,
|
|
Packit Service |
a1bd4f |
G_CALLBACK(client_devices_changed_cb),
|
|
Packit Service |
a1bd4f |
&info;;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* We're expecting a client::devices change, client::activate callback,
|
|
Packit Service |
a1bd4f |
* and a device::active-connection change.
|
|
Packit Service |
a1bd4f |
* The client::devices callback can hook a client::active-connections
|
|
Packit Service |
a1bd4f |
* change and bump this if the property is not yet loaded.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
info.remaining = 3;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_main_loop_run(gl.loop);
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(client, client_acs_changed_cb, &info;;
|
|
Packit Service |
a1bd4f |
g_signal_handlers_disconnect_by_func(client, client_devices_changed_cb, &info;;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert(info.ac != NULL);
|
|
Packit Service |
a1bd4f |
g_clear_object(&info.ac);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (info.device) {
|
|
Packit Service |
a1bd4f |
g_object_remove_weak_pointer(G_OBJECT(info.device), (gpointer *) &info.device);
|
|
Packit Service |
a1bd4f |
nm_clear_g_signal_handler(info.device, &info.ac_signal_id);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_device_connection_compatibility(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = NULL;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMClient *client = NULL;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMConnection *conn = NULL;
|
|
Packit Service |
a1bd4f |
NMDevice * device1;
|
|
Packit Service |
a1bd4f |
NMDevice * device2;
|
|
Packit Service |
a1bd4f |
NMSettingWired * s_wired;
|
|
Packit Service |
a1bd4f |
GError * error = NULL;
|
|
Packit Service |
a1bd4f |
const char * subchannels[] = {"0.0.8000", "0.0.8001", "0.0.8002", NULL};
|
|
Packit Service |
a1bd4f |
const char * subchannels_2[] = {"0.0.8000", "0.0.8001", NULL};
|
|
Packit Service |
a1bd4f |
const char * subchannels_x[] = {"0.0.8000", "0.0.8001", "0.0.800X", NULL};
|
|
Packit Service |
a1bd4f |
const char * hw_addr1 = "52:54:00:ab:db:23";
|
|
Packit Service |
a1bd4f |
const char * hw_addr2 = "52:54:00:ab:db:24";
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
sinfo = nmtstc_service_init();
|
|
Packit Service |
a1bd4f |
if (!nmtstc_service_available(sinfo))
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
client = nmtstc_client_new(TRUE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* Create two devices */
|
|
Packit Service |
a1bd4f |
device1 = nmtstc_service_add_wired_device(sinfo, client, "eth0", hw_addr1, subchannels);
|
|
Packit Service |
a1bd4f |
device2 = nmtstc_service_add_wired_device(sinfo, client, "eth1", hw_addr2, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_device_get_hw_address(device1), ==, hw_addr1);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_device_get_hw_address(device2), ==, hw_addr2);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
conn =
|
|
Packit Service |
a1bd4f |
nmtst_create_minimal_connection("wired-matches", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL);
|
|
Packit Service |
a1bd4f |
s_wired = nm_connection_get_setting_wired(conn);
|
|
Packit Service |
a1bd4f |
nm_setting_wired_add_mac_blacklist_item(s_wired, "00:11:22:33:44:55");
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* device1 and conn are compatible */
|
|
Packit Service |
a1bd4f |
g_object_set(s_wired,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_MAC_ADDRESS,
|
|
Packit Service |
a1bd4f |
hw_addr1,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_S390_SUBCHANNELS,
|
|
Packit Service |
a1bd4f |
subchannels,
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit Service |
a1bd4f |
nm_device_connection_compatible(device1, conn, &error);
|
|
Packit Service |
a1bd4f |
g_assert_no_error(error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* device2 and conn differ in subchannels */
|
|
Packit Service |
a1bd4f |
g_object_set(s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, subchannels_x, NULL);
|
|
Packit Service |
a1bd4f |
nm_device_connection_compatible(device2, conn, &error);
|
|
Packit Service |
a1bd4f |
g_assert_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION);
|
|
Packit Service |
a1bd4f |
g_clear_error(&error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* device1 and conn differ in subchannels - 2 in connection, 3 in device */
|
|
Packit Service |
a1bd4f |
g_object_set(s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, subchannels_2, NULL);
|
|
Packit Service |
a1bd4f |
nm_device_connection_compatible(device1, conn, &error);
|
|
Packit Service |
a1bd4f |
g_assert_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION);
|
|
Packit Service |
a1bd4f |
g_clear_error(&error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_set(s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, NULL, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* device2 and conn differ in MAC address */
|
|
Packit Service |
a1bd4f |
g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, "aa:bb:cc:dd:ee:ee", NULL);
|
|
Packit Service |
a1bd4f |
nm_device_connection_compatible(device2, conn, &error);
|
|
Packit Service |
a1bd4f |
g_assert_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION);
|
|
Packit Service |
a1bd4f |
g_clear_error(&error);
|
|
Packit Service |
a1bd4f |
g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, NULL, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* device1 is blacklisted in conn */
|
|
Packit Service |
a1bd4f |
nm_setting_wired_add_mac_blacklist_item(s_wired, hw_addr1);
|
|
Packit Service |
a1bd4f |
nm_device_connection_compatible(device1, conn, &error);
|
|
Packit Service |
a1bd4f |
g_assert_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION);
|
|
Packit Service |
a1bd4f |
g_clear_error(&error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
_test_connection_invalid_find_connections(gpointer element, gpointer needle, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMRemoteConnection *con = NM_REMOTE_CONNECTION(element);
|
|
Packit Service |
a1bd4f |
const char * path = needle;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_assert(NM_IS_REMOTE_CONNECTION(con));
|
|
Packit Service |
a1bd4f |
g_assert(path && *path);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return strcmp(path, nm_connection_get_path((NMConnection *) con)) == 0;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define ASSERT_IDX(i) \
|
|
Packit Service |
a1bd4f |
G_STMT_START \
|
|
Packit Service |
a1bd4f |
{ \
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(idx[i], >=, 0); \
|
|
Packit Service |
a1bd4f |
g_assert(path##i &&*path##i); \
|
|
Packit Service |
a1bd4f |
g_assert(NM_IS_REMOTE_CONNECTION(connections->pdata[idx[i]])); \
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr(nm_connection_get_path(connections->pdata[idx[i]]), ==, path##i); \
|
|
Packit Service |
a1bd4f |
} \
|
|
Packit Service |
a1bd4f |
G_STMT_END
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
test_connection_invalid(void)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMTSTC_SERVICE_INFO_SETUP(my_sinfo)
|
|
Packit Service |
a1bd4f |
gs_unref_object NMConnection *connection = NULL;
|
|
Packit Service |
a1bd4f |
NMSettingConnection * s_con;
|
|
Packit Service |
a1bd4f |
gs_unref_object NMClient *client = NULL;
|
|
Packit Service |
a1bd4f |
const GPtrArray * connections;
|
|
Packit Service |
a1bd4f |
gs_free char * path0 = NULL;
|
|
Packit Service |
a1bd4f |
gs_free char * path1 = NULL;
|
|
Packit Service |
a1bd4f |
gs_free char * path2 = NULL;
|
|
Packit Service |
a1bd4f |
gs_free char * path3 = NULL;
|
|
Packit Service |
a1bd4f |
gs_free char * uuid2 = NULL;
|
|
Packit Service |
a1bd4f |
gsize n_found;
|
|
Packit Service |
a1bd4f |
gssize idx[4];
|
|
Packit Service |
a1bd4f |
gs_unref_variant GVariant *variant = NULL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert(g_main_loop_get_context(gl.loop)
|
|
Packit Service |
a1bd4f |
== (g_main_context_get_thread_default() ?: g_main_context_default()));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**************************************************************************
|
|
Packit Service |
a1bd4f |
* Add three connections before starting libnm. One valid, two invalid.
|
|
Packit Service |
a1bd4f |
*************************************************************************/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connection = nmtst_create_minimal_connection("test-connection-invalid-0",
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
&s_con);
|
|
Packit Service |
a1bd4f |
nmtst_connection_normalize(connection);
|
|
Packit Service |
a1bd4f |
g_object_set(s_con, NM_SETTING_CONNECTION_UUID, nmtst_uuid_generate(), NULL);
|
|
Packit Service |
a1bd4f |
nmtstc_service_add_connection(my_sinfo, connection, TRUE, &path0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_connection_remove_setting(connection, NM_TYPE_SETTING_WIRED);
|
|
Packit Service |
a1bd4f |
g_object_set(s_con,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_ID,
|
|
Packit Service |
a1bd4f |
"test-connection-invalid-1",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_TYPE,
|
|
Packit Service |
a1bd4f |
"invalid-type-1",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_UUID,
|
|
Packit Service |
a1bd4f |
nmtst_uuid_generate(),
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit Service |
a1bd4f |
nmtstc_service_add_connection(my_sinfo, connection, FALSE, &path1);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_set(s_con,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_ID,
|
|
Packit Service |
a1bd4f |
"test-connection-invalid-2",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_TYPE,
|
|
Packit Service |
a1bd4f |
"invalid-type-2",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_UUID,
|
|
Packit Service |
a1bd4f |
nmtst_uuid_generate(),
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit Service |
a1bd4f |
variant = nm_connection_to_dbus(connection, NM_CONNECTION_SERIALIZE_ALL);
|
|
Packit Service |
a1bd4f |
NMTST_VARIANT_EDITOR(
|
|
Packit Service |
a1bd4f |
variant,
|
|
Packit Service |
a1bd4f |
NMTST_VARIANT_ADD_SETTING("invalid-type-2",
|
|
Packit Service |
a1bd4f |
nmtst_variant_new_vardict("some-key1",
|
|
Packit Service |
a1bd4f |
g_variant_new_string("some-value1"),
|
|
Packit Service |
a1bd4f |
"some-key2",
|
|
Packit Service |
a1bd4f |
g_variant_new_uint32(4722))));
|
|
Packit Service |
a1bd4f |
g_variant_ref_sink(variant);
|
|
Packit Service |
a1bd4f |
nmtstc_service_add_connection_variant(my_sinfo, variant, FALSE, &path2);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
client = nmtstc_client_new(TRUE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connections = nm_client_get_connections(client);
|
|
Packit Service |
a1bd4f |
g_assert(connections);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(connections->len, ==, 3);
|
|
Packit Service |
a1bd4f |
n_found = nmtst_find_all_indexes(connections->pdata,
|
|
Packit Service |
a1bd4f |
connections->len,
|
|
Packit Service |
a1bd4f |
(gpointer *) ((const char *[]){path0, path1, path2}),
|
|
Packit Service |
a1bd4f |
3,
|
|
Packit Service |
a1bd4f |
_test_connection_invalid_find_connections,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
idx);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(n_found, ==, 3);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(0);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(1);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(2);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_without_normalization(connections->pdata[idx[0]]);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[1]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[2]], 0, 0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**************************************************************************
|
|
Packit Service |
a1bd4f |
* After having the client up and running, add another invalid connection
|
|
Packit Service |
a1bd4f |
*************************************************************************/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_set(s_con,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_ID,
|
|
Packit Service |
a1bd4f |
"test-connection-invalid-2",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_TYPE,
|
|
Packit Service |
a1bd4f |
"invalid-type-2",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_UUID,
|
|
Packit Service |
a1bd4f |
(uuid2 = g_strdup(nmtst_uuid_generate())),
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit Service |
a1bd4f |
nmtstc_service_add_connection(my_sinfo, connection, FALSE, &path3);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtst_main_loop_run(gl.loop, 1000);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connections = nm_client_get_connections(client);
|
|
Packit Service |
a1bd4f |
g_assert(connections);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(connections->len, ==, 4);
|
|
Packit Service |
a1bd4f |
n_found = nmtst_find_all_indexes(connections->pdata,
|
|
Packit Service |
a1bd4f |
connections->len,
|
|
Packit Service |
a1bd4f |
(gpointer *) ((const char *[]){path0, path1, path2, path3}),
|
|
Packit Service |
a1bd4f |
4,
|
|
Packit Service |
a1bd4f |
_test_connection_invalid_find_connections,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
idx);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(n_found, ==, 4);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(0);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(1);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(2);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(3);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_without_normalization(connections->pdata[idx[0]]);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[1]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[2]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[3]], 0, 0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**************************************************************************
|
|
Packit Service |
a1bd4f |
* Modify the invalid connection (still invalid)
|
|
Packit Service |
a1bd4f |
*************************************************************************/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
NMTST_VARIANT_EDITOR(variant,
|
|
Packit Service |
a1bd4f |
NMTST_VARIANT_CHANGE_PROPERTY("invalid-type-2", "some-key2", "u", 4721));
|
|
Packit Service |
a1bd4f |
g_variant_ref_sink(variant);
|
|
Packit Service |
a1bd4f |
nmtstc_service_update_connection_variant(my_sinfo, path2, variant, FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtst_main_loop_run(gl.loop, 100);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connections = nm_client_get_connections(client);
|
|
Packit Service |
a1bd4f |
g_assert(connections);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(connections->len, ==, 4);
|
|
Packit Service |
a1bd4f |
n_found = nmtst_find_all_indexes(connections->pdata,
|
|
Packit Service |
a1bd4f |
connections->len,
|
|
Packit Service |
a1bd4f |
(gpointer *) ((const char *[]){path0, path1, path2, path3}),
|
|
Packit Service |
a1bd4f |
4,
|
|
Packit Service |
a1bd4f |
_test_connection_invalid_find_connections,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
idx);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(n_found, ==, 4);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(0);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(1);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(2);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(3);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_without_normalization(connections->pdata[idx[0]]);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[1]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[2]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[3]], 0, 0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**************************************************************************
|
|
Packit Service |
a1bd4f |
* Modify the invalid connection (becomes valid)
|
|
Packit Service |
a1bd4f |
*************************************************************************/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
NMTST_VARIANT_EDITOR(variant, NMTST_VARIANT_DROP_SETTING("invalid-type-2"));
|
|
Packit Service |
a1bd4f |
NMTST_VARIANT_EDITOR(variant,
|
|
Packit Service |
a1bd4f |
NMTST_VARIANT_CHANGE_PROPERTY(NM_SETTING_CONNECTION_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_TYPE,
|
|
Packit Service |
a1bd4f |
"s",
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_SETTING_NAME));
|
|
Packit Service |
a1bd4f |
g_variant_ref_sink(variant);
|
|
Packit Service |
a1bd4f |
nmtstc_service_update_connection_variant(my_sinfo, path2, variant, FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtst_main_loop_run(gl.loop, 100);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connections = nm_client_get_connections(client);
|
|
Packit Service |
a1bd4f |
g_assert(connections);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(connections->len, ==, 4);
|
|
Packit Service |
a1bd4f |
n_found = nmtst_find_all_indexes(connections->pdata,
|
|
Packit Service |
a1bd4f |
connections->len,
|
|
Packit Service |
a1bd4f |
(gpointer *) ((const char *[]){path0, path1, path2, path3}),
|
|
Packit Service |
a1bd4f |
4,
|
|
Packit Service |
a1bd4f |
_test_connection_invalid_find_connections,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
idx);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(n_found, ==, 4);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(0);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(1);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(2);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(3);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_without_normalization(connections->pdata[idx[0]]);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[1]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_after_normalization(connections->pdata[idx[2]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[3]], 0, 0);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**************************************************************************
|
|
Packit Service |
a1bd4f |
* Modify the invalid connection (still invalid)
|
|
Packit Service |
a1bd4f |
*************************************************************************/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_object_set(s_con, NM_SETTING_CONNECTION_ID, "test-connection-invalid-2x", NULL);
|
|
Packit Service |
a1bd4f |
nmtstc_service_update_connection(my_sinfo, path3, connection, FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtst_main_loop_run(gl.loop, 100);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connections = nm_client_get_connections(client);
|
|
Packit Service |
a1bd4f |
g_assert(connections);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(connections->len, ==, 4);
|
|
Packit Service |
a1bd4f |
n_found = nmtst_find_all_indexes(connections->pdata,
|
|
Packit Service |
a1bd4f |
connections->len,
|
|
Packit Service |
a1bd4f |
(gpointer *) ((const char *[]){path0, path1, path2, path3}),
|
|
Packit Service |
a1bd4f |
4,
|
|
Packit Service |
a1bd4f |
_test_connection_invalid_find_connections,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
idx);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(n_found, ==, 4);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(0);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(1);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(2);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(3);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_without_normalization(connections->pdata[idx[0]]);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[1]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_after_normalization(connections->pdata[idx[2]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[3]], 0, 0);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr("test-connection-invalid-2x",
|
|
Packit Service |
a1bd4f |
==,
|
|
Packit Service |
a1bd4f |
nm_connection_get_id(connections->pdata[idx[3]]));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**************************************************************************
|
|
Packit Service |
a1bd4f |
* Modify the invalid connection (now becomes valid)
|
|
Packit Service |
a1bd4f |
*************************************************************************/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_clear_object(&connection);
|
|
Packit Service |
a1bd4f |
connection = nmtst_create_minimal_connection("test-connection-invalid-2",
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
&s_con);
|
|
Packit Service |
a1bd4f |
nmtst_connection_normalize(connection);
|
|
Packit Service |
a1bd4f |
g_object_set(s_con,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_ID,
|
|
Packit Service |
a1bd4f |
"test-connection-invalid-2z",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_TYPE,
|
|
Packit Service |
a1bd4f |
"802-3-ethernet",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_UUID,
|
|
Packit Service |
a1bd4f |
uuid2,
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtstc_service_update_connection(my_sinfo, path3, connection, FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtst_main_loop_run(gl.loop, 100);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connections = nm_client_get_connections(client);
|
|
Packit Service |
a1bd4f |
g_assert(connections);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(connections->len, ==, 4);
|
|
Packit Service |
a1bd4f |
n_found = nmtst_find_all_indexes(connections->pdata,
|
|
Packit Service |
a1bd4f |
connections->len,
|
|
Packit Service |
a1bd4f |
(gpointer *) ((const char *[]){path0, path1, path2, path3}),
|
|
Packit Service |
a1bd4f |
4,
|
|
Packit Service |
a1bd4f |
_test_connection_invalid_find_connections,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
idx);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(n_found, ==, 4);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(0);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(1);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(2);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(3);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_without_normalization(connections->pdata[idx[0]]);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_unnormalizable(connections->pdata[idx[1]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_after_normalization(connections->pdata[idx[2]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_without_normalization(connections->pdata[idx[3]]);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr("test-connection-invalid-2z",
|
|
Packit Service |
a1bd4f |
==,
|
|
Packit Service |
a1bd4f |
nm_connection_get_id(connections->pdata[idx[3]]));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/**************************************************************************
|
|
Packit Service |
a1bd4f |
* Modify the invalid connection and make it valid
|
|
Packit Service |
a1bd4f |
*************************************************************************/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_clear_object(&connection);
|
|
Packit Service |
a1bd4f |
connection = nmtst_create_minimal_connection("test-connection-invalid-1",
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_SETTING_NAME,
|
|
Packit Service |
a1bd4f |
&s_con);
|
|
Packit Service |
a1bd4f |
nmtst_connection_normalize(connection);
|
|
Packit Service |
a1bd4f |
g_object_set(s_con,
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_ID,
|
|
Packit Service |
a1bd4f |
"test-connection-invalid-1x",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_TYPE,
|
|
Packit Service |
a1bd4f |
"802-3-ethernet",
|
|
Packit Service |
a1bd4f |
NM_SETTING_CONNECTION_UUID,
|
|
Packit Service |
a1bd4f |
nm_connection_get_uuid(connections->pdata[idx[1]]),
|
|
Packit Service |
a1bd4f |
NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtstc_service_update_connection(my_sinfo, path1, connection, FALSE);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmtst_main_loop_run(gl.loop, 100);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
connections = nm_client_get_connections(client);
|
|
Packit Service |
a1bd4f |
g_assert(connections);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(connections->len, ==, 4);
|
|
Packit Service |
a1bd4f |
n_found = nmtst_find_all_indexes(connections->pdata,
|
|
Packit Service |
a1bd4f |
connections->len,
|
|
Packit Service |
a1bd4f |
(gpointer *) ((const char *[]){path0, path1, path2, path3}),
|
|
Packit Service |
a1bd4f |
4,
|
|
Packit Service |
a1bd4f |
_test_connection_invalid_find_connections,
|
|
Packit Service |
a1bd4f |
NULL,
|
|
Packit Service |
a1bd4f |
idx);
|
|
Packit Service |
a1bd4f |
g_assert_cmpint(n_found, ==, 4);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(0);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(1);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(2);
|
|
Packit Service |
a1bd4f |
ASSERT_IDX(3);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_without_normalization(connections->pdata[idx[0]]);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_without_normalization(connections->pdata[idx[1]]);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_after_normalization(connections->pdata[idx[2]], 0, 0);
|
|
Packit Service |
a1bd4f |
nmtst_assert_connection_verifies_without_normalization(connections->pdata[idx[3]]);
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr("test-connection-invalid-1x",
|
|
Packit Service |
a1bd4f |
==,
|
|
Packit Service |
a1bd4f |
nm_connection_get_id(connections->pdata[idx[1]]));
|
|
Packit Service |
a1bd4f |
g_assert_cmpstr("test-connection-invalid-2z",
|
|
Packit Service |
a1bd4f |
==,
|
|
Packit Service |
a1bd4f |
nm_connection_get_id(connections->pdata[idx[3]]));
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#undef ASSERT_IDX
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NMTST_DEFINE();
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
int
|
|
Packit Service |
a1bd4f |
main(int argc, char **argv)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
g_setenv("LIBNM_USE_SESSION_BUS", "1", TRUE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
nmtst_init(&argc, &argv, TRUE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
gl.loop = g_main_loop_new(NULL, FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/device-added", test_device_added);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/device-added-signal-after-init", test_device_added_signal_after_init);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/wifi-ap-added-removed", test_wifi_ap_added_removed);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/devices-array", test_devices_array);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/client-nm-running", test_client_nm_running);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/active-connections", test_active_connections);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/activate-virtual", test_activate_virtual);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/device-connection-compatibility", test_device_connection_compatibility);
|
|
Packit Service |
a1bd4f |
g_test_add_func("/libnm/connection/invalid", test_connection_invalid);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return g_test_run();
|
|
Packit |
5756e2 |
}
|