platform/test: add test for invoking platform signals

There seems to be an issue with glib/ffi that causes failures
to pass enum-typed arguments to signals (related bug rh#1260577).

Add a test for platform signals which, beside NM_CONFIG_SIGNAL_CONFIG_CHANGED,
is the only place where we use enum-typed arguments for signals.

Strangely, this test doesn't cause the failure, so it's unclear why
the workaround was necessary for "config-changed" signal (commit
e7d66f1df6).
This commit is contained in:
Thomas Haller 2015-09-09 12:22:16 +02:00
parent e7d66f1df6
commit 52cd5ee612

View file

@ -117,6 +117,41 @@ software_add (NMLinkType link_type, const char *name)
g_assert_not_reached ();
}
static void
test_link_changed_signal_cb (NMPlatform *platform,
NMPObjectType obj_type,
int ifindex,
const NMPlatformIP4Route *route,
NMPlatformSignalChangeType change_type,
NMPlatformReason reason,
gboolean *p_test_link_changed_signal_arg)
{
/* test invocation of platform signals with multiple listeners
* connected to the signal. Platform signals have enum-typed
* arguments and there seem to be an issue with invoking such
* signals on s390x and ppc64 archs.
* https://bugzilla.redhat.com/show_bug.cgi?id=1260577
*
* As the test shows, the failure is not reproducible for
* platform signals.
*/
g_assert (NM_IS_PLATFORM (platform));
g_assert (platform == NM_PLATFORM_GET);
g_assert (ifindex > 0);
g_assert (route);
g_assert_cmpint (obj_type, ==, NMP_OBJECT_TYPE_LINK);
g_assert_cmpint ((gint64) change_type, !=, (gint64) 0);
g_assert_cmpint (change_type, !=, NM_PLATFORM_SIGNAL_NONE);
g_assert_cmpint ((gint64) reason, !=, (gint64) 0);
g_assert_cmpint (reason, !=, NM_PLATFORM_REASON_NONE);
*p_test_link_changed_signal_arg = TRUE;
}
static void
test_slave (int master, int type, SignalData *master_changed)
{
@ -125,6 +160,8 @@ test_slave (int master, int type, SignalData *master_changed)
SignalData *link_changed, *link_removed;
char *value;
NMLinkType link_type = nm_platform_link_get_type (NM_PLATFORM_GET, master);
gboolean test_link_changed_signal_arg1;
gboolean test_link_changed_signal_arg2;
g_assert (NM_IN_SET (link_type, NM_LINK_TYPE_TEAM, NM_LINK_TYPE_BOND, NM_LINK_TYPE_BRIDGE));
@ -158,11 +195,21 @@ test_slave (int master, int type, SignalData *master_changed)
else
g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex));
test_link_changed_signal_arg1 = FALSE;
test_link_changed_signal_arg2 = FALSE;
g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_LINK_CHANGED, G_CALLBACK (test_link_changed_signal_cb), &test_link_changed_signal_arg1);
g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_LINK_CHANGED, G_CALLBACK (test_link_changed_signal_cb), &test_link_changed_signal_arg2);
/* Set master up */
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, master, NULL));
g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, master));
accept_signals (master_changed, 1, 2);
g_signal_handlers_disconnect_by_func (NM_PLATFORM_GET, G_CALLBACK (test_link_changed_signal_cb), &test_link_changed_signal_arg1);
g_signal_handlers_disconnect_by_func (NM_PLATFORM_GET, G_CALLBACK (test_link_changed_signal_cb), &test_link_changed_signal_arg2);
g_assert (test_link_changed_signal_arg1);
g_assert (test_link_changed_signal_arg2);
/* Master with a disconnected slave is disconnected
*
* For some reason, bonding and teaming slaves are automatically set up. We