That is, fixes to the tests
From: David Shea dshea@redhat.com
--- pyanaconda/packaging/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py index 3371c76..15891c6 100644 --- a/pyanaconda/packaging/__init__.py +++ b/pyanaconda/packaging/__init__.py @@ -625,7 +625,7 @@ def writeStorageLate(self): self.storage.umountFilesystems()
# Explicitly mount the root on the physical sysroot - rootmnt = storage.mountpoints.get('/') + rootmnt = self.storage.mountpoints.get('/') rootmnt.setup() rootmnt.format.setup(options=rootmnt.format.options, chroot=iutil.getTargetPhysicalRoot())
From: David Shea dshea@redhat.com
--- tests/dd_tests/dd_test.py | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/tests/dd_tests/dd_test.py b/tests/dd_tests/dd_test.py index a254eba..60ff6b4 100644 --- a/tests/dd_tests/dd_test.py +++ b/tests/dd_tests/dd_test.py @@ -1,6 +1,9 @@ #!/usr/bin/python # unit tests for driver disk utilities (utils/dd)
+# Ignore any interruptible calls +# pylint: disable=interruptible-system-call + import os import shutil import unittest
From: David Shea dshea@redhat.com
--- pyanaconda/iutil.py | 11 ++++++++--- tests/pyanaconda_tests/iutil_test.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py index 6888253..7d80ed7 100644 --- a/pyanaconda/iutil.py +++ b/pyanaconda/iutil.py @@ -392,7 +392,7 @@ def execWithCaptureBinary(command, argv, stdin=None, root='/', log_output=False, return _run_program(argv, stdin=stdin, root=root, log_output=log_output, filter_stderr=filter_stderr, binary_output=True)[1]
-def execReadlines(command, argv, stdin=None, root='/', env_prune=None): +def execReadlines(command, argv, stdin=None, root='/', env_prune=None, filter_stderr=False): """ Execute an external command and return the line output of the command in real-time.
@@ -407,9 +407,9 @@ def execReadlines(command, argv, stdin=None, root='/', env_prune=None): :param argv: The argument list :param stdin: The file object to read stdin from. :param stdout: Optional file object to redirect stdout and stderr to. - :param stderr: not used :param root: The directory to chroot to before running command. :param env_prune: environment variable to remove before execution + :param filter_stderr: Whether stderr should be excluded from the returned output
Output from the file is not logged to program.log This returns an iterator with the lines from the command until it has finished @@ -456,8 +456,13 @@ def __next__(self):
argv = [command] + argv
+ if filter_stderr: + stderr = subprocess.DEVNULL + else: + stderr = subprocess.STDOUT + try: - proc = startProgram(argv, root=root, stdin=stdin, env_prune=env_prune, bufsize=1) + proc = startProgram(argv, root=root, stdin=stdin, stderr=stderr, env_prune=env_prune, bufsize=1) except OSError as e: with program_log_lock: program_log.error("Error running %s: %s", argv[0], e.strerror) diff --git a/tests/pyanaconda_tests/iutil_test.py b/tests/pyanaconda_tests/iutil_test.py index ad0bc82..090d84a 100644 --- a/tests/pyanaconda_tests/iutil_test.py +++ b/tests/pyanaconda_tests/iutil_test.py @@ -288,6 +288,42 @@ def _hup_handler(signum, frame): finally: signal.signal(signal.SIGHUP, old_HUP_handler)
+ def exec_readlines_test_filter_stderr(self): + """Test execReadlines and filter_stderr.""" + + # Test that stderr is normally included + with tempfile.NamedTemporaryFile(mode="w+t") as testscript: + testscript.write("""#!/bin/sh +echo "one" +echo "two" >&2 +echo "three" +exit 0 +""") + testscript.flush() + + with timer(5): + rl_iterator = iutil.execReadlines("/bin/sh", [testscript.name]) + self.assertEqual(next(rl_iterator), "one") + self.assertEqual(next(rl_iterator), "two") + self.assertEqual(next(rl_iterator), "three") + self.assertRaises(StopIteration, rl_iterator.__next__) + + # Test that filter stderr removes the middle line + with tempfile.NamedTemporaryFile(mode="w+t") as testscript: + testscript.write("""#!/bin/sh +echo "one" +echo "two" >&2 +echo "three" +exit 0 +""") + testscript.flush() + + with timer(5): + rl_iterator = iutil.execReadlines("/bin/sh", [testscript.name], filter_stderr=True) + self.assertEqual(next(rl_iterator), "one") + self.assertEqual(next(rl_iterator), "three") + self.assertRaises(StopIteration, rl_iterator.__next__) + def start_program_preexec_fn_test(self): """Test passing preexec_fn to startProgram."""
From: David Shea dshea@redhat.com
stderr might contain, for example, warnings about network devices already being set up, and we don't care about those. --- tests/dracut_tests/parse-kickstart_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/dracut_tests/parse-kickstart_test.py b/tests/dracut_tests/parse-kickstart_test.py index 5aff119..2f87fac 100644 --- a/tests/dracut_tests/parse-kickstart_test.py +++ b/tests/dracut_tests/parse-kickstart_test.py @@ -52,7 +52,7 @@ def setUpClass(cls): cls.command = os.path.abspath(os.path.join(os.environ["top_srcdir"], "dracut/parse-kickstart"))
def execParseKickstart(self, ks_file): - return list(iutil.execReadlines(self.command, ["--tmpdir", self.tmpdir, ks_file])) + return list(iutil.execReadlines(self.command, ["--tmpdir", self.tmpdir, ks_file], filter_stderr=True))
def cdrom_test(self): with tempfile.NamedTemporaryFile(mode="w+t") as ks_file:
From: David Shea dshea@redhat.com
Use regex tests to allow any jumble of characters not containing spaces or colons to be the first link device. This way the parse-kickstart tests work on, for example, a VM with a network device named eth0, or my laptop with the network cable unplugged. --- tests/dracut_tests/parse-kickstart_test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/dracut_tests/parse-kickstart_test.py b/tests/dracut_tests/parse-kickstart_test.py index 2f87fac..36b5e66 100644 --- a/tests/dracut_tests/parse-kickstart_test.py +++ b/tests/dracut_tests/parse-kickstart_test.py @@ -139,7 +139,7 @@ def network_test(self): ks_file.flush() lines = self.execParseKickstart(ks_file.name)
- self.assertEqual(lines[0], "ip=em1:dhcp: bootdev=em1", lines) + self.assertRegex(lines[0], r"ip=[^\s:]+:dhcp: bootdev=[^\s:]+", lines)
def network_test_2(self): with tempfile.NamedTemporaryFile(mode="w+t") as ks_file: @@ -157,7 +157,7 @@ def network_static_test(self): ks_file.flush() lines = self.execParseKickstart(ks_file.name)
- self.assertEqual(lines[0], "ip=em1:dhcp: bootdev=em1", lines) + self.assertRegex(lines[0], r"ip=[^\s:]+:dhcp: bootdev=[^\s:]+", lines)
ifcfg_lines = sorted(open(self.tmpdir+"/ifcfg/ifcfg-lo").readlines()) self.assertEqual(ifcfg_lines[0], "# Generated by parse-kickstart\n", ifcfg_lines) @@ -179,7 +179,7 @@ def network_team_test(self): ks_file.flush() lines = self.execParseKickstart(ks_file.name)
- self.assertEqual(lines[0], "ip=em1:dhcp: bootdev=em1", lines) + self.assertRegex(lines[0], r"ip=[^\s:]+:dhcp: bootdev=[^\s:]+", lines)
team_lines = sorted(open(self.tmpdir+"/ifcfg/ifcfg-team0_slave_0").readlines()) self.assertEqual(team_lines[0], "# Generated by parse-kickstart\n", team_lines) @@ -198,7 +198,7 @@ def network_bond_test(self): ks_file.flush() lines = self.execParseKickstart(ks_file.name)
- self.assertEqual(lines[0], "ip=em1:dhcp: bootdev=em1", lines) + self.assertRegex(lines[0], r"ip=[^\s:]+:dhcp: bootdev=[^\s:]+", lines)
ifcfg_lines = sorted(open(self.tmpdir+"/ifcfg/ifcfg-eth0_slave_1").readlines()) self.assertEqual(ifcfg_lines[0], "# Generated by parse-kickstart\n", ifcfg_lines) @@ -216,7 +216,7 @@ def network_bridge_test(self): ks_file.flush() lines = self.execParseKickstart(ks_file.name)
- self.assertEqual(lines[0], "ip=em1:dhcp: bootdev=em1", lines) + self.assertRegex(lines[0], r"ip=[^\s:]+:dhcp: bootdev=[^\s:]+", lines)
ifcfg_lines = sorted(open(self.tmpdir+"/ifcfg/ifcfg-br0").readlines()) self.assertEqual(ifcfg_lines[0], "# Generated by parse-kickstart\n", ifcfg_lines) @@ -246,7 +246,7 @@ def network_vlanid_test(self): ks_file.flush() lines = self.execParseKickstart(ks_file.name)
- self.assertEqual(lines[0], "ip=em1:dhcp: bootdev=em1", lines) + self.assertRegex(lines[0], r"ip=[^\s:]+:dhcp: bootdev=[^\s:]+", lines)
ifcfg_lines = sorted(open(self.tmpdir+"/ifcfg/ifcfg-lo.171").readlines()) self.assertEqual(ifcfg_lines[1], "BOOTPROTO=dhcp\n", ifcfg_lines)
Added label: ACK.
Looks good to me too.
Closed.
Pushed.
anaconda-patches@lists.fedorahosted.org