Verified Commit 2b28b9b2 authored by Thomas Haller's avatar Thomas Haller

ndisc/tests: merge branch 'th/ndisc-test-assertion-fixes'

(cherry picked from commit 1411f013)
parents 5913e4ce e6f235d9
Pipeline #199394 passed with stage
in 49 minutes and 47 seconds
...@@ -47,44 +47,47 @@ match_gateway (const NMNDiscData *rdata, guint idx, const char *addr, guint32 ts ...@@ -47,44 +47,47 @@ match_gateway (const NMNDiscData *rdata, guint idx, const char *addr, guint32 ts
g_assert_cmpint (gw->preference, ==, pref); g_assert_cmpint (gw->preference, ==, pref);
} }
static void #define match_address(rdata, idx, addr, ts, lt, pref) \
match_address (const NMNDiscData *rdata, guint idx, const char *addr, guint32 ts, guint32 lt, guint32 preferred) G_STMT_START { \
{ const NMNDiscData *_rdata = (rdata); \
const NMNDiscAddress *a; guint _idx = (idx); \
char buf[INET6_ADDRSTRLEN]; const NMNDiscAddress *_a; \
guint _ts = (ts); \
g_assert (rdata); \
g_assert_cmpint (idx, <, rdata->addresses_n); g_assert (_rdata); \
g_assert (rdata->addresses); g_assert_cmpint (_idx, <, _rdata->addresses_n); \
g_assert (_rdata->addresses); \
a = &rdata->addresses[idx]; \
_a = &_rdata->addresses[_idx]; \
g_assert_cmpstr (inet_ntop (AF_INET6, &a->address, buf, sizeof (buf)), ==, addr); \
g_assert_cmpint (a->timestamp, ==, ts); nmtst_assert_ip6_address (&_a->address, (addr)); \
g_assert_cmpint (a->lifetime, ==, lt); g_assert_cmpint (_a->timestamp, <=, _ts + 1); \
g_assert_cmpint (a->preferred, ==, preferred); g_assert_cmpint ((int) _a->timestamp, >=, (int) _ts - 1); \
} g_assert_cmpint (_a->timestamp + _a->lifetime, ==, _ts + (lt)); \
g_assert_cmpint (_a->timestamp + _a->preferred, ==, _ts + (pref)); \
static void } G_STMT_END
match_route (const NMNDiscData *rdata, guint idx, const char *nw, int plen, const char *gw, guint32 ts, guint32 lt, NMIcmpv6RouterPref pref)
{ #define match_route(rdata, idx, nw, pl, gw, ts, lt, pref) \
const NMNDiscRoute *route; G_STMT_START { \
char buf[INET6_ADDRSTRLEN]; const NMNDiscData *_rdata = (rdata); \
guint _idx = (idx); \
g_assert (rdata); const NMNDiscRoute *_r; \
g_assert_cmpint (idx, <, rdata->routes_n); int _plen = (pl); \
g_assert (rdata->routes); \
g_assert (plen > 0 && plen <= 128); g_assert (_rdata); \
g_assert_cmpint (_idx, <, _rdata->routes_n); \
route = &rdata->routes[idx]; g_assert (_rdata->routes); \
g_assert (_plen > 0 && _plen <= 128); \
g_assert_cmpstr (inet_ntop (AF_INET6, &route->network, buf, sizeof (buf)), ==, nw); \
g_assert_cmpint ((int) route->plen, ==, plen); _r = &_rdata->routes[idx]; \
g_assert_cmpstr (inet_ntop (AF_INET6, &route->gateway, buf, sizeof (buf)), ==, gw); \
g_assert_cmpint (route->timestamp, ==, ts); nmtst_assert_ip6_address (&_r->network, (nw)); \
g_assert_cmpint (route->lifetime, ==, lt); g_assert_cmpint ((int) _r->plen, ==, _plen); \
g_assert_cmpint (route->preference, ==, pref); nmtst_assert_ip6_address (&_r->gateway, (gw)); \
} g_assert_cmpint (_r->timestamp, ==, (ts)); \
g_assert_cmpint (_r->lifetime, ==, (lt)); \
g_assert_cmpint (_r->preference, ==, (pref)); \
} G_STMT_END
static void static void
match_dns_server (const NMNDiscData *rdata, guint idx, const char *addr, guint32 ts, guint32 lt) match_dns_server (const NMNDiscData *rdata, guint idx, const char *addr, guint32 ts, guint32 lt)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment