[master 24/30] Add a test for parse-kickstart (#1014220)

M4rtinK installerbot-noreply at redhat.com
Mon Jun 1 14:04:41 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

The parse-kickstart script used for anaconda-dracut emits cmdline strings
and creates ifcfg files for network settings. Test these to make sure
they are working correctly.

(cherry picked from commit 9546d9ede8754ab67bdbd3efd7d8c6bc2bf52ec3)
---
 tests/dracut_tests/parse-kickstart_test.py | 40 +++++++++++++++---------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/tests/dracut_tests/parse-kickstart_test.py b/tests/dracut_tests/parse-kickstart_test.py
index e44d9d2..64fccd9 100644
--- a/tests/dracut_tests/parse-kickstart_test.py
+++ b/tests/dracut_tests/parse-kickstart_test.py
@@ -52,7 +52,7 @@ def execParseKickstart(self, ks_file):
         return list(iutil.execReadlines(self.command, ["--tmpdir", self.tmpdir, ks_file]))
 
     def cdrom_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""cdrom """)
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -60,7 +60,7 @@ def cdrom_test(self):
         self.assertEqual(lines[0], "inst.repo=cdrom", lines)
 
     def harddrive_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""harddrive --partition=sda4 --dir=/path/to/tree""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -68,7 +68,7 @@ def harddrive_test(self):
         self.assertEqual(lines[0], "inst.repo=hd:sda4:/path/to/tree", lines)
 
     def nfs_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""nfs --server=host.at.foo.com --dir=/path/to/tree --opts=nolock,timeo=50""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -76,7 +76,7 @@ def nfs_test(self):
         self.assertEqual(lines[0], "inst.repo=nfs:nolock,timeo=50:host.at.foo.com:/path/to/tree", lines)
 
     def nfs_test_2(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""nfs --server=host.at.foo.com --dir=/path/to/tree""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -84,7 +84,7 @@ def nfs_test_2(self):
         self.assertEqual(lines[0], "inst.repo=nfs:host.at.foo.com:/path/to/tree", lines)
 
     def url_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""url --url=https://host.at.foo.com/path/to/tree --noverifyssl --proxy=http://localhost:8123""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -95,7 +95,7 @@ def url_test(self):
         self.assertEqual(lines[2], "proxy=http://localhost:8123", lines)
 
     def updates_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""updates http://host.at.foo.com/path/to/updates.img""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -103,7 +103,7 @@ def updates_test(self):
         self.assertEqual(lines[0], "live.updates=http://host.at.foo.com/path/to/updates.img", lines)
 
     def mediacheck_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""mediacheck""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -111,7 +111,7 @@ def mediacheck_test(self):
         self.assertEqual(lines[0], "rd.live.check", lines)
 
     def driverdisk_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""driverdisk sda5""")
             ks_file.flush()
             # This call to execParseKickstart doesn't need to be checked,
@@ -123,7 +123,7 @@ def driverdisk_test(self):
         self.assertEqual(dd_args_ks[0], "sda5", dd_args_ks)
 
     def driverdisk_test_2(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""driverdisk --source=http://host.att.foo.com/path/to/dd""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -131,7 +131,7 @@ def driverdisk_test_2(self):
         self.assertEqual(lines[0], "inst.dd=http://host.att.foo.com/path/to/dd", lines)
 
     def network_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""network --device=link --bootproto=dhcp --activate""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -139,7 +139,7 @@ def network_test(self):
             self.assertEqual(lines[0], "ip=dhcp", lines)
 
     def network_test_2(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""network --device=AA:BB:CC:DD:EE:FF --bootproto=dhcp --activate""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -147,7 +147,7 @@ def network_test_2(self):
             self.assertEqual(lines[0], "ifname=ksdev0:aa:bb:cc:dd:ee:ff ip=ksdev0:dhcp: bootdev=ksdev0", lines)
 
     def network_static_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""network --device=link --bootproto=dhcp --activate
 network --device=lo --bootproto=static --ip=10.0.2.15 --netmask=255.255.255.0 --gateway=10.0.2.254 --nameserver=10.0.2.10
 """)
@@ -169,7 +169,7 @@ def network_static_test(self):
             self.assertTrue(ifcfg_lines[9].startswith("UUID="), ifcfg_lines)
 
     def network_team_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""network --device=link --bootproto=dhcp --activate
 network --device team0 --activate --bootproto static --ip=10.34.102.222 --netmask=255.255.255.0 --gateway=10.34.102.254 --nameserver=10.34.39.2 --teamslaves="p3p1'{\"prio\": -10, \"sticky\": true}'" --teamconfig="{\"runner\": {\"name\": \"activebackup\"}}"
 """)
@@ -188,7 +188,7 @@ def network_team_test(self):
             self.assertEqual(team_lines[6], "TEAM_PORT_CONFIG='{prio: -10, sticky: true}'\n", team_lines)
 
     def network_bond_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""network --device=link --bootproto=dhcp --activate
 network --device=eth0 --bootproto=dhcp --bondslaves=eth0,eth1
 """)
@@ -206,7 +206,7 @@ def network_bond_test(self):
             self.assertTrue(ifcfg_lines[6].startswith("UUID="), ifcfg_lines)
 
     def network_bridge_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""network --device=link --bootproto=dhcp --activate
 network --device br0 --activate --bootproto dhcp --bridgeslaves=eth0 --bridgeopts=stp=6.0,forward_delay=2
 """)
@@ -236,7 +236,7 @@ def network_bridge_test(self):
             self.assertTrue(bridge_lines[6].startswith("UUID="), bridge_lines)
 
     def network_vlanid_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""network --device=link --bootproto=dhcp --activate
 network --device=lo --vlanid=171
 """)
@@ -258,7 +258,7 @@ def network_vlanid_test(self):
             self.assertEqual(ifcfg_lines[10], "VLAN_ID=171\n", ifcfg_lines)
 
     def displaymode_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""cmdline""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -266,7 +266,7 @@ def displaymode_test(self):
             self.assertEqual(lines[0], "inst.cmdline", lines)
 
     def displaymode_test_2(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""graphical""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -274,7 +274,7 @@ def displaymode_test_2(self):
             self.assertEqual(lines[0], "inst.graphical", lines)
 
     def displaymode_test_3(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""text""")
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)
@@ -282,7 +282,7 @@ def displaymode_test_3(self):
             self.assertEqual(lines[0], "inst.text", lines)
 
     def bootloader_test(self):
-        with tempfile.NamedTemporaryFile() as ks_file:
+        with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
             ks_file.write("""bootloader --extlinux """)
             ks_file.flush()
             lines = self.execParseKickstart(ks_file.name)


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/badf2913f1d3184ff20dbc8bfdaba000ef693347


More information about the anaconda-patches mailing list