Skip to content

Commit f257a24

Browse files
committed
test_bootloader: Fix sporadic failure
This test is broken in multiple ways. Either: 1) Execution of diff races against the named temporary file being removed when the context manager is left, resulting in no output from diff and the test "passes" (diff exits with status 2). 2) diff generates output and the call to assertRegexpMatches() fails because it was renamed in Python 3.2. Fix this by ensuring diff finishes before leaving the context manager, asserting the exact diff expected, and checking the return code. Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
1 parent c8e4a37 commit f257a24

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

tests/test_bootloader.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ def test_grub2(self):
1717
proc = subprocess.Popen(["diff", "tests/data/grub.cfg", temp.name],
1818
stdout = subprocess.PIPE,
1919
universal_newlines=True)
20-
assert proc.stdout
21-
for line in proc.stdout:
22-
# pylint: disable-next=deprecated-method
23-
self.assertRegexpMatches(line, r"^(5a6,13$|>)")
2420

25-
proc.stdout.close()
26-
proc.wait()
21+
self.assertEqual(proc.stdout.read(), '''5a6,13
22+
> if [ -s $prefix/grubenv ]; then
23+
> load_env
24+
> fi
25+
>
26+
> if [ -n "$override_entry" ]; then
27+
> set default=$override_entry
28+
> fi
29+
>
30+
''')
31+
proc.stdout.close()
32+
proc.wait()
33+
self.assertEqual(proc.returncode, 1)
2734

2835
def test_no_multiboot(self):
2936
# A module2 line without a multiboot2 line is an error

0 commit comments

Comments
 (0)