Skip to content

Commit 1111aef

Browse files
committed
qemu: Add selftests tarball handling
1 parent 6a25a52 commit 1111aef

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

lib/qemu.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def configure_from_env(self):
6060
self.expected_release = get_expected_release()
6161
self.vmlinux = get_vmlinux()
6262
self.modules_tarball = get_modules_tarball()
63+
self.selftests_tarball = get_selftests_tarball()
6364
self.cpuinfo = None
6465

6566
def configure_from_args(self, orig_args):
@@ -85,6 +86,7 @@ def configure_from_args(self, orig_args):
8586
parser.add_argument('--release-path', type=str, help='Path to kernel.release')
8687
parser.add_argument('--kernel-path', type=str, help='Path to kernel (vmlinux)')
8788
parser.add_argument('--modules-path', type=str, help='Path to modules tarball')
89+
parser.add_argument('--selftests-path', type=str, help='Path to selftests tarball')
8890
parser.add_argument('--cap', dest='machine_caps', type=str, default=[], action='append', help='Machine caps')
8991
parser.add_argument('--qemu-path', dest='qemu_path', type=str, help='Path to qemu bin directory')
9092
parser.add_argument('--root-disk-path', dest='root_disk_path', type=str, help='Path to root disk directory')
@@ -142,6 +144,9 @@ def configure_from_args(self, orig_args):
142144
if args.root_disk_path:
143145
self.root_disk_path = args.root_disk_path
144146

147+
if args.selftests_path:
148+
self.selftests_tarball = args.selftests_path
149+
145150
self.compat_rootfs = args.compat_rootfs
146151
self.use_vof = args.use_vof
147152
self.quiet = args.quiet
@@ -301,6 +306,9 @@ def boot(p, timeout, qconf):
301306
if self.modules_tarball:
302307
self.modules_drive = self.add_drive(f'file={self.modules_tarball},format=raw,readonly=on')
303308

309+
if self.selftests_tarball:
310+
self.selftests_drive = self.add_drive(f'file={self.selftests_tarball},format=raw,readonly=on')
311+
304312
def add_drive(self, args):
305313
drive_id = self.next_drive
306314
self.next_drive += 1
@@ -518,6 +526,11 @@ def qemu_main(qconf):
518526
p.send(f'cd /lib/modules; cat /dev/vd{qconf.modules_drive} | zcat | tar --strip-components=2 -xf -; cd -')
519527
p.expect_prompt(timeout=boot_timeout)
520528

529+
if qconf.selftests_tarball:
530+
p.cmd('mkdir -p /var/tmp/selftests')
531+
p.send(f'cd /var/tmp/selftests; cat /dev/vd{qconf.selftests_drive} | zcat | tar --strip-components=1 -xf -; cd -')
532+
p.expect_prompt(timeout=boot_timeout)
533+
521534
if qconf.net_tests:
522535
qemu_net_setup(p)
523536
ping_test(p)

lib/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ def get_modules_tarball():
9393
return get_tarball('modules')
9494

9595

96+
def get_selftests_tarball():
97+
return get_tarball('selftests')
98+
9699
def read_expected_release(path):
97100
expected_release = open(path).read().strip()
98101
return expected_release

0 commit comments

Comments
 (0)