Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8b3a030

Browse files
committedFeb 27, 2025··
tests: integration tests for boot mode
Right now they mostly duplicate what unit tests are already testing. It will make more sense for boot mode with in-vm kernel, and/or Whonix package (instead of dummy boot modes). QubesOS/qubes-issues#9750
1 parent 9a89893 commit 8b3a030

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
 

‎qubes/tests/integ/basic.py

+68
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,74 @@ def test_207_domain_start_prohibition(self):
482482
self.loop.run_until_complete(self.vm.start())
483483
self.assertFalse(self.vm.is_running())
484484

485+
async def _test_bootmode(self, tpl, vm):
486+
await tpl.start()
487+
await tpl.run_for_stdio(
488+
"cat > /etc/qubes/post-install.d/50-test.sh",
489+
input=b"""#!/bin/sh
490+
491+
qvm-features-request boot-mode.kernelopts.mode1="opt1=val1 opt2"
492+
qvm-features-request boot-mode.name.mode1="Fancy name for mode 1"
493+
qvm-features-request boot-mode.kernelopts.mode2="only-one-option-no-value"
494+
qvm-features-request boot-mode.active=mode1
495+
qvm-features-request boot-mode.appvm-default=mode2
496+
""",
497+
user="root",
498+
)
499+
await tpl.run_for_stdio(
500+
"chmod +x " "/etc/qubes/post-install.d/50-test.sh", user="root"
501+
)
502+
await tpl.run_service_for_stdio("qubes.PostInstall", user="root")
503+
await tpl.shutdown(wait=True)
504+
505+
self.assertEqual(tpl.bootmode, "mode1")
506+
if tpl != vm:
507+
self.assertEqual(vm.bootmode, "mode2")
508+
await vm.start()
509+
cmdline = await vm.run_for_stdio("cat /proc/cmdline").decode()
510+
if tpl != vm:
511+
self.assertIn("only-one-option-no-value", cmdline)
512+
else:
513+
self.assertIn("opv1=val1", cmdline)
514+
515+
def test_210_bootmode_template(self):
516+
self.test_template = self.app.add_new_vm(
517+
qubes.vm.templatevm.TemplateVM,
518+
name=self.make_vm_name("tpl"),
519+
label="red",
520+
)
521+
self.test_template.clone_properties(self.app.default_template)
522+
self.test_template.features.update(self.app.default_template.features)
523+
self.test_template.tags.update(self.app.default_template.tags)
524+
self.loop.run_until_complete(
525+
self.test_template.clone_disk_files(self.app.default_template)
526+
)
527+
self.vm = self.app.add_new_vm(
528+
qubes.vm.appvm.AppVM,
529+
name=self.make_vm_name("vm"),
530+
template=self.test_template,
531+
label="red",
532+
)
533+
self.loop.run_until_complete(self.vm.create_on_disk())
534+
self.app.save()
535+
self.loop.run_until_complete(
536+
self._test_bootmode(self.test_template, self.vm)
537+
)
538+
539+
def test_211_bootmode_standalone(self):
540+
self.vm = self.app.add_new_vm(
541+
qubes.vm.standalonevm.StandaloneVM,
542+
name=self.make_vm_name("vm"),
543+
label="red",
544+
)
545+
self.vm.clone_properties(self.app.default_template)
546+
self.vm.features.update(self.app.default_template.features)
547+
self.loop.run_until_complete(
548+
self.vm.clone_disk_files(self.app.default_template)
549+
)
550+
self.app.save()
551+
self.loop.run_until_complete(self._test_bootmode(self.vm, self.vm))
552+
485553

486554
class TC_01_Properties(qubes.tests.SystemTestCase):
487555
# pylint: disable=attribute-defined-outside-init

0 commit comments

Comments
 (0)
Please sign in to comment.