summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-12-10 16:49:41 +0100
committerThomas Haller <thaller@redhat.com>2015-12-10 17:13:49 +0100
commit7a758ae7a3ee0389bd89b49e27b1ebf7d0a9e582 (patch)
tree7a69bc136d82e809dbec6368c583b82e51f9a776
parent06eaf291098a7bdb52e1e043053eb61ee61bfae7 (diff)
downloadNetworkManager-7a758ae7a3ee0389bd89b49e27b1ebf7d0a9e582.tar.gz
platform/tests: add nmtstp_link_get() helper
-rw-r--r--src/platform/tests/test-common.c31
-rw-r--r--src/platform/tests/test-common.h2
2 files changed, 33 insertions, 0 deletions
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c
index 0bbe1588a3..43363b84a4 100644
--- a/src/platform/tests/test-common.c
+++ b/src/platform/tests/test-common.c
@@ -1066,6 +1066,37 @@ nmtstp_ip6_address_del (gboolean external_command,
NULL);
}
+const NMPlatformLink *
+nmtstp_link_get (int ifindex,
+ const char *name)
+{
+ const NMPlatformLink *pllink = NULL;
+
+ if (ifindex > 0) {
+ pllink = nm_platform_link_get (NM_PLATFORM_GET, ifindex);
+
+ if (pllink) {
+ g_assert_cmpint (pllink->ifindex, ==, ifindex);
+ if (name)
+ g_assert_cmpstr (name, ==, pllink->name);
+ } else {
+ if (name)
+ g_assert (!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, name));
+ }
+ } else {
+ g_assert (name);
+
+ pllink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, name);
+
+ if (pllink)
+ g_assert_cmpstr (name, ==, pllink->name);
+ }
+
+ g_assert (!name || nm_utils_iface_valid_name (name));
+
+ return pllink;
+}
+
void
nmtstp_link_set_updown (gboolean external_command,
int ifindex,
diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h
index 3a5a9ff847..26a44ff909 100644
--- a/src/platform/tests/test-common.h
+++ b/src/platform/tests/test-common.h
@@ -136,6 +136,8 @@ void nmtstp_ip6_address_del (gboolean external_command,
struct in6_addr address,
int plen);
+const NMPlatformLink *nmtstp_link_get (int ifindex, const char *name);
+
void nmtstp_link_set_updown (gboolean external_command,
int ifindex,
gboolean up);