[v2,5/5] selftest: wic: Disable graphic of qemu to support WSL

Message ID 20220214154521.26905-5-stefan.herbrechtsmeier-oss@weidmueller.com
State Accepted, archived
Commit 797af95eb272bd12eac193cdfe72ddffe8aa39ca
Headers show
Series [v2,1/5] wic: partition: Support valueless keys in sourceparams | expand

Commit Message

Stefan Herbrechtsmeier Feb. 14, 2022, 3:45 p.m. UTC
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Disable graphic support of qemu to support qemu tests in WSL.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

---

Changes in v2:
- Add patch

 meta/lib/oeqa/selftest/cases/wic.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Alexander Kanavin Feb. 14, 2022, 4:28 p.m. UTC | #1
This fixes one location where the problem can occur in selftests, but
what about all the others?

Generally, it is not selftest's job to ensure qemu can be started: you
need to either tweak runqemu to detect WSL, configure
qemu-system-native from your local.conf so that it doesn't enable sdl
or gtk, or, better yet, fix the problem at the source - find out why
graphical qemu doesn't work in WSL and fix that.

Alex



On Mon, 14 Feb 2022 at 16:46, Stefan Herbrechtsmeier
<stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>
> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>
> Disable graphic support of qemu to support qemu tests in WSL.
>
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>
> ---
>
> Changes in v2:
> - Add patch
>
>  meta/lib/oeqa/selftest/cases/wic.py | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
> index a021f8d84b..6f3dc27743 100644
> --- a/meta/lib/oeqa/selftest/cases/wic.py
> +++ b/meta/lib/oeqa/selftest/cases/wic.py
> @@ -851,7 +851,7 @@ class Wic2(WicTestCase):
>          self.assertEqual(0, bitbake('wic-image-minimal').status)
>          self.remove_config(config)
>
> -        with runqemu('wic-image-minimal', ssh=False) as qemu:
> +        with runqemu('wic-image-minimal', ssh=False, runqemuparams='nographic') as qemu:
>              cmd = "mount | grep '^/dev/' | cut -f1,3 -d ' ' | egrep -c -e '/dev/sda1 /boot' " \
>                    "-e '/dev/root /|/dev/sda2 /' -e '/dev/sda3 /media' -e '/dev/sda4 /mnt'"
>              status, output = qemu.run_serial(cmd)
> @@ -871,7 +871,7 @@ class Wic2(WicTestCase):
>          self.remove_config(config)
>
>          with runqemu('core-image-minimal', ssh=False,
> -                     runqemuparams='ovmf', image_fstype='wic') as qemu:
> +                     runqemuparams='nographic ovmf', image_fstype='wic') as qemu:
>              cmd = "grep sda. /proc/partitions  |wc -l"
>              status, output = qemu.run_serial(cmd)
>              self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
> @@ -1059,7 +1059,8 @@ class Wic2(WicTestCase):
>          self.assertEqual(0, bitbake('core-image-minimal-mtdutils').status)
>          self.remove_config(config)
>
> -        with runqemu('core-image-minimal-mtdutils', ssh=False, image_fstype='wic') as qemu:
> +        with runqemu('core-image-minimal-mtdutils', ssh=False,
> +                     runqemuparams='nographic', image_fstype='wic') as qemu:
>              cmd = "grep sda. /proc/partitions  |wc -l"
>              status, output = qemu.run_serial(cmd)
>              self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
> @@ -1119,7 +1120,8 @@ class Wic2(WicTestCase):
>          self.assertEqual(0, bitbake('core-image-minimal').status)
>          self.remove_config(config)
>
> -        with runqemu('core-image-minimal', ssh=False, image_fstype='wic') as qemu:
> +        with runqemu('core-image-minimal', ssh=False,
> +                     runqemuparams='nographic', image_fstype='wic') as qemu:
>              # Check that we have ONLY two /dev/sda* partitions (/boot and /)
>              cmd = "grep sda. /proc/partitions | wc -l"
>              status, output = qemu.run_serial(cmd)
> @@ -1180,7 +1182,7 @@ class Wic2(WicTestCase):
>          self.remove_config(config)
>
>          with runqemu('core-image-minimal', ssh=False,
> -                     runqemuparams='ovmf', image_fstype='wic') as qemu:
> +                     runqemuparams='nographic ovmf', image_fstype='wic') as qemu:
>              # Check that /boot has EFI bootx64.efi (required for EFI)
>              cmd = "ls /boot/EFI/BOOT/bootx64.efi | wc -l"
>              status, output = qemu.run_serial(cmd)
> @@ -1418,7 +1420,7 @@ class Wic2(WicTestCase):
>              bb.utils.rename(new_image_path, image_path)
>
>              # Check if it boots in qemu
> -            with runqemu('core-image-minimal', ssh=False) as qemu:
> +            with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic') as qemu:
>                  cmd = "ls /etc/"
>                  status, output = qemu.run_serial('true')
>                  self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
> --
> 2.30.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#161718): https://lists.openembedded.org/g/openembedded-core/message/161718
> Mute This Topic: https://lists.openembedded.org/mt/89138943/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Stefan Herbrechtsmeier Feb. 14, 2022, 5:12 p.m. UTC | #2
Hi Alex,

Am 14.02.2022 um 17:28 schrieb Alexander Kanavin:
> This fixes one location where the problem can occur in selftests, but
> what about all the others?

