Skip to content

Commit 376c490

Browse files
committed
tests/vm: allow interactive login as root
This is useful when debugging and you want to add packages to an image. Reviewed-by: Thomas Huth <[email protected]> Signed-off-by: Alex Bennée <[email protected]> Message-Id: <[email protected]>
1 parent 3f6b694 commit 376c490

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

tests/vm/Makefile.include

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ endif
6666
@echo "Special variables:"
6767
@echo " BUILD_TARGET=foo - Override the build target"
6868
@echo " DEBUG=1 - Enable verbose output on host and interactive debugging"
69+
@echo " ROOT_USER=1 - Login as root user for interactive shell"
6970
@echo ' EXTRA_CONFIGURE_OPTS="..." - Pass to configure step'
7071
@echo " J=[0..9]* - Override the -jN parameter for make commands"
7172
@echo " LOG_CONSOLE=1 - Log console to file in: ~/.cache/qemu-vm "
@@ -141,6 +142,6 @@ vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(VM_VENV)
141142
$(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
142143
$(if $(LOG_CONSOLE),--log-console) \
143144
--image "$<" \
144-
--interactive \
145+
$(if $(ROOT_USER),--interactive-root,-interactive) \
145146
false, \
146147
" VM-BOOT-SSH $*") || true

tests/vm/basevm.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,11 @@ def get_default_jobs():
612612
parser.add_argument("--source-path", default=None,
613613
help="Path of source directory, "\
614614
"for finding additional files. ")
615-
parser.add_argument("--interactive", "-I", action="store_true",
616-
help="Interactively run command")
615+
int_ops = parser.add_mutually_exclusive_group()
616+
int_ops.add_argument("--interactive", "-I", action="store_true",
617+
help="Interactively run command")
618+
int_ops.add_argument("--interactive-root", action="store_true",
619+
help="Interactively run command as root")
617620
parser.add_argument("--snapshot", "-s", action="store_true",
618621
help="run tests with a snapshot")
619622
parser.add_argument("--genisoimage", default="genisoimage",
@@ -675,6 +678,8 @@ def main(vmcls, config=None):
675678
exitcode = 3
676679
if args.interactive:
677680
vm.ssh()
681+
elif args.interactive_root:
682+
vm.ssh_root()
678683

679684
if not args.snapshot:
680685
vm.graceful_shutdown()

0 commit comments

Comments
 (0)