Commit 25ade397 authored by Thomas Haller's avatar Thomas Haller

tests: use NMTST_EXPECT*() macros

Tests are commonly created via copy&paste. Hence, it's
better to express a certain concept explicitly via a function
or macro. This way, the implementation of the concept can be
adjusted at one place, without requiring to change all the callers.

Also, the macro is shorter, and brevity is better for tests
so it's easier to understand what the test does. Without being
bothered by noise from the redundant information.

Also, the macro knows better which message to expect. For example,
messages inside "src" are prepended by nm-logging.c with a level
and a timestamp. The expect macro is aware of that and tests for it

  #define NMTST_EXPECT_NM_ERROR(msg)      NMTST_EXPECT_NM (G_LOG_LEVEL_MESSAGE, "*<error> [*] "msg)

This again allows the caller to ignore this prefix, but still assert
more strictly.
parent 66b80bd6
This diff is collapsed.
......@@ -651,8 +651,7 @@ test_update_secrets_null_setting_name_with_setting_hash (void)
secrets = build_wep_secrets (wepkey);
g_test_expect_message ("libnm", G_LOG_LEVEL_CRITICAL,
NMTST_G_RETURN_MSG (setting_name != NULL || full_connection));
NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (setting_name != NULL || full_connection));
success = nm_connection_update_secrets (connection, NULL, secrets, &error);
g_test_assert_expected_messages ();
g_assert_no_error (error);
......
......@@ -663,23 +663,23 @@ test_dcb_flags_invalid (void)
s_dcb = (NMSettingDcb *) nm_setting_dcb_new ();
g_assert (s_dcb);
g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
TEST_FLAG (NM_SETTING_DCB_APP_FCOE_FLAGS, nm_setting_dcb_get_app_fcoe_flags, 0x332523);
g_test_assert_expected_messages ();
g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
TEST_FLAG (NM_SETTING_DCB_APP_ISCSI_FLAGS, nm_setting_dcb_get_app_iscsi_flags, 0xFF);
g_test_assert_expected_messages ();
g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
TEST_FLAG (NM_SETTING_DCB_APP_FIP_FLAGS, nm_setting_dcb_get_app_fip_flags, 0x1111);
g_test_assert_expected_messages ();
g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
TEST_FLAG (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, nm_setting_dcb_get_priority_flow_control_flags, G_MAXUINT32);
g_test_assert_expected_messages ();
g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
TEST_FLAG (NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, nm_setting_dcb_get_priority_group_flags,
(NM_SETTING_DCB_FLAG_ENABLE | NM_SETTING_DCB_FLAG_ADVERTISE | NM_SETTING_DCB_FLAG_WILLING) + 1);
g_test_assert_expected_messages ();
......
This diff is collapsed.
......@@ -96,23 +96,23 @@ test_dcb_flags_invalid (void)
s_dcb = (NMSettingDcb *) nm_setting_dcb_new ();
g_assert (s_dcb);
g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
TEST_FLAG (NM_SETTING_DCB_APP_FCOE_FLAGS, nm_setting_dcb_get_app_fcoe_flags, 0x332523);
g_test_assert_expected_messages ();
g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
TEST_FLAG (NM_SETTING_DCB_APP_ISCSI_FLAGS, nm_setting_dcb_get_app_iscsi_flags, 0xFF);
g_test_assert_expected_messages ();
g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
TEST_FLAG (NM_SETTING_DCB_APP_FIP_FLAGS, nm_setting_dcb_get_app_fip_flags, 0x1111);
g_test_assert_expected_messages ();
g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
TEST_FLAG (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, nm_setting_dcb_get_priority_flow_control_flags, G_MAXUINT32);
g_test_assert_expected_messages ();
g_test_expect_message ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
NMTST_EXPECT ("GLib-GObject", G_LOG_LEVEL_WARNING, "*invalid or out of range*");
TEST_FLAG (NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, nm_setting_dcb_get_priority_group_flags,
(NM_SETTING_DCB_FLAG_ENABLE | NM_SETTING_DCB_FLAG_ADVERTISE | NM_SETTING_DCB_FLAG_WILLING) + 1);
g_test_assert_expected_messages ();
......
......@@ -349,8 +349,7 @@ test_dhclient_invalid_classless_routes_1 (void)
options = fill_table (generic_options, NULL);
options = fill_table (data, options);
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*ignoring invalid classless static routes*");
NMTST_EXPECT_NM_WARN ("*ignoring invalid classless static routes*");
ip4_config = _ip4_config_from_options (1, "eth0", options, 0);
g_test_assert_expected_messages ();
......@@ -380,8 +379,7 @@ test_dhcpcd_invalid_classless_routes_1 (void)
options = fill_table (generic_options, NULL);
options = fill_table (data, options);
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*ignoring invalid classless static routes*");
NMTST_EXPECT_NM_WARN ("*ignoring invalid classless static routes*");
ip4_config = _ip4_config_from_options (1, "eth0", options, 0);
g_test_assert_expected_messages ();
......@@ -413,8 +411,7 @@ test_dhclient_invalid_classless_routes_2 (void)
options = fill_table (generic_options, NULL);
options = fill_table (data, options);
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*ignoring invalid classless static routes*");
NMTST_EXPECT_NM_WARN ("*ignoring invalid classless static routes*");
ip4_config = _ip4_config_from_options (1, "eth0", options, 0);
g_test_assert_expected_messages ();
......@@ -446,8 +443,7 @@ test_dhcpcd_invalid_classless_routes_2 (void)
options = fill_table (generic_options, NULL);
options = fill_table (data, options);
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*ignoring invalid classless static routes*");
NMTST_EXPECT_NM_WARN ("*ignoring invalid classless static routes*");
ip4_config = _ip4_config_from_options (1, "eth0", options, 0);
g_test_assert_expected_messages ();
......@@ -479,8 +475,7 @@ test_dhclient_invalid_classless_routes_3 (void)
options = fill_table (generic_options, NULL);
options = fill_table (data, options);
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*ignoring invalid classless static routes*");
NMTST_EXPECT_NM_WARN ("*ignoring invalid classless static routes*");
ip4_config = _ip4_config_from_options (1, "eth0", options, 0);
g_test_assert_expected_messages ();
......@@ -507,8 +502,7 @@ test_dhcpcd_invalid_classless_routes_3 (void)
options = fill_table (generic_options, NULL);
options = fill_table (data, options);
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*DHCP provided invalid classless static route*");
NMTST_EXPECT_NM_WARN ("*DHCP provided invalid classless static route*");
ip4_config = _ip4_config_from_options (1, "eth0", options, 0);
g_test_assert_expected_messages ();
......@@ -615,8 +609,7 @@ test_invalid_escaped_domain_searches (void)
options = fill_table (generic_options, NULL);
options = fill_table (data, options);
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*invalid domain search*");
NMTST_EXPECT_NM_WARN ("*invalid domain search*");
ip4_config = _ip4_config_from_options (1, "eth0", options, 0);
g_test_assert_expected_messages ();
......
......@@ -181,7 +181,7 @@ test_read_ibft_malformed (gconstpointer user_data)
g_assert (g_file_test (iscsiadm_path, G_FILE_TEST_EXISTS));
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*malformed iscsiadm record*");
NMTST_EXPECT_NM_WARN ("*malformed iscsiadm record*");
success = nms_ibft_reader_load_blocks (iscsiadm_path, &blocks, &error);
g_assert_no_error (error);
......
......@@ -605,8 +605,7 @@ test_read_miscellaneous_variables (void)
int mac_blacklist_num, i;
guint64 expected_timestamp = 0;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*invalid MAC in HWADDR_BLACKLIST 'XX:aa:invalid'*");
NMTST_EXPECT_NM_WARN ("*invalid MAC in HWADDR_BLACKLIST 'XX:aa:invalid'*");
connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-misc-variables",
NULL, TYPE_ETHERNET, NULL);
g_test_assert_expected_messages ();
......@@ -859,8 +858,7 @@ 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_MESSAGE,
"*missing PREFIX, assuming*");
NMTST_EXPECT_NM_WARN ("*missing PREFIX, assuming*");
connection = _connection_from_file (file, NULL, TYPE_ETHERNET, NULL);
g_test_assert_expected_messages ();
......@@ -1081,8 +1079,7 @@ test_read_wired_global_gateway_ignore (void)
NMSettingIPConfig *s_ip4;
char *unmanaged = NULL;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*ignoring GATEWAY (/etc/sysconfig/network) for * because the connection has no static addresses");
NMTST_EXPECT_NM_WARN ("*ignoring GATEWAY (/etc/sysconfig/network) for * because the connection has no static addresses");
connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-global-gateway-ignore",
TEST_IFCFG_DIR"/network-scripts/network-test-wired-global-gateway-ignore",
TYPE_ETHERNET, &unmanaged);
......@@ -1513,8 +1510,7 @@ test_read_wired_ipv6_manual (void)
NMIPAddress *ip6_addr;
NMIPRoute *ip6_route;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*ignoring manual default route*");
NMTST_EXPECT_NM_WARN ("*ignoring manual default route*");
connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wired-ipv6-manual",
NULL, TYPE_ETHERNET, &unmanaged);
g_test_assert_expected_messages ();
......@@ -1897,8 +1893,7 @@ test_read_write_802_1X_subj_matches (void)
gs_unref_object NMConnection *reread = NULL;
NMSetting8021x *s_8021x;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*missing IEEE_8021X_CA_CERT*peap*");
NMTST_EXPECT_NM_WARN ("*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);
g_test_assert_expected_messages ();
......@@ -1919,16 +1914,14 @@ test_read_write_802_1X_subj_matches (void)
g_assert_cmpstr (nm_setting_802_1x_get_phase2_altsubject_match (s_8021x, 0), ==, "x.yourdomain.tld");
g_assert_cmpstr (nm_setting_802_1x_get_phase2_altsubject_match (s_8021x, 1), ==, "y.yourdomain.tld");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*missing IEEE_8021X_CA_CERT for EAP method 'peap'; this is insecure!");
NMTST_EXPECT_NM_WARN ("*missing IEEE_8021X_CA_CERT for EAP method 'peap'; this is insecure!");
_writer_new_connec_exp (connection,
TEST_SCRATCH_DIR "/network-scripts/",
TEST_IFCFG_DIR "/network-scripts/ifcfg-System_test-wired-802-1X-subj-matches.cexpected",
&testfile);
g_test_assert_expected_messages ();
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*missing IEEE_8021X_CA_CERT for EAP method 'peap'; this is insecure!");
NMTST_EXPECT_NM_WARN ("*missing IEEE_8021X_CA_CERT for EAP method 'peap'; this is insecure!");
reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET, NULL);
g_test_assert_expected_messages ();
......@@ -2142,16 +2135,14 @@ test_read_wired_aliases_bad (const char *base, const char *expected_id)
static void
test_read_wired_aliases_bad_1 (void)
{
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*aliasem1:1*has no DEVICE*");
NMTST_EXPECT_NM_WARN ("*aliasem1:1*has no DEVICE*");
test_read_wired_aliases_bad (TEST_IFCFG_DIR "/network-scripts/ifcfg-aliasem1", "System aliasem1");
}
static void
test_read_wired_aliases_bad_2 (void)
{
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*aliasem2:1*has invalid DEVICE*");
NMTST_EXPECT_NM_WARN ("*aliasem2:1*has invalid DEVICE*");
test_read_wired_aliases_bad (TEST_IFCFG_DIR "/network-scripts/ifcfg-aliasem2", "System aliasem2");
}
......@@ -7713,8 +7704,7 @@ test_read_vlan_reorder_hdr_1 (void)
NMConnection *connection;
NMSettingVlan *s_vlan;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*REORDER_HDR key is deprecated, use VLAN_FLAGS*");
NMTST_EXPECT_NM_WARN ("*REORDER_HDR key is deprecated, use VLAN_FLAGS*");
connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-reorder-hdr-1",
NULL, TYPE_ETHERNET, NULL);
g_test_assert_expected_messages ();
......@@ -8508,8 +8498,7 @@ test_read_dcb_bad_booleans (void)
{
gs_free_error GError *error = NULL;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*invalid DCB_PG_STRICT value*not all 0s and 1s*");
NMTST_EXPECT_NM_WARN ("*invalid DCB_PG_STRICT value*not all 0s and 1s*");
_connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-booleans",
NULL, TYPE_ETHERNET, &error);
g_test_assert_expected_messages ();
......@@ -8523,8 +8512,7 @@ test_read_dcb_short_booleans (void)
{
gs_free_error GError *error = NULL;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*DCB_PG_STRICT value*8 characters*");
NMTST_EXPECT_NM_WARN ("*DCB_PG_STRICT value*8 characters*");
_connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-booleans",
NULL, TYPE_ETHERNET, &error);
g_test_assert_expected_messages ();
......@@ -8538,8 +8526,7 @@ test_read_dcb_bad_uints (void)
{
gs_free_error GError *error = NULL;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*invalid DCB_PG_UP2TC value*not 0 - 7*");
NMTST_EXPECT_NM_WARN ("*invalid DCB_PG_UP2TC value*not 0 - 7*");
_connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-uints",
NULL, TYPE_ETHERNET, &error);
g_test_assert_expected_messages ();
......@@ -8553,8 +8540,7 @@ test_read_dcb_short_uints (void)
{
gs_free_error GError *error = NULL;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*DCB_PG_UP2TC value*8 characters*");
NMTST_EXPECT_NM_WARN ("*DCB_PG_UP2TC value*8 characters*");
_connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-uints",
NULL, TYPE_ETHERNET, &error);
g_test_assert_expected_messages ();
......@@ -8568,8 +8554,7 @@ test_read_dcb_bad_percent (void)
{
gs_free_error GError *error = NULL;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*invalid DCB_PG_PCT percentage value*");
NMTST_EXPECT_NM_WARN ("*invalid DCB_PG_PCT percentage value*");
_connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-bad-percent",
NULL, TYPE_ETHERNET, &error);
g_test_assert_expected_messages ();
......@@ -8583,8 +8568,7 @@ test_read_dcb_short_percent (void)
{
gs_free_error GError *error = NULL;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*invalid DCB_PG_PCT percentage list value*");
NMTST_EXPECT_NM_WARN ("*invalid DCB_PG_PCT percentage list value*");
_connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-short-percent",
NULL, TYPE_ETHERNET, &error);
g_test_assert_expected_messages ();
......@@ -8598,8 +8582,7 @@ test_read_dcb_pgpct_not_100 (void)
{
gs_free_error GError *error = NULL;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*DCB_PG_PCT percentages do not equal 100*");
NMTST_EXPECT_NM_WARN ("*DCB_PG_PCT percentages do not equal 100*");
_connection_from_file_fail (TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dcb-pgpct-not-100",
NULL, TYPE_ETHERNET, &error);
g_test_assert_expected_messages ();
......@@ -8720,7 +8703,7 @@ test_read_team_master_invalid (gconstpointer user_data)
NMSettingConnection *s_con;
NMSettingTeam *s_team;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*ignoring invalid team configuration*");
NMTST_EXPECT_NM_WARN ("*ignoring invalid team configuration*");
connection = _connection_from_file (PATH_NAME, NULL, TYPE_ETHERNET, NULL);
g_test_assert_expected_messages ();
......
......@@ -231,34 +231,20 @@ test_read_valid_wired_connection (void)
char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
gboolean success;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv4.addresses:*semicolon at the end*addresses1*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv4.addresses:*semicolon at the end*addresses2*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*missing prefix length*address4*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*missing prefix length*address5*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv4.routes*semicolon at the end*routes2*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv4.routes*semicolon at the end*routes3*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv4.routes*semicolon at the end*routes5*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv4.routes*semicolon at the end*routes8*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*missing prefix length*address4*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv6.address*semicolon at the end*address5*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*missing prefix length*address5*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv6.address*semicolon at the end*address7*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv6.routes*semicolon at the end*routes1*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv6.route*semicolon at the end*route6*");
NMTST_EXPECT_NM_INFO ("*ipv4.addresses:*semicolon at the end*addresses1*");
NMTST_EXPECT_NM_INFO ("*ipv4.addresses:*semicolon at the end*addresses2*");
NMTST_EXPECT_NM_WARN ("*missing prefix length*address4*");
NMTST_EXPECT_NM_WARN ("*missing prefix length*address5*");
NMTST_EXPECT_NM_INFO ("*ipv4.routes*semicolon at the end*routes2*");
NMTST_EXPECT_NM_INFO ("*ipv4.routes*semicolon at the end*routes3*");
NMTST_EXPECT_NM_INFO ("*ipv4.routes*semicolon at the end*routes5*");
NMTST_EXPECT_NM_INFO ("*ipv4.routes*semicolon at the end*routes8*");
NMTST_EXPECT_NM_WARN ("*missing prefix length*address4*");
NMTST_EXPECT_NM_INFO ("*ipv6.address*semicolon at the end*address5*");
NMTST_EXPECT_NM_WARN ("*missing prefix length*address5*");
NMTST_EXPECT_NM_INFO ("*ipv6.address*semicolon at the end*address7*");
NMTST_EXPECT_NM_INFO ("*ipv6.routes*semicolon at the end*routes1*");
NMTST_EXPECT_NM_INFO ("*ipv6.route*semicolon at the end*route6*");
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection", &error);
g_assert_no_error (error);
g_test_assert_expected_messages ();
......@@ -649,12 +635,9 @@ test_read_wired_mac_case (void)
char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0xaa, 0xbb, 0xcc, 0x55 };
gboolean success;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv4.addresses*semicolon at the end*addresses1*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv4.addresses*semicolon at the end*addresses2*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO,
"*ipv6.routes*semicolon at the end*routes1*");
NMTST_EXPECT_NM_INFO ("*ipv4.addresses*semicolon at the end*addresses1*");
NMTST_EXPECT_NM_INFO ("*ipv4.addresses*semicolon at the end*addresses2*");
NMTST_EXPECT_NM_INFO ("*ipv6.routes*semicolon at the end*routes1*");
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_MAC_Case", NULL);
g_test_assert_expected_messages ();
g_assert (connection);
......@@ -1415,10 +1398,8 @@ test_read_wired_8021x_tls_blob_connection (void)
gboolean success;
GBytes *blob;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*<warn> * keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*<warn> * keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
NMTST_EXPECT_NM_WARN ("keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
NMTST_EXPECT_NM_WARN ("keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Blob", &error);
g_assert_no_error (error);
g_assert (connection);
......@@ -1447,8 +1428,7 @@ 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", G_LOG_LEVEL_CRITICAL,
NMTST_G_RETURN_MSG (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH));
NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (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);
......@@ -1476,8 +1456,7 @@ test_read_wired_8021x_tls_bad_path_connection (void)
char *tmp2;
gboolean success;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*does not exist*");
NMTST_EXPECT_NM_WARN ("*does not exist*");
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Path_Missing", &error);
g_test_assert_expected_messages ();
g_assert_no_error (error);
......@@ -1530,12 +1509,9 @@ test_read_wired_8021x_tls_old_connection (void)
const char *tmp;
gboolean success;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*<warn> * keyfile: 802-1x.ca-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/CA/eaptest_ca_cert.pem' does not exist*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*<warn> * keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE,
"*<warn> * keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
NMTST_EXPECT_NM_WARN ("keyfile: 802-1x.ca-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/CA/eaptest_ca_cert.pem' does not exist*");
NMTST_EXPECT_NM_WARN ("keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
NMTST_EXPECT_NM_WARN ("keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*");
connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Old", &error);
g_assert_no_error (error);
g_assert (connection);
......
......@@ -140,7 +140,6 @@ build_supplicant_config (NMConnection *connection, guint mtu, guint fixed_freq)
return nm_supplicant_config_to_variant (config);
}
#define EXPECT(msg) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, msg)
static NMConnection *
new_basic_connection (const char *id,
......@@ -199,11 +198,11 @@ test_wifi_open (void)
g_assert_no_error (error);
g_assert (success);
EXPECT ("*added 'ssid' value 'Test SSID'*");
EXPECT ("*added 'scan_ssid' value '1'*");
EXPECT ("*added 'bssid' value '11:22:33:44:55:66'*");
EXPECT ("*added 'freq_list' value *");
EXPECT ("*added 'key_mgmt' value 'NONE'");
NMTST_EXPECT_NM_INFO ("Config: added 'ssid' value 'Test SSID'*");
NMTST_EXPECT_NM_INFO ("Config: added 'scan_ssid' value '1'*");
NMTST_EXPECT_NM_INFO ("Config: added 'bssid' value '11:22:33:44:55:66'*");
NMTST_EXPECT_NM_INFO ("Config: added 'freq_list' value *");
NMTST_EXPECT_NM_INFO ("Config: added 'key_mgmt' value 'NONE'");
config_dict = build_supplicant_config (connection, 1500, 0);
g_test_assert_expected_messages ();
g_assert (config_dict);
......@@ -249,17 +248,17 @@ test_wifi_wep_key (const char *detail,
g_assert_no_error (error);
g_assert (success);
EXPECT ("*added 'ssid' value 'Test SSID'*");
EXPECT ("*added 'scan_ssid' value '1'*");
NMTST_EXPECT_NM_INFO ("Config: added 'ssid' value 'Test SSID'*");
NMTST_EXPECT_NM_INFO ("Config: added 'scan_ssid' value '1'*");
if (test_bssid)
EXPECT ("*added 'bssid' value '11:22:33:44:55:66'*");
NMTST_EXPECT_NM_INFO ("Config: added 'bssid' value '11:22:33:44:55:66'*");
EXPECT ("*added 'freq_list' value *");
EXPECT ("*added 'key_mgmt' value 'NONE'");
EXPECT ("*added 'wep_key0' value *");
EXPECT ("*added 'wep_tx_keyidx' value '0'");
NMTST_EXPECT_NM_INFO ("Config: added 'freq_list' value *");
NMTST_EXPECT_NM_INFO ("Config: added 'key_mgmt' value 'NONE'");
NMTST_EXPECT_NM_INFO ("Config: added 'wep_key0' value *");
NMTST_EXPECT_NM_INFO ("Config: added 'wep_tx_keyidx' value '0'");
if (!test_bssid)
EXPECT ("*added 'bgscan' value 'simple:30:-80:86400'*");
NMTST_EXPECT_NM_INFO ("Config: added 'bgscan' value 'simple:30:-80:86400'*");
config_dict = build_supplicant_config (connection, 1500, 0);
g_test_assert_expected_messages ();
......@@ -341,16 +340,16 @@ test_wifi_wpa_psk (const char *detail,
g_assert_no_error (error);
g_assert (success);
EXPECT ("*added 'ssid' value 'Test SSID'*");
EXPECT ("*added 'scan_ssid' value '1'*");
EXPECT ("*added 'bssid' value '11:22:33:44:55:66'*");
EXPECT ("*added 'freq_list' value *");
EXPECT ("*added 'key_mgmt' value 'WPA-PSK WPA-PSK-SHA256'");
EXPECT ("*added 'psk' value *");
EXPECT ("*added 'proto' value 'WPA RSN'");
EXPECT ("*added 'pairwise' value 'TKIP CCMP'");
EXPECT ("*added 'group' value 'TKIP CCMP'");
EXPECT ("*added 'ieee80211w' value '1'");
NMTST_EXPECT_NM_INFO ("Config: added 'ssid' value 'Test SSID'*");
NMTST_EXPECT_NM_INFO ("Config: added 'scan_ssid' value '1'*");
NMTST_EXPECT_NM_INFO ("Config: added 'bssid' value '11:22:33:44:55:66'*");
NMTST_EXPECT_NM_INFO ("Config: added 'freq_list' value *");
NMTST_EXPECT_NM_INFO ("Config: added 'key_mgmt' value 'WPA-PSK WPA-PSK-SHA256'");
NMTST_EXPECT_NM_INFO ("Config: added 'psk' value *");
NMTST_EXPECT_NM_INFO ("Config: added 'proto' value 'WPA RSN'");
NMTST_EXPECT_NM_INFO ("Config: added 'pairwise' value 'TKIP CCMP'");
NMTST_EXPECT_NM_INFO ("Config: added 'group' value 'TKIP CCMP'");
NMTST_EXPECT_NM_INFO ("Config: added 'ieee80211w' value '1'");
config_dict = build_supplicant_config (connection, 1500, 0);
g_test_assert_expected_messages ();
......@@ -436,19 +435,19 @@ test_wifi_eap_locked_bssid (void)
connection = generate_wifi_eap_connection ("Test Wifi EAP-TLS Locked", ssid, bssid_str);
EXPECT ("*added 'ssid' value 'Test SSID'*");
EXPECT ("*added 'scan_ssid' value '1'*");
EXPECT ("*added 'bssid' value '11:22:33:44:55:66'*");
EXPECT ("*added 'freq_list' value *");
EXPECT ("*added 'key_mgmt' value 'WPA-EAP'");
EXPECT ("*added 'proto' value 'WPA RSN'");
EXPECT ("*added 'pairwise' value 'TKIP CCMP'");
EXPECT ("*added 'group' value 'TKIP CCMP'");
EXPECT ("*Config: added 'eap' value 'TLS'");
EXPECT ("*Config: added 'fragment_size' value '1086'");
EXPECT ("* Config: added 'ca_cert' value '*/test-ca-cert.pem'");
EXPECT ("* Config: added 'private_key' value '*/test-cert.p12'");
EXPECT ("*Config: added 'proactive_key_caching' value '1'");
NMTST_EXPECT_NM_INFO ("Config: added 'ssid' value 'Test SSID'*");
NMTST_EXPECT_NM_INFO ("Config: added 'scan_ssid' value '1'*");
NMTST_EXPECT_NM_INFO ("Config: added 'bssid' value '11:22:33:44:55:66'*");
NMTST_EXPECT_NM_INFO ("Config: added 'freq_list' value *");
NMTST_EXPECT_NM_INFO ("Config: added 'key_mgmt' value 'WPA-EAP'");
NMTST_EXPECT_NM_INFO ("Config: added 'proto' value 'WPA RSN'");
NMTST_EXPECT_NM_INFO ("Config: added 'pairwise' value 'TKIP CCMP'");
NMTST_EXPECT_NM_INFO ("Config: added 'group' value 'TKIP CCMP'");
NMTST_EXPECT_NM_INFO ("Config: added 'eap' value 'TLS'");
NMTST_EXPECT_NM_INFO ("Config: added 'fragment_size' value '1086'");
NMTST_EXPECT_NM_INFO ("Config: added 'ca_cert' value '*/test-ca-cert.pem'");
NMTST_EXPECT_NM_INFO ("Config: added 'private_key' value '*/test-cert.p12'");
NMTST_EXPECT_NM_INFO ("Config: added 'proactive_key_caching' value '1'");
config_dict = build_supplicant_config (connection, mtu, 0);
g_test_assert_expected_messages ();
g_assert (config_dict);
......@@ -477,19 +476,19 @@ test_wifi_eap_unlocked_bssid (void)
connection = generate_wifi_eap_connection ("Test Wifi EAP-TLS Unlocked", ssid, NULL);
EXPECT ("*added 'ssid' value 'Test SSID'*");
EXPECT ("*added 'scan_ssid' value '1'*");
EXPECT ("*added 'freq_list' value *");
EXPECT ("*added 'key_mgmt' value 'WPA-EAP'");
EXPECT ("*added 'proto' value 'WPA RSN'");
EXPECT ("*added 'pairwise' value 'TKIP CCMP'");
EXPECT ("*added 'group' value 'TKIP CCMP'");
EXPECT ("*Config: added 'eap' value 'TLS'");
EXPECT ("*Config: added 'fragment_size' value '1086'");
EXPECT ("* Config: added 'ca_cert' value '*/test-ca-cert.pem'");
EXPECT ("* Config: added 'private_key' value '*/test-cert.p12'");
EXPECT ("*Config: added 'proactive_key_caching' value '1'");
EXPECT ("*Config: added 'bgscan' value 'simple:30:-65:300'");
NMTST_EXPECT_NM_INFO ("Config: added 'ssid' value 'Test SSID'*");
NMTST_EXPECT_NM_INFO ("Config: added 'scan_ssid' value '1'*");
NMTST_EXPECT_NM_INFO ("Config: added 'freq_list' value *");
NMTST_EXPECT_NM_INFO ("Config: added 'key_mgmt' value 'WPA-EAP'");
NMTST_EXPECT_NM_INFO ("Config: added 'proto' value 'WPA RSN'");
NMTST_EXPECT_NM_INFO ("Config: added 'pairwise' value 'TKIP CCMP'");
NMTST_EXPECT_NM_INFO ("Config: added 'group' value 'TKIP CCMP'");
NMTST_EXPECT_NM_INFO ("Config: added 'eap' value 'TLS'");
NMTST_EXPECT_NM_INFO ("Config: added 'fragment_size' value '1086'");
NMTST_EXPECT_NM_INFO ("Config: added 'ca_cert' value '*/test-ca-cert.pem'");
NMTST_EXPECT_NM_INFO ("Config: added 'private_key' value '*/test-cert.p12'");
NMTST_EXPECT_NM_INFO ("Config: added 'proactive_key_caching' value '1'");
NMTST_EXPECT_NM_INFO ("Config: added 'bgscan' value 'simple:30:-65:300'");
config_dict = build_supplicant_config (connection, mtu, 0);
g_test_assert_expected_messages ();
g_assert (config_dict);
......
......@@ -334,14 +334,14 @@ test_config_connectivity_check (void)
g_assert (nm_connectivity_check_enabled (connectivity));
/* disable connectivity checking */
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*config: signal: *");
NMTST_EXPECT_NM_INFO ("config: signal: *");
nm_config_set_connectivity_check_enabled (config, FALSE);
g_test_assert_expected_messages ();
g_assert (!nm_connectivity_check_enabled (connectivity));
/* re-enable connectivity checking */
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*config: signal: *");
NMTST_EXPECT_NM_INFO ("config: signal: *");
nm_config_set_connectivity_check_enabled (config, TRUE);
g_test_assert_expected_messages ();
......@@ -386,7 +386,7 @@ test_config_no_auto_default (void)
g_assert (!nm_config_get_no_auto_default_for_device (config, dev3));
g_assert (nm_config_get_no_auto_default_for_device (config, dev4));
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*config: signal: NO_AUTO_DEFAULT,no-auto-default *");
NMTST_EXPECT_NM_INFO ("config: signal: NO_AUTO_DEFAULT,no-auto-default *");
nm_config_set_no_auto_default_for_device (config, dev3);
g_test_assert_expected_messages ();
......@@ -597,9 +597,9 @@ _set_values_user (NMConfig *config,
config_data_before = g_object_ref (nm_config_get_data (config));
if (expected_changes != NM_CONFIG_CHANGE_NONE)
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*config: signal: *");
NMTST_EXPECT_NM_INFO ("config: signal: *");
else
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*config: signal: SIGHUP (no changes from disk)*");
NMTST_EXPECT_NM_INFO ("config: signal: SIGHUP (no changes from disk)*");
nm_config_reload (config, NM_CONFIG_CHANGE_CAUSE_SIGHUP);
......@@ -641,7 +641,7 @@ _set_values_intern (NMConfig *config,
&config_changed_data);
if (expected_changes != NM_CONFIG_CHANGE_NONE)
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*config: signal: *");
NMTST_EXPECT_NM_INFO ("config: signal: *");
nm_config_set_values (config, keyfile_intern, TRUE, FALSE);
......@@ -904,15 +904,15 @@ test_config_signal (void)
&expected);
expected = NM_CONFIG_CHANGE_CAUSE_SIGUSR1;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*config: signal: SIGUSR1");
NMTST_EXPECT_NM_INFO ("config: signal: SIGUSR1");
nm_config_reload (config, expected);
expected = NM_CONFIG_CHANGE_CAUSE_SIGUSR2;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*config: signal: SIGUSR2");
NMTST_EXPECT_NM_INFO ("config: signal: SIGUSR2");
nm_config_reload (config, expected);
expected = NM_CONFIG_CHANGE_CAUSE_SIGHUP;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*config: signal: SIGHUP (no changes from disk)*");
NMTST_EXPECT_NM_INFO ("config: signal: SIGHUP (no changes from disk)*");
nm_config_reload (config, expected);
......@@ -925,7 +925,7 @@ test_config_signal (void)
G_CALLBACK (_test_signal_config_changed_cb2),
&expected);
expected = NM_CONFIG_CHANGE_CAUSE_SIGUSR2;
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*config: signal: SIGUSR2");
NMTST_EXPECT_NM_INFO ("config: signal: SIGUSR2");
nm_config_reload (config, NM_CONFIG_CHANGE_CAUSE_SIGUSR2);
g_signal_handlers_disconnect_by_func (config, _test_signal_config_changed_cb2, &expected);
......
This diff is collapsed.
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