platform: fix root-tests after adding link detection without udev

Co-Authored-By: Lubomir Rintel <lkundrak@v3.sk>

Fixes: 388b7830f3
Fixes: 285ee1fda2
(cherry picked from commit b22bf15c1d)
This commit is contained in:
Thomas Haller 2015-05-04 17:18:39 +02:00
parent 285ee1fda2
commit 7c4a657efa
5 changed files with 13 additions and 36 deletions

View file

@ -49,11 +49,6 @@ typedef struct {
int vlan_id;
} NMFakePlatformLink;
typedef struct {
int ifindex;
NMPlatform *platform;
} NMFakePlatformLinkData;
#define NM_FAKE_PLATFORM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_FAKE_PLATFORM, NMFakePlatformPrivate))
G_DEFINE_TYPE (NMFakePlatform, nm_fake_platform, NM_TYPE_PLATFORM)
@ -172,23 +167,6 @@ _nm_platform_link_get (NMPlatform *platform, int ifindex, NMPlatformLink *l)
return !!device;
}
static gboolean
_link_announce (NMFakePlatformLinkData *data)
{
NMFakePlatformLink *device = link_get (data->platform, data->ifindex);
if (device)
g_signal_emit_by_name (data->platform,
NM_PLATFORM_SIGNAL_LINK_CHANGED,
device->link.ifindex,
device,
NM_PLATFORM_SIGNAL_ADDED,
NM_PLATFORM_REASON_INTERNAL);
g_free (data);
return FALSE;
}
static gboolean
link_add (NMPlatform *platform, const char *name, NMLinkType type, const void *address, size_t address_len)
{
@ -199,12 +177,8 @@ link_add (NMPlatform *platform, const char *name, NMLinkType type, const void *a
g_array_append_val (priv->links, device);
if (device.link.ifindex) {
NMFakePlatformLinkData *data = g_new (NMFakePlatformLinkData, 1);
data->ifindex = device.link.ifindex;
data->platform = platform;
g_idle_add ((GSourceFunc) _link_announce, data);
}
if (device.link.ifindex)
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, device.link.ifindex, &device, NM_PLATFORM_SIGNAL_ADDED, NM_PLATFORM_REASON_INTERNAL);
return TRUE;
}

View file

@ -256,7 +256,7 @@ setup_tests (void)
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
wait_signal (link_added);
accept_signal (link_added);
free_signal (link_added);
g_test_add_func ("/address/internal/ip4", test_ip4_address);

View file

@ -36,7 +36,7 @@ test_cleanup_internal (void)
/* Create and set up device */
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
wait_signal (link_added);
accept_signal (link_added);
free_signal (link_added);
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);

View file

@ -115,7 +115,7 @@ software_add (NMLinkType link_type, const char *name)
/* Don't call link_callback for the bridge interface */
parent_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, PARENT_NAME);
if (nm_platform_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0))
wait_signal (parent_added);
accept_signal (parent_added);
free_signal (parent_added);
{
@ -148,7 +148,7 @@ test_slave (int master, int type, SignalData *master_changed)
g_assert (ifindex > 0);
link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex);
link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex);
wait_signal (link_added);
accept_signal (link_added);
/* Set the slave up to see whether master's IFF_LOWER_UP is set correctly.
*
@ -263,7 +263,7 @@ test_software (NMLinkType link_type, const char *link_typename)
link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME);
g_assert (software_add (link_type, DEVICE_NAME));
no_error ();
wait_signal (link_added);
accept_signal (link_added);
g_assert (nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
g_assert (ifindex >= 0);
@ -405,7 +405,7 @@ test_internal (void)
/* Add device */
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
no_error ();
wait_signal (link_added);
accept_signal (link_added);
/* Try to add again */
g_assert (!nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
@ -485,6 +485,7 @@ test_external (void)
run_command ("ip link add %s type %s", DEVICE_NAME, "dummy");
wait_signal (link_added);
g_assert (nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
g_assert (ifindex > 0);
@ -496,7 +497,7 @@ test_external (void)
success = nm_platform_link_get (NM_PLATFORM_GET, ifindex, &link);
g_assert (success);
if (!link.driver) {
if (!link.initialized) {
/* we still lack the notification via UDEV. Expect another link changed signal. */
wait_signal (link_changed);
}
@ -505,8 +506,10 @@ test_external (void)
g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex));
run_command ("ip link set %s up", DEVICE_NAME);
wait_signal (link_changed);
g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex));
run_command ("ip link set %s down", DEVICE_NAME);

View file

@ -321,7 +321,7 @@ setup_tests (void)
nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME));
g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME));
wait_signal (link_added);
accept_signal (link_added);
free_signal (link_added);
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)));