diff options
author | Thomas Haller <thaller@redhat.com> | 2017-05-26 20:05:08 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-05-26 20:20:37 +0200 |
commit | b60b885395cf1f1ac1776f7361b2d8d7fcaa26a3 (patch) | |
tree | 34cd727f6ee7812a1967e843ea85471bdf47298c /src/platform/tests/test-common.c | |
parent | 87da20d6847aae262ad1784fe9f79295f62193e9 (diff) | |
download | NetworkManager-th/platform-tests.tar.gz |
platform/tests: use nm_platform_link_veth_add() to create veth pair in testth/platform-tests
Diffstat (limited to 'src/platform/tests/test-common.c')
-rw-r--r-- | src/platform/tests/test-common.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index 661a4360ec..bf4786bdb3 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -977,6 +977,36 @@ nmtstp_ip6_address_del (NMPlatform *platform, } 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 * nmtstp_link_dummy_add (NMPlatform *platform, gboolean external_command, const char *name) |