diff options
Diffstat (limited to 'src/settings/plugins/ifnet/tests/test_all.c')
| -rw-r--r-- | src/settings/plugins/ifnet/tests/test_all.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/src/settings/plugins/ifnet/tests/test_all.c b/src/settings/plugins/ifnet/tests/test_all.c index 52d9ce2a..50441d4e 100644 --- a/src/settings/plugins/ifnet/tests/test_all.c +++ b/src/settings/plugins/ifnet/tests/test_all.c @@ -33,11 +33,21 @@ #include "wpa_parser.h" #include "connection_parser.h" +/* Fake config file function to make the linker happy */ +const char *ifnet_plugin_get_conf_file (void); + +const char * +ifnet_plugin_get_conf_file (void) +{ + return "/etc/foo/barasdfasdfasdfasdf"; +} + + static void test_getdata () { ASSERT (ifnet_get_data ("eth1", "config") - && strcmp (ifnet_get_data ("eth1", "config"), "dhcp") == 0, + && strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0, "get data", "config_eth1 is not correct"); ASSERT (ifnet_get_data ("ppp0", "username") && strcmp (ifnet_get_data ("ppp0", "username"), "user") == 0, @@ -84,7 +94,7 @@ test_is_static () ASSERT (is_static_ip4 ("eth0") == TRUE, "is static", "a static interface is recognized as dhcp"); ASSERT (!is_static_ip6 ("eth0") == TRUE, "is static", - "a static interface is recognized as dhcp"); + "a dhcp interface is recognized as static"); } static void @@ -182,10 +192,6 @@ test_convert_ipv4_config_block () ASSERT (iblock == NULL, "convert config_block", "convert error configuration"); destroy_ip_block (iblock); - iblock = convert_ip4_config_block ("eth6"); - ASSERT (iblock != NULL, "convert config_block", - "convert error configuration"); - destroy_ip_block (iblock); } static void @@ -200,6 +206,16 @@ test_convert_ipv4_routes_block () destroy_ip_block (tmp); ASSERT (iblock == NULL, "convert ip4 routes", "should only get one route"); + + iblock = convert_ip4_routes_block ("eth9"); + 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"); + iblock = iblock->next; + destroy_ip_block (tmp); + ASSERT (iblock == NULL, "convert ip4 routes", + "should only get one route"); } static void @@ -222,6 +238,9 @@ test_wpa_parser () "wep_key0 of static-wep-test should be abcde, find %s", value); ASSERT (exist_ssid ("leap-example"), "get wsec", "ssid leap-example is not found"); + + value = wpa_get_value ("test-with-hash-in-psk", "psk"); + g_assert_cmpstr (value, ==, "\"xjtudlc3731###asdfasdfasdf\""); } static void @@ -272,6 +291,18 @@ test_new_connection () "new connection failed: %s", error ? error->message : "NONE"); g_object_unref (connection); + + connection = ifnet_update_connection_from_config_block ("eth9", &error); + ASSERT (connection != NULL, "new connection", + "new connection(eth9) failed: %s", + error ? error->message : "NONE"); + g_object_unref (connection); + + connection = ifnet_update_connection_from_config_block ("eth10", &error); + ASSERT (connection != NULL, "new connection", + "new connection(eth10) failed: %s", + error ? error->message : "NONE"); + g_object_unref (connection); } #define NET_GEN_NAME "net.generate" |