public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH v2 5/9] testsuite: Allow custom image names in start_vm.py
Date: Wed,  8 Feb 2023 16:45:07 +0100	[thread overview]
Message-ID: <20230208154511.1884-6-ubely@ilbers.de> (raw)
In-Reply-To: <20230208154511.1884-1-ubely@ilbers.de>

This removes hardcoded `isar-image-base` image name used in
`testsuite/start_vm.py`.

Now, user can pass custom value with `-i` or `--image` option
(e.g. `isar-image-debug` or any other value used in their downstream.

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 testsuite/cibuilder.py |  9 +++++----
 testsuite/start_vm.py  | 21 +++++++++++----------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index 5d82ec4b..247b998b 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -209,8 +209,9 @@ class CIBuilder(Test):
 
         return env['LAYERDIR_' + layer].strip('"')
 
-    def vm_start(self, arch='amd64', distro='buster', enforce_pcbios=False,
-                 skip_modulecheck=False):
+    def vm_start(self, arch='amd64', distro='buster',
+                 enforce_pcbios=False, skip_modulecheck=False,
+                 image='isar-image-base'):
         time_to_wait = self.params.get('time_to_wait', default=60)
 
         self.log.info('===================================================')
@@ -233,7 +234,7 @@ class CIBuilder(Test):
             os.unlink(latest_link)
         os.symlink(os.path.basename(output_file), latest_link)
 
-        cmdline = start_vm.format_qemu_cmdline(arch, self.build_dir, distro,
+        cmdline = start_vm.format_qemu_cmdline(arch, self.build_dir, distro, image,
                                                output_file, None, enforce_pcbios)
         cmdline.insert(1, '-nographic')
 
@@ -244,7 +245,7 @@ class CIBuilder(Test):
         module_output = b'Just an example'
         resize_output = None
 
-        bb_output = start_vm.get_bitbake_env(arch, distro).decode()
+        bb_output = start_vm.get_bitbake_env(arch, distro, image).decode()
         image_fstypes = start_vm.get_bitbake_var(bb_output, 'IMAGE_FSTYPES')
         wks_file = start_vm.get_bitbake_var(bb_output, 'WKS_FILE')
         # only the first type will be tested in start_vm.py
diff --git a/testsuite/start_vm.py b/testsuite/start_vm.py
index c3726f14..d151232e 100755
--- a/testsuite/start_vm.py
+++ b/testsuite/start_vm.py
@@ -10,8 +10,8 @@ import subprocess
 import sys
 import time
 
-def get_bitbake_env(arch, distro):
-    multiconfig = 'mc:qemu' + arch + '-' + distro + ':isar-image-base'
+def get_bitbake_env(arch, distro, image):
+    multiconfig = 'mc:qemu' + arch + '-' + distro + ':' + image
     output = subprocess.check_output(['bitbake', '-e', str(multiconfig)])
     return output
 
@@ -22,18 +22,19 @@ def get_bitbake_var(output, var):
             ret = line.split('"')[1]
     return ret
 
-def format_qemu_cmdline(arch, build, distro, out, pid, enforce_pcbios=False):
-    bb_output = get_bitbake_env(arch, distro).decode()
+def format_qemu_cmdline(arch, build, distro, image, out, pid, enforce_pcbios=False):
+    bb_output = get_bitbake_env(arch, distro, image).decode()
 
-    rootfs_image = ''
     extra_args = ''
     cpu = ['']
 
     image_type = get_bitbake_var(bb_output, 'IMAGE_FSTYPES').split()[0]
     deploy_dir_image = get_bitbake_var(bb_output, 'DEPLOY_DIR_IMAGE')
     base = 'ubuntu' if distro in ['focal', 'bionic'] else 'debian'
+
+    rootfs_image = image + '-' + base + '-' + distro + '-qemu' + arch + '.' + image_type
+
     if image_type == 'ext4':
-        rootfs_image = 'isar-image-base-' + base + '-' + distro + '-qemu' + arch + '.ext4'
         kernel_image = deploy_dir_image + '/' + get_bitbake_var(bb_output, 'KERNEL_IMAGE')
         initrd_image = get_bitbake_var(bb_output, 'INITRD_IMAGE')
 
@@ -49,7 +50,6 @@ def format_qemu_cmdline(arch, build, distro, out, pid, enforce_pcbios=False):
         extra_args = ['-kernel', kernel_image, '-initrd', initrd_image]
         extra_args.extend(kargs)
     elif image_type == 'wic':
-        rootfs_image = 'isar-image-base-' + base + '-' + distro + '-qemu' + arch + '.wic'
         extra_args = ['-snapshot']
     else:
         raise ValueError('Invalid image type: ' + str(image_type))
@@ -91,8 +91,8 @@ def format_qemu_cmdline(arch, build, distro, out, pid, enforce_pcbios=False):
 
     return cmd
 
-def start_qemu(arch, build, distro, out, pid, enforce_pcbios):
-    cmdline = format_qemu_cmdline(arch, build, distro, out, pid, enforce_pcbios)
+def start_qemu(arch, build, distro, image, out, pid, enforce_pcbios):
+    cmdline = format_qemu_cmdline(arch, build, distro, image, out, pid, enforce_pcbios)
     cmdline.insert(1, '-nographic')
 
     print(cmdline)
@@ -103,9 +103,10 @@ if __name__ == "__main__":
     parser.add_argument('-a', '--arch', choices=['arm', 'arm64', 'amd64', 'i386', 'mipsel'], help='set isar machine architecture.', default='arm')
     parser.add_argument('-b', '--build', help='set path to build directory.', default=os.getcwd())
     parser.add_argument('-d', '--distro', choices=['buster', 'bullseye', 'bookworm'], help='set isar Debian distribution.', default='bookworm')
+    parser.add_argument('-i', '--image', help='set image name.', default='isar-image-base')
     parser.add_argument('-o', '--out', help='Route QEMU console output to specified file.')
     parser.add_argument('-p', '--pid', help='Store QEMU pid to specified file.')
     parser.add_argument('--pcbios', action="store_true", help='remove any bios options to enforce use of pc bios')
     args = parser.parse_args()
 
-    start_qemu(args.arch, args.build, args.distro, args.out, args.pid, args.pcbios)
+    start_qemu(args.arch, args.build, args.distro, args.image, args.out, args.pid, args.pcbios)
-- 
2.20.1


  parent reply	other threads:[~2023-02-08 15:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08 15:45 [PATCH v2 0/9] Support running custom commands in VM Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 1/9] testsuite: Fix failing hostname service in qemu guest Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 2/9] testsuite: Add SSH key pair for using in CI Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 3/9] meta-isar: Add a recipe that configures ci user Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 4/9] meta-isar: Use a separate image recipe in CI Uladzimir Bely
2023-02-08 15:45 ` Uladzimir Bely [this message]
2023-02-08 15:45 ` [PATCH v2 6/9] testsuite: Support running custom commands in VM Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 7/9] testsuite: Support running custom scripts " Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 8/9] testsuite: Run custom commands and scripts on some qemu targets Uladzimir Bely
2023-02-08 15:45 ` [PATCH v2 9/9] testsuite: Update testsuite qemu-related documentation Uladzimir Bely
2023-02-21 10:56 ` [PATCH v2 0/9] Support running custom commands in VM Uladzimir Bely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230208154511.1884-6-ubely@ilbers.de \
    --to=ubely@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox