Merge ~raharper/curtin:fix/multiple-carry-over-param-separators into curtin:master

Proposed by Ryan Harper
Status: Merged
Approved by: Ryan Harper
Approved revision: beafd4b0f34d6e3f56e26a11cc85594d7fa290f5
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/curtin:fix/multiple-carry-over-param-separators
Merge into: curtin:master
Diff against target: 64 lines (+18/-4)
2 files modified
curtin/commands/install_grub.py (+7/-2)
tests/unittests/test_commands_install_grub.py (+11/-2)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Dan Watkins (community) Approve
Review via email: mp+384469@code.launchpad.net

Commit message

Handle multiple separators which were found in TestAllindata vmtest

TestAllindata specifies additional kernel args and include the '---'
separator. vmtest baseclass already includes a '---' and after
landing of the grub refactor, the python version of the
get_carryover_params did not handle the additional '---'.
Fix this by combining any args after the first '---' separator.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Dan Watkins (oddbloke) wrote :

LGTM, thanks!

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

Commit message lints:
- Line #3 has 3 too many characters. Line starts with: "separator. vmtest baseclass"...- Line #4 has 1 too many characters. Line starts with: "grub refactor, the python"...- Line #5 has 1 too many characters. Line starts with: "the additional '---'."...

review: Needs Fixing
Revision history for this message
Server Team CI bot (server-team-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/commands/install_grub.py b/curtin/commands/install_grub.py
2index 11ffd55..777aa35 100644
3--- a/curtin/commands/install_grub.py
4+++ b/curtin/commands/install_grub.py
5@@ -119,14 +119,19 @@ def get_carryover_params(distroinfo):
6 def wrap(sep):
7 return ' ' + sep + ' '
8
9+ sections = []
10 if wrap(preferred_sep) in cmdline:
11- lead, extra = cmdline.split(wrap(preferred_sep))
12+ sections = cmdline.split(wrap(preferred_sep))
13 elif wrap(legacy_sep) in cmdline:
14- lead, extra = cmdline.split(wrap(legacy_sep))
15+ sections = cmdline.split(wrap(legacy_sep))
16 else:
17 extra = ""
18 lead = cmdline
19
20+ if sections:
21+ lead = sections[0]
22+ extra = " ".join(sections[1:])
23+
24 carry_extra = []
25 if extra:
26 for tok in extra.split():
27diff --git a/tests/unittests/test_commands_install_grub.py b/tests/unittests/test_commands_install_grub.py
28index 1d0c43f..8808159 100644
29--- a/tests/unittests/test_commands_install_grub.py
30+++ b/tests/unittests/test_commands_install_grub.py
31@@ -181,7 +181,7 @@ class TestGetCarryoverParams(CiTestCase):
32 self.m_load_file.return_value = cmdline
33 self.assertEqual([], install_grub.get_carryover_params(distroinfo))
34
35- def test_legacy_seporator(self):
36+ def test_legacy_separator(self):
37 distroinfo = install_grub.distro.get_distroinfo()
38 sep = '--'
39 expected_carry_params = ['foo=bar', 'debug=1']
40@@ -191,7 +191,7 @@ class TestGetCarryoverParams(CiTestCase):
41 self.assertEqual(expected_carry_params,
42 install_grub.get_carryover_params(distroinfo))
43
44- def test_preferred_seporator(self):
45+ def test_preferred_separator(self):
46 distroinfo = install_grub.distro.get_distroinfo()
47 sep = '---'
48 expected_carry_params = ['foo=bar', 'debug=1']
49@@ -201,6 +201,15 @@ class TestGetCarryoverParams(CiTestCase):
50 self.assertEqual(expected_carry_params,
51 install_grub.get_carryover_params(distroinfo))
52
53+ def test_multiple_preferred_separator(self):
54+ distroinfo = install_grub.distro.get_distroinfo()
55+ sep = '---'
56+ expected_carry_params = ['extra', 'additional']
57+ cmdline = "lead=args %s extra %s additional" % (sep, sep)
58+ self.m_load_file.return_value = cmdline
59+ self.assertEqual(expected_carry_params,
60+ install_grub.get_carryover_params(distroinfo))
61+
62 def test_drop_bootif_initrd_boot_image_from_extra(self):
63 distroinfo = install_grub.distro.get_distroinfo()
64 sep = '---'

Subscribers

People subscribed via source and target branches