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
diff --git a/curtin/commands/install_grub.py b/curtin/commands/install_grub.py
index 11ffd55..777aa35 100644
--- a/curtin/commands/install_grub.py
+++ b/curtin/commands/install_grub.py
@@ -119,14 +119,19 @@ def get_carryover_params(distroinfo):
119 def wrap(sep):119 def wrap(sep):
120 return ' ' + sep + ' '120 return ' ' + sep + ' '
121121
122 sections = []
122 if wrap(preferred_sep) in cmdline:123 if wrap(preferred_sep) in cmdline:
123 lead, extra = cmdline.split(wrap(preferred_sep))124 sections = cmdline.split(wrap(preferred_sep))
124 elif wrap(legacy_sep) in cmdline:125 elif wrap(legacy_sep) in cmdline:
125 lead, extra = cmdline.split(wrap(legacy_sep))126 sections = cmdline.split(wrap(legacy_sep))
126 else:127 else:
127 extra = ""128 extra = ""
128 lead = cmdline129 lead = cmdline
129130
131 if sections:
132 lead = sections[0]
133 extra = " ".join(sections[1:])
134
130 carry_extra = []135 carry_extra = []
131 if extra:136 if extra:
132 for tok in extra.split():137 for tok in extra.split():
diff --git a/tests/unittests/test_commands_install_grub.py b/tests/unittests/test_commands_install_grub.py
index 1d0c43f..8808159 100644
--- a/tests/unittests/test_commands_install_grub.py
+++ b/tests/unittests/test_commands_install_grub.py
@@ -181,7 +181,7 @@ class TestGetCarryoverParams(CiTestCase):
181 self.m_load_file.return_value = cmdline181 self.m_load_file.return_value = cmdline
182 self.assertEqual([], install_grub.get_carryover_params(distroinfo))182 self.assertEqual([], install_grub.get_carryover_params(distroinfo))
183183
184 def test_legacy_seporator(self):184 def test_legacy_separator(self):
185 distroinfo = install_grub.distro.get_distroinfo()185 distroinfo = install_grub.distro.get_distroinfo()
186 sep = '--'186 sep = '--'
187 expected_carry_params = ['foo=bar', 'debug=1']187 expected_carry_params = ['foo=bar', 'debug=1']
@@ -191,7 +191,7 @@ class TestGetCarryoverParams(CiTestCase):
191 self.assertEqual(expected_carry_params,191 self.assertEqual(expected_carry_params,
192 install_grub.get_carryover_params(distroinfo))192 install_grub.get_carryover_params(distroinfo))
193193
194 def test_preferred_seporator(self):194 def test_preferred_separator(self):
195 distroinfo = install_grub.distro.get_distroinfo()195 distroinfo = install_grub.distro.get_distroinfo()
196 sep = '---'196 sep = '---'
197 expected_carry_params = ['foo=bar', 'debug=1']197 expected_carry_params = ['foo=bar', 'debug=1']
@@ -201,6 +201,15 @@ class TestGetCarryoverParams(CiTestCase):
201 self.assertEqual(expected_carry_params,201 self.assertEqual(expected_carry_params,
202 install_grub.get_carryover_params(distroinfo))202 install_grub.get_carryover_params(distroinfo))
203203
204 def test_multiple_preferred_separator(self):
205 distroinfo = install_grub.distro.get_distroinfo()
206 sep = '---'
207 expected_carry_params = ['extra', 'additional']
208 cmdline = "lead=args %s extra %s additional" % (sep, sep)
209 self.m_load_file.return_value = cmdline
210 self.assertEqual(expected_carry_params,
211 install_grub.get_carryover_params(distroinfo))
212
204 def test_drop_bootif_initrd_boot_image_from_extra(self):213 def test_drop_bootif_initrd_boot_image_from_extra(self):
205 distroinfo = install_grub.distro.get_distroinfo()214 distroinfo = install_grub.distro.get_distroinfo()
206 sep = '---'215 sep = '---'

Subscribers

People subscribed via source and target branches