diff options
author | Thomas Haller <thaller@redhat.com> | 2014-04-17 14:56:32 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-06-05 18:12:56 +0200 |
commit | 0e9cd4f6fc44c617377c3bc6298e74dd86aaec01 (patch) | |
tree | f8d7680bc082db2a7d20cf6f868ac5741e79da15 /include | |
parent | be56b26c7d96058db00249c461eb9e97033d62bc (diff) | |
download | NetworkManager-0e9cd4f6fc44c617377c3bc6298e74dd86aaec01.tar.gz |
nmtst: add functions nmtst_platform_ip[46]_routes_equal
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/nm-test-utils.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index abc75993fd..f42c70d183 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -362,6 +362,48 @@ nmtst_platform_ip6_route_full (const char *network, guint plen, const char *gate return route; } +inline static void +nmtst_platform_ip4_routes_equal (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b, gsize len) +{ + gsize i; + + g_assert (a); + g_assert (b); + + for (i = 0; i < len; i++) { + if (nm_platform_ip4_route_cmp (&a[i], &b[i]) != 0) { + g_error ("Error comparing IPv4 route[%lu]: %s vs %s", (long unsigned) i, + nmtst_static_1024_01 (nm_platform_ip4_route_to_string (&a[i])), + nmtst_static_1024_02 (nm_platform_ip4_route_to_string (&b[i]))); + g_assert_not_reached (); + } + + /* also check with memcmp, though this might fail for valid programs (due to field alignment) */ + g_assert_cmpint (memcmp (&a[i], &b[i], sizeof (a[i])), ==, 0); + } +} + +inline static void +nmtst_platform_ip6_routes_equal (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b, gsize len) +{ + gsize i; + + g_assert (a); + g_assert (b); + + for (i = 0; i < len; i++) { + if (nm_platform_ip6_route_cmp (&a[i], &b[i]) != 0) { + g_error ("Error comparing IPv6 route[%lu]: %s vs %s", (long unsigned) i, + nmtst_static_1024_01 (nm_platform_ip6_route_to_string (&a[i])), + nmtst_static_1024_02 (nm_platform_ip6_route_to_string (&b[i]))); + g_assert_not_reached (); + } + + /* also check with memcmp, though this might fail for valid programs (due to field alignment) */ + g_assert_cmpint (memcmp (&a[i], &b[i], sizeof (a[i])), ==, 0); + } +} + #endif |