diff options
| author | Michael Biebl <biebl@debian.org> | 2015-01-22 00:29:39 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2015-01-22 00:29:39 +0100 |
| commit | 2c032d8f1c6292c1338a615e6ec40252889ba85c (patch) | |
| tree | 1f77182220b2b0264288ba4a476ab47e5bc48716 /src/settings/plugins/ifnet/tests/test_all.c | |
| parent | 33491bc4279481db8ae47213e34a6d695a0e8830 (diff) | |
Imported Upstream version 1.0.0 upstream/1.0.0
Diffstat (limited to 'src/settings/plugins/ifnet/tests/test_all.c')
| -rw-r--r-- | src/settings/plugins/ifnet/tests/test_all.c | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/src/settings/plugins/ifnet/tests/test_all.c b/src/settings/plugins/ifnet/tests/test_all.c index c320ed5f..9c399128 100644 --- a/src/settings/plugins/ifnet/tests/test_all.c +++ b/src/settings/plugins/ifnet/tests/test_all.c @@ -20,6 +20,8 @@ * Copyright (C) 1999-2010 Gentoo Foundation, Inc. */ +#include "config.h" + #include <stdio.h> #include <string.h> #include <glib.h> @@ -55,7 +57,7 @@ nm_config_get_dhcp_client (NMConfig *config) } static void -test_getdata () +test_getdata (void) { ASSERT (ifnet_get_data ("eth1", "config") && strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0, @@ -103,7 +105,7 @@ test_write_hostname (const char *temp_path) } static void -test_is_static () +test_is_static (void) { ASSERT (is_static_ip4 ("eth1") == FALSE, "is static", "a dhcp interface is recognized as static"); @@ -114,7 +116,7 @@ test_is_static () } static void -test_has_default_route () +test_has_default_route (void) { ASSERT (has_default_ip4_route ("eth0"), "has default route", "eth0 should have a default ipv4 route"); @@ -126,7 +128,7 @@ test_has_default_route () } static void -test_has_ip6_address () +test_has_ip6_address (void) { ASSERT (has_ip6_address ("eth2"), "has ip6 address", "eth2 should have a ipv6 address"); @@ -136,7 +138,7 @@ test_has_ip6_address () } static void -test_is_ip4_address () +test_is_ip4_address (void) { gchar *address1 = "192.168.4.232/24"; gchar *address2 = "192.168.100.{1..254}/24"; @@ -151,7 +153,7 @@ test_is_ip4_address () } static void -test_is_ip6_address () +test_is_ip6_address (void) { gchar *address1 = "4321:0:1:2:3:4:567:89ac/24"; @@ -160,43 +162,30 @@ test_is_ip6_address () } static void -check_ip_block (ip_block * iblock, gchar * ip, gchar * netmask, gchar * gateway) +check_ip_block (ip_block * iblock, gchar * ip, guint32 prefix, gchar * gateway) { - char *str; - guint32 tmp_ip4_addr; - - str = malloc (INET_ADDRSTRLEN); - tmp_ip4_addr = iblock->ip; - inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN); - ASSERT (strcmp (ip, str) == 0, "check ip", - "ip expected:%s, find:%s", ip, str); - tmp_ip4_addr = iblock->netmask; - inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN); - ASSERT (strcmp (netmask, str) == 0, "check netmask", - "netmask expected:%s, find:%s", netmask, str); - tmp_ip4_addr = iblock->gateway; - inet_ntop (AF_INET, &tmp_ip4_addr, str, INET_ADDRSTRLEN); - ASSERT (strcmp (gateway, str) == 0, "check gateway", - "gateway expected:%s, find:%s", gateway, str); - free (str); + ASSERT (strcmp (ip, iblock->ip) == 0, "check ip", + "ip expected:%s, find:%s", ip, iblock->ip); + ASSERT (prefix == iblock->prefix, "check netmask", + "prefix expected:%d, find:%d", prefix, iblock->prefix); + ASSERT (g_strcmp0 (gateway, iblock->next_hop) == 0, "check gateway", + "gateway expected:%s, find:%s", gateway, iblock->next_hop); } static void -test_convert_ipv4_config_block () +test_convert_ipv4_config_block (void) { ip_block *iblock = convert_ip4_config_block ("eth0"); ip_block *tmp = iblock; ASSERT (iblock != NULL, "convert ipv4 block", "block eth0 should not be NULL"); - check_ip_block (iblock, "202.117.16.121", "255.255.255.0", - "202.117.16.1"); + check_ip_block (iblock, "202.117.16.121", 24, "202.117.16.1"); iblock = iblock->next; destroy_ip_block (tmp); ASSERT (iblock != NULL, "convert ipv4 block", "block eth0 should have a second IP address"); - check_ip_block (iblock, "192.168.4.121", "255.255.255.0", - "202.117.16.1"); + check_ip_block (iblock, "192.168.4.121", 24, "202.117.16.1"); destroy_ip_block (iblock); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, @@ -206,7 +195,7 @@ test_convert_ipv4_config_block () ASSERT (iblock != NULL && iblock->next == NULL, "convert error IPv4 address", "should only get one address"); - check_ip_block (iblock, "192.168.4.121", "255.255.255.0", "0.0.0.0"); + check_ip_block (iblock, "192.168.4.121", 24, NULL); destroy_ip_block (iblock); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, @@ -214,17 +203,16 @@ test_convert_ipv4_config_block () iblock = convert_ip4_config_block ("eth3"); ASSERT (iblock == NULL, "convert config_block", "convert error configuration"); - destroy_ip_block (iblock); } static void -test_convert_ipv4_routes_block () +test_convert_ipv4_routes_block (void) { ip_block *iblock = convert_ip4_routes_block ("eth0"); ip_block *tmp = iblock; ASSERT (iblock != NULL, "convert ip4 routes", "should get one route"); - check_ip_block (iblock, "192.168.4.0", "255.255.255.0", "192.168.4.1"); + check_ip_block (iblock, "192.168.4.0", 24, "192.168.4.1"); iblock = iblock->next; destroy_ip_block (tmp); ASSERT (iblock == NULL, "convert ip4 routes", @@ -234,7 +222,7 @@ test_convert_ipv4_routes_block () tmp = iblock; ASSERT (iblock != NULL, "convert ip4 routes", "should get one route"); - check_ip_block (iblock, "10.0.0.0", "255.0.0.0", "192.168.0.1"); + check_ip_block (iblock, "10.0.0.0", 8, "192.168.0.1"); iblock = iblock->next; destroy_ip_block (tmp); ASSERT (iblock == NULL, "convert ip4 routes", @@ -242,7 +230,7 @@ test_convert_ipv4_routes_block () } static void -test_wpa_parser () +test_wpa_parser (void) { const char *value; @@ -261,7 +249,7 @@ test_wpa_parser () } static void -test_strip_string () +test_strip_string (void) { gchar *str = "( \"default via 202.117.16.1\" )"; gchar *result = g_strdup (str); @@ -277,7 +265,7 @@ test_strip_string () } static void -test_is_unmanaged () +test_is_unmanaged (void) { ASSERT (is_managed ("eth0"), "test_is_unmanaged", "eth0 should be managed"); @@ -286,7 +274,7 @@ test_is_unmanaged () } static void -test_new_connection () +test_new_connection (void) { GError *error = NULL; NMConnection *connection; @@ -409,7 +397,7 @@ test_add_connection (const char *basepath) } static void -test_delete_connection () +test_delete_connection (void) { GError *error = NULL; NMConnection *connection; @@ -438,7 +426,7 @@ test_delete_connection () } static void -test_missing_config () +test_missing_config (void) { GError *error = NULL; NMConnection *connection; |