Commit c55c6312 authored by Beniamino Galvani's avatar Beniamino Galvani

shared: add test utilities for IP routes

Add utility functions to check the value of a route attribute.
parent b9d11ffa
......@@ -1291,6 +1291,50 @@ nmtst_setting_ip_config_add_route (NMSettingIPConfig *s_ip,
g_assert (nm_setting_ip_config_add_route (s_ip, route));
nm_ip_route_unref (route);
}
inline static void
nmtst_assert_route_attribute_string (NMIPRoute *route, const char *name, const char *value)
{
GVariant *variant;
variant = nm_ip_route_get_attribute (route, name);
g_assert (variant);
g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING));
g_assert_cmpstr (g_variant_get_string (variant, NULL), ==, value);
}
inline static void
nmtst_assert_route_attribute_byte (NMIPRoute *route, const char *name, guchar value)
{
GVariant *variant;
variant = nm_ip_route_get_attribute (route, name);
g_assert (variant);
g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_BYTE));
g_assert_cmpint (g_variant_get_byte (variant), ==, value);
}
inline static void
nmtst_assert_route_attribute_uint32 (NMIPRoute *route, const char *name, guint32 value)
{
GVariant *variant;
variant = nm_ip_route_get_attribute (route, name);
g_assert (variant);
g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_UINT32));
g_assert_cmpint (g_variant_get_uint32 (variant), ==, value);
}
inline static void
nmtst_assert_route_attribute_boolean (NMIPRoute *route, const char *name, gboolean value)
{
GVariant *variant;
variant = nm_ip_route_get_attribute (route, name);
g_assert (variant);
g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_BOOLEAN));
g_assert_cmpint (g_variant_get_boolean (variant), ==, value);
}
#endif /* NM_SETTING_IP_CONFIG_H */
#if (defined(__NM_SIMPLE_CONNECTION_H__) && defined(__NM_SETTING_CONNECTION_H__)) || (defined(NM_CONNECTION_H))
......@@ -1661,6 +1705,7 @@ nmtst_assert_hwaddr_equals (gconstpointer hwaddr1, gssize hwaddr1_len, const cha
nmtst_assert_hwaddr_equals (hwaddr1, hwaddr1_len, expected, __FILE__, __LINE__)
#endif
#if defined(__NM_SIMPLE_CONNECTION_H__) && defined(__NM_SETTING_CONNECTION_H__) && defined(__NM_KEYFILE_INTERNAL_H__)
static inline NMConnection *
......
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