mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-07 04:00:32 +01:00
core: use g_test_expect_message() in test programs
Use g_test_expect_message() in the various daemon-side test programs, to avoid spewing error messages when (successfully) running "make check". The ifnet and ifupdown plugins are extremely verbose, so they were partially "fixed" by turning down the logging level from INFO to WARN in those tests. test-dhcp-options needed to be converted to gtestutils so that the newly-added check in nm-dbus-manager would recognize it as a test program and not try to create a private bus.
This commit is contained in:
parent
e3fc25731e
commit
0140cdb73d
7 changed files with 361 additions and 52 deletions
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
#include "nm-test-helpers.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "reader.h"
|
||||
|
|
@ -512,8 +513,11 @@ test_read_wired_static_no_prefix (gconstpointer user_data)
|
|||
file = g_strdup_printf (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-wired-static-no-prefix-%u", expected_prefix);
|
||||
expected_id = g_strdup_printf ("System test-wired-static-no-prefix-%u", expected_prefix);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*missing PREFIX, assuming*");
|
||||
connection = connection_from_file (file, NULL, TYPE_ETHERNET, NULL, NULL,
|
||||
NULL, NULL, NULL, &error, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection);
|
||||
g_assert (nm_connection_verify (connection, &error));
|
||||
|
|
@ -1857,6 +1861,8 @@ test_read_wired_ipv6_manual (void)
|
|||
NMIP6Route *ip6_route;
|
||||
struct in6_addr addr;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*ignoring manual default route*");
|
||||
connection = connection_from_file (TEST_IFCFG_WIRED_IPV6_MANUAL,
|
||||
NULL,
|
||||
TYPE_ETHERNET,
|
||||
|
|
@ -1867,6 +1873,8 @@ test_read_wired_ipv6_manual (void)
|
|||
&route6file,
|
||||
&error,
|
||||
&ignore_error);
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
ASSERT (connection != NULL,
|
||||
"wired-ipv6-manual-read", "failed to read %s: %s", TEST_IFCFG_WIRED_IPV6_MANUAL, error->message);
|
||||
|
||||
|
|
@ -2763,9 +2771,12 @@ test_read_write_802_1X_subj_matches (void)
|
|||
GError *error = NULL;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*missing IEEE_8021X_CA_CERT*peap*");
|
||||
connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-802-1X-subj-matches",
|
||||
NULL, TYPE_ETHERNET, NULL, NULL,
|
||||
NULL, NULL, NULL, &error, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
g_assert_no_error (error);
|
||||
g_assert (connection != NULL);
|
||||
|
||||
|
|
@ -2795,8 +2806,11 @@ test_read_write_802_1X_subj_matches (void)
|
|||
nm_utils_normalize_connection (connection, TRUE);
|
||||
|
||||
/* re-read the connection for comparison */
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*missing IEEE_8021X_CA_CERT*peap*");
|
||||
reread = connection_from_file (written, NULL, TYPE_ETHERNET, NULL, NULL,
|
||||
NULL, NULL, NULL, &error, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
unlink (written);
|
||||
g_free (written);
|
||||
|
||||
|
|
@ -3002,6 +3016,10 @@ test_read_wired_aliases_bad (void)
|
|||
NMIP4Address *ip4_addr;
|
||||
struct in_addr addr;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*aliasem1:1*has no DEVICE*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*aliasem1:2*has invalid DEVICE*");
|
||||
connection = connection_from_file (TEST_IFCFG_ALIASES_BAD,
|
||||
NULL,
|
||||
TYPE_ETHERNET,
|
||||
|
|
@ -3012,6 +3030,7 @@ test_read_wired_aliases_bad (void)
|
|||
&route6file,
|
||||
&error,
|
||||
&ignore_error);
|
||||
g_test_assert_expected_messages ();
|
||||
ASSERT (connection != NULL,
|
||||
"aliases-bad-read", "failed to read %s: %s", TEST_IFCFG_ALIASES_BAD, error->message);
|
||||
|
||||
|
|
@ -11250,7 +11269,7 @@ test_read_ibft_static (void)
|
|||
}
|
||||
|
||||
static void
|
||||
test_read_ibft_malformed (const char *name, const char *iscsiadm_path)
|
||||
test_read_ibft_malformed (const char *name, const char *iscsiadm_path, gboolean expect_warning)
|
||||
{
|
||||
NMConnection *connection;
|
||||
char *unmanaged = NULL;
|
||||
|
|
@ -11262,6 +11281,10 @@ test_read_ibft_malformed (const char *name, const char *iscsiadm_path)
|
|||
|
||||
g_assert (g_file_test (iscsiadm_path, G_FILE_TEST_EXISTS));
|
||||
|
||||
if (expect_warning) {
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*malformed iscsiadm record*");
|
||||
}
|
||||
connection = connection_from_file (TEST_IFCFG_IBFT_STATIC,
|
||||
NULL,
|
||||
TYPE_ETHERNET,
|
||||
|
|
@ -11272,6 +11295,8 @@ test_read_ibft_malformed (const char *name, const char *iscsiadm_path)
|
|||
&route6file,
|
||||
&error,
|
||||
&ignore_error);
|
||||
if (expect_warning)
|
||||
g_test_assert_expected_messages ();
|
||||
ASSERT (connection == NULL,
|
||||
name, "unexpectedly able to read %s", TEST_IFCFG_IBFT_STATIC);
|
||||
|
||||
|
|
@ -12982,6 +13007,8 @@ test_read_bond_slave (void)
|
|||
gboolean ignore_error = FALSE;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*ignoring IP4 config on slave*");
|
||||
connection = connection_from_file (TEST_IFCFG_BOND_SLAVE,
|
||||
NULL,
|
||||
TYPE_ETHERNET,
|
||||
|
|
@ -12992,6 +13019,8 @@ test_read_bond_slave (void)
|
|||
&route6file,
|
||||
&error,
|
||||
&ignore_error);
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
ASSERT (connection != NULL,
|
||||
"bond-slave-read", "unexpected failure reading %s", TEST_IFCFG_BOND_SLAVE);
|
||||
|
||||
|
|
@ -13346,6 +13375,8 @@ test_read_bond_slave_ib (void)
|
|||
gboolean ignore_error = FALSE;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*ignoring IP4 config on slave*");
|
||||
connection = connection_from_file (TEST_IFCFG_BOND_SLAVE_IB,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
@ -13356,6 +13387,8 @@ test_read_bond_slave_ib (void)
|
|||
&route6file,
|
||||
&error,
|
||||
&ignore_error);
|
||||
g_test_assert_expected_messages();
|
||||
|
||||
ASSERT (connection != NULL,
|
||||
"bond-slave-read-ib", "unexpected failure reading %s", TEST_IFCFG_BOND_SLAVE_IB);
|
||||
|
||||
|
|
@ -13694,8 +13727,12 @@ test_read_dcb_bad_booleans (void)
|
|||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*invalid DCB_PG_STRICT value*not all 0s and 1s*");
|
||||
connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-booleans",
|
||||
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
|
||||
g_assert (strstr (error->message, "invalid boolean digit"));
|
||||
g_assert (connection == NULL);
|
||||
|
|
@ -13707,8 +13744,12 @@ test_read_dcb_short_booleans (void)
|
|||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*DCB_PG_STRICT value*8 characters*");
|
||||
connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-booleans",
|
||||
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
|
||||
g_assert (strstr (error->message, "boolean array must be 8 characters"));
|
||||
g_assert (connection == NULL);
|
||||
|
|
@ -13720,8 +13761,12 @@ test_read_dcb_bad_uints (void)
|
|||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*invalid DCB_PG_UP2TC value*not 0 - 7*");
|
||||
connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-uints",
|
||||
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
|
||||
g_assert (strstr (error->message, "invalid uint digit"));
|
||||
g_assert (connection == NULL);
|
||||
|
|
@ -13733,8 +13778,12 @@ test_read_dcb_short_uints (void)
|
|||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*DCB_PG_UP2TC value*8 characters*");
|
||||
connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-uints",
|
||||
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
|
||||
g_assert (strstr (error->message, "uint array must be 8 characters"));
|
||||
g_assert (connection == NULL);
|
||||
|
|
@ -13746,8 +13795,12 @@ test_read_dcb_bad_percent (void)
|
|||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*invalid DCB_PG_PCT percentage value*");
|
||||
connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-percent",
|
||||
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
|
||||
g_assert (strstr (error->message, "invalid percent element"));
|
||||
g_assert (connection == NULL);
|
||||
|
|
@ -13759,8 +13812,12 @@ test_read_dcb_short_percent (void)
|
|||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*invalid DCB_PG_PCT percentage list value*");
|
||||
connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-percent",
|
||||
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
|
||||
g_assert (strstr (error->message, "percent array must be 8 elements"));
|
||||
g_assert (connection == NULL);
|
||||
|
|
@ -13772,8 +13829,12 @@ test_read_dcb_pgpct_not_100 (void)
|
|||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*DCB_PG_PCT percentages do not equal 100*");
|
||||
connection = connection_from_file (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-pgpct-not-100",
|
||||
NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
g_assert_error (error, IFCFG_PLUGIN_ERROR, 0);
|
||||
g_assert (strstr (error->message, "invalid percentage sum"));
|
||||
g_assert (connection == NULL);
|
||||
|
|
@ -14296,14 +14357,20 @@ int main (int argc, char **argv)
|
|||
gboolean success;
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
#if GLIB_CHECK_VERSION(2,34,0)
|
||||
/* consider even unexpected g_message()s to be fatal */
|
||||
g_log_set_always_fatal (G_LOG_LEVEL_MASK);
|
||||
#else
|
||||
/* g_test_expect_message() is dummied out, so allow warnings */
|
||||
g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
|
||||
#endif
|
||||
|
||||
g_type_init ();
|
||||
|
||||
success = nm_utils_init (&error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (success);
|
||||
|
||||
g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
|
||||
|
||||
g_test_add_func (TPATH "svUnescape", test_svUnescape);
|
||||
|
||||
g_test_add_func (TPATH "unmanaged", test_read_unmanaged);
|
||||
|
|
@ -14343,7 +14410,7 @@ int main (int argc, char **argv)
|
|||
test_read_wired_8021x_tls_secret_flags (TEST_IFCFG_WIRED_8021X_TLS_AGENT, NM_SETTING_SECRET_FLAG_AGENT_OWNED);
|
||||
test_read_wired_8021x_tls_secret_flags (TEST_IFCFG_WIRED_8021X_TLS_ALWAYS,
|
||||
NM_SETTING_SECRET_FLAG_AGENT_OWNED | NM_SETTING_SECRET_FLAG_NOT_SAVED);
|
||||
g_test_add_func (TPATH "802-1x/subj-mathes", test_read_write_802_1X_subj_matches);
|
||||
g_test_add_func (TPATH "802-1x/subj-matches", test_read_write_802_1X_subj_matches);
|
||||
test_read_wired_aliases_good ();
|
||||
test_read_wired_aliases_bad ();
|
||||
test_read_wifi_open ();
|
||||
|
|
@ -14463,12 +14530,12 @@ int main (int argc, char **argv)
|
|||
/* iSCSI / ibft */
|
||||
test_read_ibft_dhcp ();
|
||||
test_read_ibft_static ();
|
||||
test_read_ibft_malformed ("ibft-bad-record-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-record");
|
||||
test_read_ibft_malformed ("ibft-bad-entry-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-entry");
|
||||
test_read_ibft_malformed ("ibft-bad-ipaddr-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-ipaddr");
|
||||
test_read_ibft_malformed ("ibft-bad-gateway-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-gateway");
|
||||
test_read_ibft_malformed ("ibft-bad-dns1-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-dns1");
|
||||
test_read_ibft_malformed ("ibft-bad-dns2-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-dns2");
|
||||
test_read_ibft_malformed ("ibft-bad-record-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-record", FALSE);
|
||||
test_read_ibft_malformed ("ibft-bad-entry-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-entry", TRUE);
|
||||
test_read_ibft_malformed ("ibft-bad-ipaddr-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-ipaddr", TRUE);
|
||||
test_read_ibft_malformed ("ibft-bad-gateway-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-gateway", TRUE);
|
||||
test_read_ibft_malformed ("ibft-bad-dns1-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-dns1", TRUE);
|
||||
test_read_ibft_malformed ("ibft-bad-dns2-read", TEST_IFCFG_DIR "/iscsiadm-test-bad-dns2", TRUE);
|
||||
g_test_add_func (TPATH "dcb/read-basic", test_read_dcb_basic);
|
||||
g_test_add_func (TPATH "dcb/write-basic", test_write_dcb_basic);
|
||||
g_test_add_func (TPATH "dcb/default-app-priorities", test_read_dcb_default_app_priorities);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,11 @@
|
|||
#include <unistd.h>
|
||||
#include <nm-utils.h>
|
||||
|
||||
#include "net_parser.h"
|
||||
#include "nm-test-helpers.h"
|
||||
#include "nm-linux-platform.h"
|
||||
#include "nm-logging.h"
|
||||
|
||||
#include "net_parser.h"
|
||||
#include "net_utils.h"
|
||||
#include "wpa_parser.h"
|
||||
#include "connection_parser.h"
|
||||
|
|
@ -195,12 +198,19 @@ test_convert_ipv4_config_block ()
|
|||
check_ip_block (iblock, "192.168.4.121", "255.255.255.0",
|
||||
"202.117.16.1");
|
||||
destroy_ip_block (iblock);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*Can't handle IPv4 address*202.117.16.1211*");
|
||||
iblock = convert_ip4_config_block ("eth2");
|
||||
g_test_assert_expected_messages ();
|
||||
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");
|
||||
destroy_ip_block (iblock);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*missing netmask or prefix*");
|
||||
iblock = convert_ip4_config_block ("eth3");
|
||||
ASSERT (iblock == NULL, "convert config_block",
|
||||
"convert error configuration");
|
||||
|
|
@ -281,7 +291,12 @@ test_new_connection ()
|
|||
GError *error = NULL;
|
||||
NMConnection *connection;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*Can't handle IPv4 address*202.117.16.1211*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*Can't handle IPv6 address*202.117.16.1211*");
|
||||
connection = ifnet_update_connection_from_config_block ("eth2", NULL, &error);
|
||||
g_test_assert_expected_messages ();
|
||||
ASSERT (connection != NULL, "new connection",
|
||||
"new connection failed: %s",
|
||||
error ? error->message : "None");
|
||||
|
|
@ -378,7 +393,12 @@ test_add_connection (const char *basepath)
|
|||
kill_backup (&backup);
|
||||
g_object_unref (connection);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*Can't handle ipv4 address: brd, missing netmask or prefix*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*Can't handle ipv4 address: 202.117.16.255, missing netmask or prefix*");
|
||||
connection = ifnet_update_connection_from_config_block ("myxjtu2", basepath, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
ASSERT (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL),
|
||||
"add connection", "add connection failed: %s", "myxjtu2");
|
||||
kill_backup (&backup);
|
||||
|
|
@ -423,7 +443,10 @@ test_missing_config ()
|
|||
GError *error = NULL;
|
||||
NMConnection *connection;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*Unknown config for eth8*");
|
||||
connection = ifnet_update_connection_from_config_block ("eth8", NULL, &error);
|
||||
g_test_assert_expected_messages ();
|
||||
ASSERT (connection == NULL && error != NULL, "get connection",
|
||||
"get connection should fail with 'Unknown config for eth8'");
|
||||
}
|
||||
|
|
@ -434,6 +457,8 @@ main (int argc, char **argv)
|
|||
char *f;
|
||||
|
||||
g_type_init ();
|
||||
nm_linux_platform_setup ();
|
||||
nm_logging_setup ("WARN", "DEFAULT", NULL, NULL);
|
||||
|
||||
nm_fake_platform_setup ();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
#include <nm-utils.h>
|
||||
|
||||
#include "nm-test-helpers.h"
|
||||
#include "nm-logging.h"
|
||||
|
||||
#include "interface_parser.h"
|
||||
#include "parser.h"
|
||||
|
||||
|
|
@ -941,6 +943,7 @@ main (int argc, char **argv)
|
|||
|
||||
if (!nm_utils_init (&error))
|
||||
FAIL ("nm-utils-init", "failed to initialize libnm-util: %s", error->message);
|
||||
nm_logging_setup ("WARN", "DEFAULT", NULL, NULL);
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include <nm-setting-infiniband.h>
|
||||
|
||||
#include "nm-test-helpers.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#include "reader.h"
|
||||
#include "writer.h"
|
||||
|
|
@ -141,7 +142,36 @@ test_read_valid_wired_connection (void)
|
|||
const char *expected6_dnssearch2 = "redhat.com";
|
||||
const char *expected6_dnssearch3 = "gnu.org";
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv4.addresses1*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv4.addresses2*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*Missing prefix length*ipv4.address4*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*Missing prefix length*ipv4.address5*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv4.routes2*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv4.routes3*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv4.routes5*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv4.routes8*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*Missing prefix length*ipv6.address4*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv6.address5*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*Missing prefix length*ipv6.address5*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv6.address7*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv6.routes1*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv6.route6*semicolon at the end*");
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_WIRED_FILE, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
ASSERT (connection != NULL,
|
||||
"connection-read", "failed to read %s", TEST_WIRED_FILE);
|
||||
|
||||
|
|
@ -861,7 +891,14 @@ test_read_wired_mac_case (void)
|
|||
const char *expected_id = "Test Wired Connection MAC Case";
|
||||
const char *expected_uuid = "4e80a56d-c99f-4aad-a6dd-b449bc398c57";
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv4.addresses1*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv4.addresses2*semicolon at the end*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*ipv6.routes1*semicolon at the end*");
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_WIRED_MAC_CASE_FILE, NULL);
|
||||
g_test_assert_expected_messages ();
|
||||
ASSERT (connection != NULL,
|
||||
"connection-read", "failed to read %s", TEST_WIRED_MAC_CASE_FILE);
|
||||
|
||||
|
|
@ -2182,7 +2219,10 @@ test_read_wired_8021x_tls_blob_connection (void)
|
|||
g_assert_cmpint (nm_setting_802_1x_get_ca_cert_scheme (s_8021x), ==, NM_SETTING_802_1X_CK_SCHEME_BLOB);
|
||||
|
||||
/* Make sure it's not a path, since it's a blob */
|
||||
g_test_expect_message ("libnm-util", G_LOG_LEVEL_CRITICAL,
|
||||
"*assertion*scheme == NM_SETTING_802_1X_CK_SCHEME_PATH*");
|
||||
tmp = nm_setting_802_1x_get_ca_cert_path (s_8021x);
|
||||
g_test_assert_expected_messages ();
|
||||
g_assert (tmp == NULL);
|
||||
|
||||
/* Validate the path */
|
||||
|
|
@ -2212,7 +2252,10 @@ test_read_wired_8021x_tls_bad_path_connection (void)
|
|||
char *tmp2;
|
||||
gboolean success;
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*does not exist*");
|
||||
connection = nm_keyfile_plugin_connection_from_file (TEST_WIRED_TLS_PATH_MISSING_FILE, &error);
|
||||
g_test_assert_expected_messages ();
|
||||
if (connection == NULL) {
|
||||
g_assert (error);
|
||||
g_warning ("Failed to read %s: %s", TEST_WIRED_TLS_PATH_MISSING_FILE, error->message);
|
||||
|
|
@ -3300,6 +3343,7 @@ int main (int argc, char **argv)
|
|||
char *base;
|
||||
|
||||
g_type_init ();
|
||||
g_log_set_always_fatal (G_LOG_LEVEL_MASK);
|
||||
|
||||
if (!nm_utils_init (&error))
|
||||
FAIL ("nm-utils-init", "failed to initialize libnm-util: %s", error->message);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include <nm-setting-8021x.h>
|
||||
|
||||
#include "nm-test-helpers.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#include "nm-supplicant-config.h"
|
||||
#include "nm-supplicant-settings-verify.h"
|
||||
|
|
@ -173,13 +174,25 @@ test_wifi_open (void)
|
|||
|
||||
config = nm_supplicant_config_new ();
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'ssid' value 'Test SSID'*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'scan_ssid' value '1'*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'bssid' value '11:22:33:44:55:66'*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'freq_list' value *");
|
||||
success = nm_supplicant_config_add_setting_wireless (config, s_wifi, 0);
|
||||
ASSERT (success == TRUE,
|
||||
"wifi-open", "failed to add wireless setting to supplicant config.");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'key_mgmt' value 'NONE'");
|
||||
success = nm_supplicant_config_add_no_security (config);
|
||||
ASSERT (success == TRUE,
|
||||
"wifi-open", "failed to add wireless security to supplicant config.");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
hash = nm_supplicant_config_get_hash (config);
|
||||
ASSERT (hash != NULL,
|
||||
|
|
@ -272,16 +285,32 @@ test_wifi_wep_key (const char *detail,
|
|||
|
||||
config = nm_supplicant_config_new ();
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'ssid' value 'Test SSID'*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'scan_ssid' value '1'*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'bssid' value '11:22:33:44:55:66'*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'freq_list' value *");
|
||||
success = nm_supplicant_config_add_setting_wireless (config, s_wifi, 0);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to add wireless setting to supplicant config.");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'key_mgmt' value 'NONE'");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'wep_key0' value *");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'wep_tx_keyidx' value '0'");
|
||||
success = nm_supplicant_config_add_setting_wireless_security (config,
|
||||
s_wsec,
|
||||
NULL,
|
||||
"376aced7-b28c-46be-9a62-fcdf072571da");
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to add wireless security to supplicant config.");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
hash = nm_supplicant_config_get_hash (config);
|
||||
ASSERT (hash != NULL,
|
||||
|
|
@ -405,16 +434,36 @@ test_wifi_wpa_psk (const char *detail,
|
|||
|
||||
config = nm_supplicant_config_new ();
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'ssid' value 'Test SSID'*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'scan_ssid' value '1'*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'bssid' value '11:22:33:44:55:66'*");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'freq_list' value *");
|
||||
success = nm_supplicant_config_add_setting_wireless (config, s_wifi, 0);
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to add wireless setting to supplicant config.");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'key_mgmt' value 'WPA-PSK'");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'psk' value *");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'proto' value 'WPA RSN'");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'pairwise' value 'TKIP CCMP'");
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
|
||||
"*added 'group' value 'TKIP CCMP'");
|
||||
success = nm_supplicant_config_add_setting_wireless_security (config,
|
||||
s_wsec,
|
||||
NULL,
|
||||
"376aced7-b28c-46be-9a62-fcdf072571da");
|
||||
ASSERT (success == TRUE,
|
||||
detail, "failed to add wireless security to supplicant config.");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
hash = nm_supplicant_config_get_hash (config);
|
||||
ASSERT (hash != NULL,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ AM_CPPFLAGS = \
|
|||
-I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/libnm-util \
|
||||
-I$(top_builddir)/libnm-util \
|
||||
-I$(top_srcdir)/src/logging \
|
||||
-I$(top_srcdir)/src/platform \
|
||||
-I$(top_srcdir)/src/dhcp-manager \
|
||||
-I$(top_srcdir)/src \
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <nm-utils.h>
|
||||
|
||||
#include "nm-dhcp-manager.h"
|
||||
#include "nm-logging.h"
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
|
|
@ -97,8 +98,9 @@ static Option generic_options[] = {
|
|||
};
|
||||
|
||||
static void
|
||||
test_generic_options (const char *client)
|
||||
test_generic_options (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const NMPlatformIP4Address *address;
|
||||
|
|
@ -214,8 +216,9 @@ static Option wins_options[] = {
|
|||
};
|
||||
|
||||
static void
|
||||
test_wins_options (const char *client)
|
||||
test_wins_options (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const NMPlatformIP4Address *address;
|
||||
|
|
@ -295,8 +298,9 @@ ip4_test_gateway (const char *test,
|
|||
}
|
||||
|
||||
static void
|
||||
test_classless_static_routes_1 (const char *client)
|
||||
test_classless_static_routes_1 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
|
|
@ -328,8 +332,9 @@ test_classless_static_routes_1 (const char *client)
|
|||
}
|
||||
|
||||
static void
|
||||
test_classless_static_routes_2 (const char *client)
|
||||
test_classless_static_routes_2 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
|
|
@ -361,8 +366,9 @@ test_classless_static_routes_2 (const char *client)
|
|||
}
|
||||
|
||||
static void
|
||||
test_fedora_dhclient_classless_static_routes (const char *client)
|
||||
test_fedora_dhclient_classless_static_routes (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "129.210.177.128";
|
||||
|
|
@ -398,8 +404,9 @@ test_fedora_dhclient_classless_static_routes (const char *client)
|
|||
}
|
||||
|
||||
static void
|
||||
test_dhclient_invalid_classless_routes_1 (const char *client)
|
||||
test_dhclient_invalid_classless_routes_1 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
|
|
@ -413,9 +420,12 @@ test_dhclient_invalid_classless_routes_1 (const char *client)
|
|||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (data, options);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*ignoring invalid classless static routes*");
|
||||
ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-dhclient-classless-invalid-1", "failed to parse DHCP4 options");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
/* IP4 routes */
|
||||
ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
|
||||
|
|
@ -428,8 +438,9 @@ test_dhclient_invalid_classless_routes_1 (const char *client)
|
|||
}
|
||||
|
||||
static void
|
||||
test_dhcpcd_invalid_classless_routes_1 (const char *client)
|
||||
test_dhcpcd_invalid_classless_routes_1 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "10.1.1.5";
|
||||
|
|
@ -445,9 +456,12 @@ test_dhcpcd_invalid_classless_routes_1 (const char *client)
|
|||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (data, options);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*ignoring invalid classless static routes*");
|
||||
ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-dhcpcd-classless-invalid-1", "failed to parse DHCP4 options");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
/* Test falling back to old-style static routes if the classless static
|
||||
* routes are invalid.
|
||||
|
|
@ -463,8 +477,9 @@ test_dhcpcd_invalid_classless_routes_1 (const char *client)
|
|||
}
|
||||
|
||||
static void
|
||||
test_dhclient_invalid_classless_routes_2 (const char *client)
|
||||
test_dhclient_invalid_classless_routes_2 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "10.1.1.5";
|
||||
|
|
@ -479,9 +494,12 @@ test_dhclient_invalid_classless_routes_2 (const char *client)
|
|||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (data, options);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*ignoring invalid classless static routes*");
|
||||
ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-dhclient-classless-invalid-2", "failed to parse DHCP4 options");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
/* Test falling back to old-style static routes if the classless static
|
||||
* routes are invalid.
|
||||
|
|
@ -497,8 +515,9 @@ test_dhclient_invalid_classless_routes_2 (const char *client)
|
|||
}
|
||||
|
||||
static void
|
||||
test_dhcpcd_invalid_classless_routes_2 (const char *client)
|
||||
test_dhcpcd_invalid_classless_routes_2 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "10.1.1.5";
|
||||
|
|
@ -513,9 +532,12 @@ test_dhcpcd_invalid_classless_routes_2 (const char *client)
|
|||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (data, options);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*ignoring invalid classless static routes*");
|
||||
ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-dhcpcd-classless-invalid-2", "failed to parse DHCP4 options");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
/* Test falling back to old-style static routes if the classless static
|
||||
* routes are invalid.
|
||||
|
|
@ -533,8 +555,9 @@ test_dhcpcd_invalid_classless_routes_2 (const char *client)
|
|||
}
|
||||
|
||||
static void
|
||||
test_dhclient_invalid_classless_routes_3 (const char *client)
|
||||
test_dhclient_invalid_classless_routes_3 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
|
|
@ -547,9 +570,12 @@ test_dhclient_invalid_classless_routes_3 (const char *client)
|
|||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (data, options);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*ignoring invalid classless static routes*");
|
||||
ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-dhclient-classless-invalid-3", "failed to parse DHCP4 options");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
/* IP4 routes */
|
||||
ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
|
||||
|
|
@ -561,8 +587,9 @@ test_dhclient_invalid_classless_routes_3 (const char *client)
|
|||
}
|
||||
|
||||
static void
|
||||
test_dhcpcd_invalid_classless_routes_3 (const char *client)
|
||||
test_dhcpcd_invalid_classless_routes_3 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
|
|
@ -575,9 +602,12 @@ test_dhcpcd_invalid_classless_routes_3 (const char *client)
|
|||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (data, options);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*DHCP provided invalid classless static route*");
|
||||
ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-dhcpcd-classless-invalid-3", "failed to parse DHCP4 options");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
/* IP4 routes */
|
||||
ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
|
||||
|
|
@ -589,8 +619,9 @@ test_dhcpcd_invalid_classless_routes_3 (const char *client)
|
|||
}
|
||||
|
||||
static void
|
||||
test_dhclient_gw_in_classless_routes (const char *client)
|
||||
test_dhclient_gw_in_classless_routes (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
|
|
@ -621,8 +652,9 @@ test_dhclient_gw_in_classless_routes (const char *client)
|
|||
}
|
||||
|
||||
static void
|
||||
test_dhcpcd_gw_in_classless_routes (const char *client)
|
||||
test_dhcpcd_gw_in_classless_routes (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
|
|
@ -658,8 +690,9 @@ static Option escaped_searches_options[] = {
|
|||
};
|
||||
|
||||
static void
|
||||
test_escaped_domain_searches (const char *client)
|
||||
test_escaped_domain_searches (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const char *expected_search0 = "host1";
|
||||
|
|
@ -692,17 +725,21 @@ static Option invalid_escaped_searches_options[] = {
|
|||
};
|
||||
|
||||
static void
|
||||
test_invalid_escaped_domain_searches (const char *client)
|
||||
test_invalid_escaped_domain_searches (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
|
||||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (invalid_escaped_searches_options, options);
|
||||
|
||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||
"*invalid domain search*");
|
||||
ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind");
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-invalid-escaped-domain-searches", "failed to parse DHCP4 options");
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
/* domain searches */
|
||||
ASSERT (nm_ip4_config_get_num_searches (ip4_config) == 0,
|
||||
|
|
@ -741,8 +778,33 @@ test_ip4_missing_prefix (const char *client, const char *ip, guint32 expected_pr
|
|||
}
|
||||
|
||||
static void
|
||||
test_ip4_prefix_classless (const char *client)
|
||||
test_ip4_missing_prefix_24 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
|
||||
test_ip4_missing_prefix (client, "192.168.1.10", 24);
|
||||
}
|
||||
|
||||
static void
|
||||
test_ip4_missing_prefix_16 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
|
||||
test_ip4_missing_prefix (client, "172.16.54.50", 16);
|
||||
}
|
||||
|
||||
static void
|
||||
test_ip4_missing_prefix_8 (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
|
||||
test_ip4_missing_prefix (client, "10.1.2.3", 8);
|
||||
}
|
||||
|
||||
static void
|
||||
test_ip4_prefix_classless (gconstpointer test_data)
|
||||
{
|
||||
const char *client = test_data;
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
const NMPlatformIP4Address *address;
|
||||
|
|
@ -777,16 +839,21 @@ test_ip4_prefix_classless (const char *client)
|
|||
int main (int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
char *base;
|
||||
char *path;
|
||||
const char *clients[2][2] = { {DHCLIENT_PATH, "dhclient"}, {DHCPCD_PATH, "dhcpcd"} };
|
||||
guint32 i;
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
#if !GLIB_CHECK_VERSION(2,34,0)
|
||||
g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
|
||||
#endif
|
||||
|
||||
g_type_init ();
|
||||
|
||||
if (!nm_utils_init (&error))
|
||||
FAIL ("nm-utils-init", "failed to initialize libnm-util: %s", error->message);
|
||||
nm_logging_setup ("WARN", "DEFAULT", NULL, NULL);
|
||||
|
||||
/* The tests */
|
||||
for (i = 0; i < 2; i++) {
|
||||
const char *client_path = clients[i][0];
|
||||
const char *client = clients[i][1];
|
||||
|
|
@ -794,30 +861,83 @@ int main (int argc, char **argv)
|
|||
if (!client_path || !strlen (client_path))
|
||||
continue;
|
||||
|
||||
test_generic_options (client);
|
||||
test_wins_options (client);
|
||||
test_classless_static_routes_1 (client);
|
||||
test_classless_static_routes_2 (client);
|
||||
test_fedora_dhclient_classless_static_routes (client);
|
||||
test_dhclient_invalid_classless_routes_1 (client);
|
||||
test_dhcpcd_invalid_classless_routes_1 (client);
|
||||
test_dhclient_invalid_classless_routes_2 (client);
|
||||
test_dhcpcd_invalid_classless_routes_2 (client);
|
||||
test_dhclient_invalid_classless_routes_3 (client);
|
||||
test_dhcpcd_invalid_classless_routes_3 (client);
|
||||
test_dhclient_gw_in_classless_routes (client);
|
||||
test_dhcpcd_gw_in_classless_routes (client);
|
||||
test_escaped_domain_searches (client);
|
||||
test_invalid_escaped_domain_searches (client);
|
||||
test_ip4_missing_prefix (client, "192.168.1.10", 24);
|
||||
test_ip4_missing_prefix (client, "172.16.54.50", 16);
|
||||
test_ip4_missing_prefix (client, "10.1.2.3", 8);
|
||||
test_ip4_prefix_classless (client);
|
||||
path = g_strdup_printf ("/dhcp/%s/generic-options", client);
|
||||
g_test_add_data_func (path, client, test_generic_options);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/wins-options", client);
|
||||
g_test_add_data_func (path, client, test_wins_options);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/classless-static-routes-1", client);
|
||||
g_test_add_data_func (path, client, test_classless_static_routes_1);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/classless-static-routes-2", client);
|
||||
g_test_add_data_func (path, client, test_classless_static_routes_2);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/fedora-dhclient-classless-static-routes", client);
|
||||
g_test_add_data_func (path, client, test_fedora_dhclient_classless_static_routes);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/dhclient-invalid-classless-routes-1", client);
|
||||
g_test_add_data_func (path, client, test_dhclient_invalid_classless_routes_1);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/dhcpcd-invalid-classless-routes-1", client);
|
||||
g_test_add_data_func (path, client, test_dhcpcd_invalid_classless_routes_1);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/dhclient-invalid-classless-routes-2", client);
|
||||
g_test_add_data_func (path, client, test_dhclient_invalid_classless_routes_2);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/dhcpcd-invalid-classless-routes-2", client);
|
||||
g_test_add_data_func (path, client, test_dhcpcd_invalid_classless_routes_2);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/dhclient-invalid-classless-routes-3", client);
|
||||
g_test_add_data_func (path, client, test_dhclient_invalid_classless_routes_3);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/dhcpcd-invalid-classless-routes-3", client);
|
||||
g_test_add_data_func (path, client, test_dhcpcd_invalid_classless_routes_3);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/dhclient-gw-in-classless-routes", client);
|
||||
g_test_add_data_func (path, client, test_dhclient_gw_in_classless_routes);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/dhcpcd-gw-in-classless-routes", client);
|
||||
g_test_add_data_func (path, client, test_dhcpcd_gw_in_classless_routes);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/escaped-domain-searches", client);
|
||||
g_test_add_data_func (path, client, test_escaped_domain_searches);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/invalid-escaped-domain-searches", client);
|
||||
g_test_add_data_func (path, client, test_invalid_escaped_domain_searches);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/ip4-missing-prefix-24", client);
|
||||
g_test_add_data_func (path, client, test_ip4_missing_prefix_24);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/ip4-missing-prefix-16", client);
|
||||
g_test_add_data_func (path, client, test_ip4_missing_prefix_16);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/ip4-missing-prefix-8", client);
|
||||
g_test_add_data_func (path, client, test_ip4_missing_prefix_8);
|
||||
g_free (path);
|
||||
|
||||
path = g_strdup_printf ("/dhcp/%s/ip4-prefix-classless", client);
|
||||
g_test_add_data_func (path, client, test_ip4_prefix_classless);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
base = g_path_get_basename (argv[0]);
|
||||
fprintf (stdout, "%s: SUCCESS\n", base);
|
||||
g_free (base);
|
||||
return 0;
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue