platform/tests: use nm_platform_link_veth_add() to create veth pair in test
This commit is contained in:
@@ -40,9 +40,8 @@ static void
|
|||||||
fixture_setup (test_fixture *fixture, gconstpointer user_data)
|
fixture_setup (test_fixture *fixture, gconstpointer user_data)
|
||||||
{
|
{
|
||||||
/* create veth pair. */
|
/* create veth pair. */
|
||||||
nmtstp_run_command_check ("ip link add dev %s type veth peer name %s", IFACE_VETH0, IFACE_VETH1);
|
fixture->ifindex0 = nmtstp_link_veth_add (NM_PLATFORM_GET, -1, IFACE_VETH0, IFACE_VETH1)->ifindex;
|
||||||
fixture->ifindex0 = nmtstp_assert_wait_for_link (NM_PLATFORM_GET, IFACE_VETH0, NM_LINK_TYPE_VETH, 100)->ifindex;
|
fixture->ifindex1 = nmtstp_link_get_typed (NM_PLATFORM_GET, -1, IFACE_VETH1, NM_LINK_TYPE_VETH)->ifindex;
|
||||||
fixture->ifindex1 = nmtstp_assert_wait_for_link (NM_PLATFORM_GET, IFACE_VETH1, NM_LINK_TYPE_VETH, 100)->ifindex;
|
|
||||||
|
|
||||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, fixture->ifindex0, NULL));
|
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, fixture->ifindex0, NULL));
|
||||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, fixture->ifindex1, NULL));
|
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, fixture->ifindex1, NULL));
|
||||||
|
@@ -976,6 +976,36 @@ nmtstp_ip6_address_del (NMPlatform *platform,
|
|||||||
} \
|
} \
|
||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
|
|
||||||
|
const NMPlatformLink *
|
||||||
|
nmtstp_link_veth_add (NMPlatform *platform,
|
||||||
|
gboolean external_command,
|
||||||
|
const char *name,
|
||||||
|
const char *peer)
|
||||||
|
{
|
||||||
|
const NMPlatformLink *pllink = NULL;
|
||||||
|
gboolean success;
|
||||||
|
|
||||||
|
g_assert (nm_utils_is_valid_iface_name (name, NULL));
|
||||||
|
|
||||||
|
external_command = nmtstp_run_command_check_external (external_command);
|
||||||
|
|
||||||
|
_init_platform (&platform, external_command);
|
||||||
|
|
||||||
|
if (external_command) {
|
||||||
|
success = !nmtstp_run_command ("ip link add dev %s type veth peer name %s",
|
||||||
|
name, peer);
|
||||||
|
if (success) {
|
||||||
|
pllink = nmtstp_assert_wait_for_link (platform, name, NM_LINK_TYPE_VETH, 100);
|
||||||
|
nmtstp_assert_wait_for_link (platform, peer, NM_LINK_TYPE_VETH, 10);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
success = nm_platform_link_veth_add (platform, name, peer, &pllink) == NM_PLATFORM_ERROR_SUCCESS;
|
||||||
|
|
||||||
|
g_assert (success);
|
||||||
|
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_VETH);
|
||||||
|
return pllink;
|
||||||
|
}
|
||||||
|
|
||||||
const NMPlatformLink *
|
const NMPlatformLink *
|
||||||
nmtstp_link_dummy_add (NMPlatform *platform,
|
nmtstp_link_dummy_add (NMPlatform *platform,
|
||||||
gboolean external_command,
|
gboolean external_command,
|
||||||
|
@@ -197,6 +197,10 @@ void nmtstp_link_set_updown (NMPlatform *platform,
|
|||||||
int ifindex,
|
int ifindex,
|
||||||
gboolean up);
|
gboolean up);
|
||||||
|
|
||||||
|
const NMPlatformLink *nmtstp_link_veth_add (NMPlatform *platform,
|
||||||
|
gboolean external_command,
|
||||||
|
const char *name,
|
||||||
|
const char *peer);
|
||||||
const NMPlatformLink *nmtstp_link_dummy_add (NMPlatform *platform,
|
const NMPlatformLink *nmtstp_link_dummy_add (NMPlatform *platform,
|
||||||
gboolean external_command,
|
gboolean external_command,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
@@ -1713,9 +1713,8 @@ test_nl_bugs_veth (void)
|
|||||||
NMTstpNamespaceHandle *ns_handle = NULL;
|
NMTstpNamespaceHandle *ns_handle = NULL;
|
||||||
|
|
||||||
/* create veth pair. */
|
/* create veth pair. */
|
||||||
nmtstp_run_command_check ("ip link add dev %s type veth peer name %s", IFACE_VETH0, IFACE_VETH1);
|
ifindex_veth0 = nmtstp_link_veth_add (NM_PLATFORM_GET, -1, IFACE_VETH0, IFACE_VETH1)->ifindex;
|
||||||
ifindex_veth0 = nmtstp_assert_wait_for_link (NM_PLATFORM_GET, IFACE_VETH0, NM_LINK_TYPE_VETH, 100)->ifindex;
|
ifindex_veth1 = nmtstp_link_get_typed (NM_PLATFORM_GET, -1, IFACE_VETH1, NM_LINK_TYPE_VETH)->ifindex;
|
||||||
ifindex_veth1 = nmtstp_assert_wait_for_link (NM_PLATFORM_GET, IFACE_VETH1, NM_LINK_TYPE_VETH, 100)->ifindex;
|
|
||||||
|
|
||||||
/* assert that nm_platform_link_veth_get_properties() returns the expected peer ifindexes. */
|
/* assert that nm_platform_link_veth_get_properties() returns the expected peer ifindexes. */
|
||||||
g_assert (nm_platform_link_veth_get_properties (NM_PLATFORM_GET, ifindex_veth0, &i));
|
g_assert (nm_platform_link_veth_get_properties (NM_PLATFORM_GET, ifindex_veth0, &i));
|
||||||
|
Reference in New Issue
Block a user