mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 10:20:14 +01:00
libnm: merge branch 'th/libnm-dangling-property'
https://bugzilla.redhat.com/show_bug.cgi?id=2039331 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/896 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1064
This commit is contained in:
commit
aafd6cb524
5 changed files with 103 additions and 0 deletions
|
|
@ -1799,6 +1799,7 @@ nml_dbus_property_o_notify(NMClient *self,
|
|||
|
||||
if (pr_o->obj_watcher
|
||||
&& (!dbus_path || !nm_streq(dbus_path, pr_o->obj_watcher->dbobj->dbus_path->str))) {
|
||||
pr_o->nmobj = NULL;
|
||||
_dbobjs_obj_watcher_unregister(self, g_steal_pointer(&pr_o->obj_watcher));
|
||||
changed = TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -788,6 +788,32 @@ activate_cb(GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
g_main_loop_quit(info->loop);
|
||||
}
|
||||
|
||||
static void
|
||||
_dev_eth0_1_state_changed_cb(NMDevice *device,
|
||||
NMDeviceState new_state,
|
||||
NMDeviceState old_state,
|
||||
NMDeviceStateReason reason,
|
||||
int *p_count_call)
|
||||
{
|
||||
const GPtrArray *arr;
|
||||
|
||||
g_assert(p_count_call);
|
||||
g_assert_cmpint(*p_count_call, ==, 0);
|
||||
|
||||
(*p_count_call)++;
|
||||
|
||||
g_assert(NM_IS_DEVICE_VLAN(device));
|
||||
|
||||
g_assert_cmpint(old_state, ==, NM_DEVICE_STATE_PREPARE);
|
||||
g_assert_cmpint(new_state, ==, NM_DEVICE_STATE_UNKNOWN);
|
||||
|
||||
arr = nm_device_get_available_connections(device);
|
||||
g_assert(arr);
|
||||
g_assert_cmpint(arr->len, ==, 0);
|
||||
|
||||
g_assert(!nm_device_get_active_connection(device));
|
||||
}
|
||||
|
||||
static void
|
||||
test_activate_virtual(void)
|
||||
{
|
||||
|
|
@ -799,6 +825,9 @@ test_activate_virtual(void)
|
|||
TestACInfo info = {gl.loop, NULL, 0};
|
||||
TestConnectionInfo conn_info = {gl.loop, NULL};
|
||||
|
||||
if (nmtst_test_skip_slow())
|
||||
return;
|
||||
|
||||
sinfo = nmtstc_service_init();
|
||||
if (!nmtstc_service_available(sinfo))
|
||||
return;
|
||||
|
|
@ -847,6 +876,57 @@ test_activate_virtual(void)
|
|||
g_object_remove_weak_pointer(G_OBJECT(info.device), (gpointer *) &info.device);
|
||||
nm_clear_g_signal_handler(info.device, &info.ac_signal_id);
|
||||
}
|
||||
|
||||
if (nmtst_get_rand_bool()) {
|
||||
/* OK, enough for this run. Let's see whether we can tear down
|
||||
* successfully at this point. */
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
NMDevice *dev_eth0_1;
|
||||
NMActiveConnection *ac;
|
||||
const GPtrArray *arr;
|
||||
gulong sig_id;
|
||||
int call_count = 0;
|
||||
gboolean take_ref = nmtst_get_rand_bool();
|
||||
|
||||
/* ensure we got all the necessary events in place. */
|
||||
nmtst_main_loop_run(gl.loop, 50);
|
||||
|
||||
dev_eth0_1 = nm_client_get_device_by_iface(client, "eth0.1");
|
||||
g_assert(NM_IS_DEVICE_VLAN(dev_eth0_1));
|
||||
if (take_ref)
|
||||
g_object_ref(dev_eth0_1);
|
||||
|
||||
arr = nm_device_get_available_connections(dev_eth0_1);
|
||||
g_assert(arr);
|
||||
g_assert_cmpint(arr->len, ==, 1);
|
||||
|
||||
ac = nm_device_get_active_connection(dev_eth0_1);
|
||||
g_assert(NM_IS_ACTIVE_CONNECTION(ac));
|
||||
|
||||
sig_id = g_signal_connect(dev_eth0_1,
|
||||
"state-changed",
|
||||
G_CALLBACK(_dev_eth0_1_state_changed_cb),
|
||||
&call_count);
|
||||
|
||||
g_clear_object(&client);
|
||||
|
||||
g_assert_cmpint(call_count, ==, 1);
|
||||
|
||||
if (take_ref) {
|
||||
arr = nm_device_get_available_connections(dev_eth0_1);
|
||||
g_assert(arr);
|
||||
g_assert_cmpint(arr->len, ==, 0);
|
||||
|
||||
g_assert(!nm_device_get_active_connection(dev_eth0_1));
|
||||
|
||||
nm_clear_g_signal_handler(dev_eth0_1, &sig_id);
|
||||
|
||||
g_object_unref(dev_eth0_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -709,6 +709,17 @@ nmtst_test_quick(void)
|
|||
return __nmtst_internal.test_quick;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nmtst_test_skip_slow(void)
|
||||
{
|
||||
if (!nmtst_test_quick())
|
||||
return FALSE;
|
||||
|
||||
g_print("Skipping test: don't run long running test %s (NMTST_DEBUG=slow)\n", g_get_prgname());
|
||||
g_test_skip("Skip long running test");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if GLIB_CHECK_VERSION(2, 34, 0)
|
||||
#undef g_test_expect_message
|
||||
#define g_test_expect_message(...) \
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ usage() {
|
|||
echo " --no-libtool: when running with valgrind, the script tries automatically to"
|
||||
echo " use libtool as necessary. This disables libtool usage"
|
||||
echo " --make-first|-m: before running the test, make it (only works with autotools build)"
|
||||
echo " --no-make-first|-M: disable --make-first option"
|
||||
echo " --valgrind|-v: run under valgrind"
|
||||
echo " --no-valgrind|-V: disable running under valgrind (overrides NMTST_USE_VALGRIND=1)"
|
||||
echo " -d: set NMTST_DEBUG=d"
|
||||
|
|
@ -165,6 +166,10 @@ else
|
|||
NMTST_MAKE_FIRST=1
|
||||
shift
|
||||
;;
|
||||
--no-make-first|-M)
|
||||
NMTST_MAKE_FIRST=0
|
||||
shift
|
||||
;;
|
||||
"--valgrind"|-v)
|
||||
NMTST_USE_VALGRIND=1
|
||||
shift;
|
||||
|
|
|
|||
|
|
@ -1077,6 +1077,9 @@ class Device(ExportedObj):
|
|||
elif isinstance(self, WifiDevice):
|
||||
if con_inst.get_type() == NM.SETTING_WIRELESS_SETTING_NAME:
|
||||
return True
|
||||
elif isinstance(self, VlanDevice):
|
||||
if con_inst.get_type() == NM.SETTING_VLAN_SETTING_NAME:
|
||||
return True
|
||||
return False
|
||||
|
||||
def available_connections_get(self):
|
||||
|
|
@ -1630,6 +1633,9 @@ class NetworkManager(ExportedObj):
|
|||
|
||||
ac = ActiveConnection(device, con_inst, None)
|
||||
self.active_connection_add(ac)
|
||||
|
||||
gl.manager.devices_available_connections_update()
|
||||
|
||||
return ExportedObj.to_path(ac)
|
||||
|
||||
def active_connection_add(self, ac):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue