platform/test: fix expecting NM_PLATFORM_SOURCE_KERNEL in platform tests
In this case, the fake platform implementation was wrong in that it did not set the source property of the route/address objects like linux platform does. Fix the test and the fake platform. https://bugzilla.gnome.org/show_bug.cgi?id=706293 Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -827,6 +827,7 @@ ip4_address_add (NMPlatform *platform, int ifindex,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset (&address, 0, sizeof (address));
|
memset (&address, 0, sizeof (address));
|
||||||
|
address.source = NM_PLATFORM_SOURCE_KERNEL;
|
||||||
address.ifindex = ifindex;
|
address.ifindex = ifindex;
|
||||||
address.address = addr;
|
address.address = addr;
|
||||||
address.peer_address = peer_addr;
|
address.peer_address = peer_addr;
|
||||||
@@ -868,6 +869,7 @@ ip6_address_add (NMPlatform *platform, int ifindex,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset (&address, 0, sizeof (address));
|
memset (&address, 0, sizeof (address));
|
||||||
|
address.source = NM_PLATFORM_SOURCE_KERNEL;
|
||||||
address.ifindex = ifindex;
|
address.ifindex = ifindex;
|
||||||
address.address = addr;
|
address.address = addr;
|
||||||
address.peer_address = peer_addr;
|
address.peer_address = peer_addr;
|
||||||
@@ -1045,6 +1047,7 @@ ip4_route_add (NMPlatform *platform, int ifindex, in_addr_t network, int plen,
|
|||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
memset (&route, 0, sizeof (route));
|
memset (&route, 0, sizeof (route));
|
||||||
|
route.source = NM_PLATFORM_SOURCE_KERNEL;
|
||||||
route.ifindex = ifindex;
|
route.ifindex = ifindex;
|
||||||
route.network = network;
|
route.network = network;
|
||||||
route.plen = plen;
|
route.plen = plen;
|
||||||
@@ -1082,6 +1085,7 @@ ip6_route_add (NMPlatform *platform, int ifindex, struct in6_addr network, int p
|
|||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
memset (&route, 0, sizeof (route));
|
memset (&route, 0, sizeof (route));
|
||||||
|
route.source = NM_PLATFORM_SOURCE_KERNEL;
|
||||||
route.ifindex = ifindex;
|
route.ifindex = ifindex;
|
||||||
route.network = network;
|
route.network = network;
|
||||||
route.plen = plen;
|
route.plen = plen;
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#include "test-common.h"
|
#include "test-common.h"
|
||||||
|
#include "nm-test-utils.h"
|
||||||
|
|
||||||
#define DEVICE_NAME "nm-test-device"
|
#define DEVICE_NAME "nm-test-device"
|
||||||
|
|
||||||
@@ -93,18 +94,21 @@ test_ip4_route ()
|
|||||||
/* Test route listing */
|
/* Test route listing */
|
||||||
routes = nm_platform_ip4_route_get_all (ifindex, TRUE);
|
routes = nm_platform_ip4_route_get_all (ifindex, TRUE);
|
||||||
memset (rts, 0, sizeof (rts));
|
memset (rts, 0, sizeof (rts));
|
||||||
|
rts[0].source = NM_PLATFORM_SOURCE_KERNEL;
|
||||||
rts[0].network = gateway;
|
rts[0].network = gateway;
|
||||||
rts[0].plen = 32;
|
rts[0].plen = 32;
|
||||||
rts[0].ifindex = ifindex;
|
rts[0].ifindex = ifindex;
|
||||||
rts[0].gateway = INADDR_ANY;
|
rts[0].gateway = INADDR_ANY;
|
||||||
rts[0].metric = metric;
|
rts[0].metric = metric;
|
||||||
rts[0].mss = mss;
|
rts[0].mss = mss;
|
||||||
|
rts[1].source = NM_PLATFORM_SOURCE_KERNEL;
|
||||||
rts[1].network = network;
|
rts[1].network = network;
|
||||||
rts[1].plen = plen;
|
rts[1].plen = plen;
|
||||||
rts[1].ifindex = ifindex;
|
rts[1].ifindex = ifindex;
|
||||||
rts[1].gateway = gateway;
|
rts[1].gateway = gateway;
|
||||||
rts[1].metric = metric;
|
rts[1].metric = metric;
|
||||||
rts[1].mss = mss;
|
rts[1].mss = mss;
|
||||||
|
rts[2].source = NM_PLATFORM_SOURCE_KERNEL;
|
||||||
rts[2].network = 0;
|
rts[2].network = 0;
|
||||||
rts[2].plen = 0;
|
rts[2].plen = 0;
|
||||||
rts[2].ifindex = ifindex;
|
rts[2].ifindex = ifindex;
|
||||||
@@ -113,6 +117,7 @@ test_ip4_route ()
|
|||||||
rts[2].mss = mss;
|
rts[2].mss = mss;
|
||||||
g_assert_cmpint (routes->len, ==, 3);
|
g_assert_cmpint (routes->len, ==, 3);
|
||||||
g_assert (!memcmp (routes->data, rts, sizeof (rts)));
|
g_assert (!memcmp (routes->data, rts, sizeof (rts)));
|
||||||
|
nmtst_platform_ip4_routes_equal ((NMPlatformIP4Route *) routes->data, rts, routes->len);
|
||||||
g_array_unref (routes);
|
g_array_unref (routes);
|
||||||
|
|
||||||
/* Remove route */
|
/* Remove route */
|
||||||
@@ -176,18 +181,21 @@ test_ip6_route ()
|
|||||||
/* Test route listing */
|
/* Test route listing */
|
||||||
routes = nm_platform_ip6_route_get_all (ifindex, TRUE);
|
routes = nm_platform_ip6_route_get_all (ifindex, TRUE);
|
||||||
memset (rts, 0, sizeof (rts));
|
memset (rts, 0, sizeof (rts));
|
||||||
|
rts[0].source = NM_PLATFORM_SOURCE_KERNEL;
|
||||||
rts[0].network = gateway;
|
rts[0].network = gateway;
|
||||||
rts[0].plen = 128;
|
rts[0].plen = 128;
|
||||||
rts[0].ifindex = ifindex;
|
rts[0].ifindex = ifindex;
|
||||||
rts[0].gateway = in6addr_any;
|
rts[0].gateway = in6addr_any;
|
||||||
rts[0].metric = metric;
|
rts[0].metric = metric;
|
||||||
rts[0].mss = mss;
|
rts[0].mss = mss;
|
||||||
|
rts[1].source = NM_PLATFORM_SOURCE_KERNEL;
|
||||||
rts[1].network = network;
|
rts[1].network = network;
|
||||||
rts[1].plen = plen;
|
rts[1].plen = plen;
|
||||||
rts[1].ifindex = ifindex;
|
rts[1].ifindex = ifindex;
|
||||||
rts[1].gateway = gateway;
|
rts[1].gateway = gateway;
|
||||||
rts[1].metric = metric;
|
rts[1].metric = metric;
|
||||||
rts[1].mss = mss;
|
rts[1].mss = mss;
|
||||||
|
rts[2].source = NM_PLATFORM_SOURCE_KERNEL;
|
||||||
rts[2].network = in6addr_any;
|
rts[2].network = in6addr_any;
|
||||||
rts[2].plen = 0;
|
rts[2].plen = 0;
|
||||||
rts[2].ifindex = ifindex;
|
rts[2].ifindex = ifindex;
|
||||||
@@ -196,6 +204,7 @@ test_ip6_route ()
|
|||||||
rts[2].mss = mss;
|
rts[2].mss = mss;
|
||||||
g_assert_cmpint (routes->len, ==, 3);
|
g_assert_cmpint (routes->len, ==, 3);
|
||||||
g_assert (!memcmp (routes->data, rts, sizeof (rts)));
|
g_assert (!memcmp (routes->data, rts, sizeof (rts)));
|
||||||
|
nmtst_platform_ip6_routes_equal ((NMPlatformIP6Route *) routes->data, rts, routes->len);
|
||||||
g_array_unref (routes);
|
g_array_unref (routes);
|
||||||
|
|
||||||
/* Remove route */
|
/* Remove route */
|
||||||
|
Reference in New Issue
Block a user