From aeefde7513b34bfa367d73e8ced29f13e223ee0c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 14 Feb 2014 10:04:33 -0600 Subject: [PATCH] ifcfg-rh: add testcase for empty Team port config Add testcase for 3e70fb20d4aabcdc3d874ae32f31a17eb5c76f60. --- .../tests/network-scripts/Makefile.am | 3 +- .../ifcfg-test-team-port-empty-config | 4 +++ .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 28 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-team-port-empty-config diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am index d13f5621d..d63354f69 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -112,7 +112,8 @@ EXTRA_DIST = \ ifcfg-test-fcoe-fabric \ ifcfg-test-fcoe-vn2vn \ ifcfg-test-team-master \ - ifcfg-test-team-port + ifcfg-test-team-port \ + ifcfg-test-team-port-empty-config check-local: @for f in $(EXTRA_DIST); do \ diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-team-port-empty-config b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-team-port-empty-config new file mode 100644 index 000000000..04df69387 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-team-port-empty-config @@ -0,0 +1,4 @@ +TYPE=Ethernet +DEVICE=p4p1 +TEAM_MASTER=team0 +DEVICETYPE=TeamPort diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 3691c5f37..225610ff4 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -13475,6 +13475,33 @@ test_write_team_port (void) g_object_unref (reread); } +static void +test_read_team_port_empty_config (void) +{ + NMConnection *connection; + NMSettingConnection *s_con; + gboolean success; + GError *error = NULL; + + connection = connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-team-port-empty-config", + NULL, TYPE_ETHERNET, NULL, NULL, NULL, NULL, NULL, &error, NULL); + g_assert_no_error (error); + g_assert (connection); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_WIRED_SETTING_NAME); + g_assert_cmpstr (nm_setting_connection_get_master (s_con), ==, "team0"); + + /* Empty TEAM_PORT_CONFIG means no team-port setting */ + g_assert (nm_connection_get_setting_team_port (connection) == NULL); + + g_object_unref (connection); +} /* Old algorithm for "remove escaped characters in place". * @@ -13804,6 +13831,7 @@ int main (int argc, char **argv) g_test_add_func (TPATH "team/write-master", test_write_team_master); g_test_add_func (TPATH "team/read-port", test_read_team_port); g_test_add_func (TPATH "team/write-port", test_write_team_port); + g_test_add_func (TPATH "team/read-port-empty-config", test_read_team_port_empty_config); /* Stuff we expect to fail for now */ test_write_wired_pppoe ();