Other tests like efibootpartition, gcc, glibc or runqemu already set 
nographic.

> Generally, it is not selftest's job to ensure qemu can be started:

Why selftest requires features which it doesn't need?

> you
> need to either tweak runqemu to detect WSL, configure
> qemu-system-native from your local.conf so that it doesn't enable sdl
> or gtk, or, better yet, fix the problem at the source - find out why
> graphical qemu doesn't work in WSL and fix that.

The graphic support depends on the WSL version.

Regards
   Stefan
Alexander Kanavin Feb. 14, 2022, 5:25 p.m. UTC | #3
On Mon, 14 Feb 2022 at 18:12, Stefan Herbrechtsmeier
<stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
> Am 14.02.2022 um 17:28 schrieb Alexander Kanavin:
> > This fixes one location where the problem can occur in selftests, but
> > what about all the others?
>
> Other tests like efibootpartition, gcc, glibc or runqemu already set
> nographic.

Yes, some of them do. Others do not, here's a complete list:
[ak@localhost meta]$ grep -ilr "with runqemu" lib/oeqa/selftest/cases
lib/oeqa/selftest/cases/gcc.py
lib/oeqa/selftest/cases/runqemu.py
lib/oeqa/selftest/cases/efibootpartition.py
lib/oeqa/selftest/cases/package.py
lib/oeqa/selftest/cases/wic.py
lib/oeqa/selftest/cases/devtool.py
lib/oeqa/selftest/cases/imagefeatures.py
lib/oeqa/selftest/cases/overlayfs.py
lib/oeqa/selftest/cases/runtime_test.py


> > Generally, it is not selftest's job to ensure qemu can be started:
> Why selftest requires features which it doesn't need?

Selftest does not 'require' anything; it simply uses runqemu()'s
defaults. If the defaults aren't suitable, the right place to correct
them is runqemu() in lib/oeqa/utils/commands.py.

> The graphic support depends on the WSL version.

Yep, so please correct this in the right place, subject to actually
running in WSL version where nographic is required.

Alex

Patch

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index a021f8d84b..6f3dc27743 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -851,7 +851,7 @@  class Wic2(WicTestCase):
         self.assertEqual(0, bitbake('wic-image-minimal').status)
         self.remove_config(config)
 
-        with runqemu('wic-image-minimal', ssh=False) as qemu:
+        with runqemu('wic-image-minimal', ssh=False, runqemuparams='nographic') as qemu:
             cmd = "mount | grep '^/dev/' | cut -f1,3 -d ' ' | egrep -c -e '/dev/sda1 /boot' " \
                   "-e '/dev/root /|/dev/sda2 /' -e '/dev/sda3 /media' -e '/dev/sda4 /mnt'"
             status, output = qemu.run_serial(cmd)
@@ -871,7 +871,7 @@  class Wic2(WicTestCase):
         self.remove_config(config)
 
         with runqemu('core-image-minimal', ssh=False,
-                     runqemuparams='ovmf', image_fstype='wic') as qemu:
+                     runqemuparams='nographic ovmf', image_fstype='wic') as qemu:
             cmd = "grep sda. /proc/partitions  |wc -l"
             status, output = qemu.run_serial(cmd)
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
@@ -1059,7 +1059,8 @@  class Wic2(WicTestCase):
         self.assertEqual(0, bitbake('core-image-minimal-mtdutils').status)
         self.remove_config(config)
 
-        with runqemu('core-image-minimal-mtdutils', ssh=False, image_fstype='wic') as qemu:
+        with runqemu('core-image-minimal-mtdutils', ssh=False,
+                     runqemuparams='nographic', image_fstype='wic') as qemu:
             cmd = "grep sda. /proc/partitions  |wc -l"
             status, output = qemu.run_serial(cmd)
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
@@ -1119,7 +1120,8 @@  class Wic2(WicTestCase):
         self.assertEqual(0, bitbake('core-image-minimal').status)
         self.remove_config(config)
 
-        with runqemu('core-image-minimal', ssh=False, image_fstype='wic') as qemu:
+        with runqemu('core-image-minimal', ssh=False,
+                     runqemuparams='nographic', image_fstype='wic') as qemu:
             # Check that we have ONLY two /dev/sda* partitions (/boot and /)
             cmd = "grep sda. /proc/partitions | wc -l"
             status, output = qemu.run_serial(cmd)
@@ -1180,7 +1182,7 @@  class Wic2(WicTestCase):
         self.remove_config(config)
 
         with runqemu('core-image-minimal', ssh=False,
-                     runqemuparams='ovmf', image_fstype='wic') as qemu:
+                     runqemuparams='nographic ovmf', image_fstype='wic') as qemu:
             # Check that /boot has EFI bootx64.efi (required for EFI)
             cmd = "ls /boot/EFI/BOOT/bootx64.efi | wc -l"
             status, output = qemu.run_serial(cmd)
@@ -1418,7 +1420,7 @@  class Wic2(WicTestCase):
             bb.utils.rename(new_image_path, image_path)
 
             # Check if it boots in qemu
-            with runqemu('core-image-minimal', ssh=False) as qemu:
+            with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic') as qemu:
                 cmd = "ls /etc/"
                 status, output = qemu.run_serial('true')
                 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))