All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests
@ 2018-10-13 15:15 Philippe Mathieu-Daudé
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 1/6] tests/acceptance: Rename the generic BootLinuxConsole test as test_x86_64_pc Philippe Mathieu-Daudé
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-13 15:15 UTC (permalink / raw)
  To: Alex Bennée, Cleber Rosa, Eduardo Habkost, BALATON Zoltan,
	Magnus Damm
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Lukáš Doktor, Fam Zheng

Hi,

Another neanderthal approach to add multi-arch acceptance tests using Avocado.

I couldn't figure how to use the R2D serial, the kernel boots using the sm501
display correctly, but I'm too console-oriented to write UI tests...

Magnus or Zoltan, any hint on this?

Thanks

Phil.

Since v2 (http://lists.gnu.org/archive/html/qemu-devel/2018-06/msg06370.html):
- use Debian packaged kernels, add link to the sources and a comment
  about how to rebuild these images (Alex)
- use self.arch from Cleber's series
- add mips64el kernel console test
- add sh4 test using the tracing framework

Since v1 (http://lists.gnu.org/archive/html/qemu-devel/2018-04/msg03076.html):
- we can now run other archs (Cleber)

Based-on: 20181009232607.15521-1-crosa@redhat.com
"Acceptance Tests: basic architecture support" from Cleber Rosa
https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg01821.html

Philippe Mathieu-Daudé (6):
  tests/acceptance: Rename the generic BootLinuxConsole test as
    test_x86_64_pc
  tests/acceptance: Add a kludge to not use the default console
  tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole
  tests/acceptance: Add test_mipsel_5kc_malta in BootLinuxConsole
  tests/acceptance: Add test_sh4_r2d in BootLinuxConsole
  tests/acceptance: Add test_sh4_r2d in BootLinuxTracing

 scripts/qemu.py                        |   6 +-
 tests/acceptance/boot_linux_console.py | 206 ++++++++++++++++++++++++-
 2 files changed, 208 insertions(+), 4 deletions(-)

-- 
2.19.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH v3 1/6] tests/acceptance: Rename the generic BootLinuxConsole test as test_x86_64_pc
  2018-10-13 15:15 [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Philippe Mathieu-Daudé
@ 2018-10-13 15:15 ` Philippe Mathieu-Daudé
  2018-10-19 18:15   ` Cleber Rosa
  2018-10-13 15:15 ` [Qemu-devel] [RFC PATCH v3 2/6] tests/acceptance: Add a kludge to not use the default console Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-13 15:15 UTC (permalink / raw)
  To: Alex Bennée, Cleber Rosa, Eduardo Habkost
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Lukáš Doktor, Fam Zheng

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/acceptance/boot_linux_console.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index ba3ac036da..3aa4dbe5f9 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -15,7 +15,7 @@ from avocado_qemu import Test
 
 class BootLinuxConsole(Test):
     """
-    Boots a x86_64 Linux kernel and checks that the console is operational
+    Boots a Linux kernel and checks that the console is operational
     and the kernel command line is properly passed from QEMU to the kernel
 
     :avocado: enable
@@ -23,7 +23,7 @@ class BootLinuxConsole(Test):
 
     timeout = 60
 
-    def test(self):
+    def test_x86_64_pc(self):
         if self.arch != 'x86_64':
             self.cancel('Currently specific to the x86_64 target arch')
         kernel_url = ('https://mirrors.kernel.org/fedora/releases/28/'
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [RFC PATCH v3 2/6] tests/acceptance: Add a kludge to not use the default console
  2018-10-13 15:15 [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Philippe Mathieu-Daudé
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 1/6] tests/acceptance: Rename the generic BootLinuxConsole test as test_x86_64_pc Philippe Mathieu-Daudé
@ 2018-10-13 15:15 ` Philippe Mathieu-Daudé
  2018-10-19 17:37   ` Cleber Rosa
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 3/6] tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-13 15:15 UTC (permalink / raw)
  To: Alex Bennée, Cleber Rosa, Eduardo Habkost
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Lukáš Doktor, Fam Zheng

The board already instantiate the proper devices, we don't want to
add extra devices but connect the chardev to one of the serial already
available.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 scripts/qemu.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/qemu.py b/scripts/qemu.py
index fca9b76990..7e779954e6 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -221,8 +221,10 @@ class QEMUMachine(object):
                                                  self._name + "-console.sock")
             chardev = ('socket,id=console,path=%s,server,nowait' %
                        self._console_address)
-            device = '%s,chardev=console' % self._console_device_type
-            args.extend(['-chardev', chardev, '-device', device])
+            args.extend(['-chardev', chardev])
+            if len(self._console_device_type):
+                device = '%s,chardev=console' % self._console_device_type
+                args.extend(['-device', device])
         return args
 
     def _pre_launch(self):
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH v3 3/6] tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole
  2018-10-13 15:15 [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Philippe Mathieu-Daudé
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 1/6] tests/acceptance: Rename the generic BootLinuxConsole test as test_x86_64_pc Philippe Mathieu-Daudé
  2018-10-13 15:15 ` [Qemu-devel] [RFC PATCH v3 2/6] tests/acceptance: Add a kludge to not use the default console Philippe Mathieu-Daudé
@ 2018-10-13 15:15 ` Philippe Mathieu-Daudé
  2018-10-19 17:42   ` Cleber Rosa
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 4/6] tests/acceptance: Add test_mipsel_5kc_malta " Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-13 15:15 UTC (permalink / raw)
  To: Alex Bennée, Cleber Rosa, Eduardo Habkost
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Lukáš Doktor, Fam Zheng

Similar to the test_x86_64_pc test, this boots a Linux kernel on a
Malta board (MIPS 4Kc big-endian) and verify the serial is working.

This test requires the dpkg-deb tool (apt/dnf install dpkg) to
extract the kernel from the Debian package.

  $ avocado --show=console run -p arch=mips tests/acceptance/boot_linux_console.py
  console: [    0.000000] Initializing cgroup subsys cpuset
  console: [    0.000000] Initializing cgroup subsys cpu
  console: [    0.000000] Linux version 2.6.32-5-4kc-malta (Debian 2.6.32-48) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 Sat Feb 16 12:43:42 UTC 2013
  console: [    0.000000]
  console: [    0.000000] LINUX started...
  console: [    0.000000] bootconsole [early0] enabled
  console: [    0.000000] CPU revision is: 00019300 (MIPS 24Kc)
  console: [    0.000000] FPU revision is: 00739300
  console: [    0.000000] Determined physical RAM map:
  console: [    0.000000]  memory: 00001000 @ 00000000 (reserved)
  console: [    0.000000]  memory: 000ef000 @ 00001000 (ROM data)
  console: [    0.000000]  memory: 005b7000 @ 000f0000 (reserved)
  console: [    0.000000]  memory: 03958000 @ 006a7000 (usable)
  console: [    0.000000] Wasting 54496 bytes for tracking 1703 unused pages
  console: [    0.000000] Initrd not found or empty - disabling initrd
  console: [    0.000000] Zone PFN ranges:
  console: [    0.000000]   DMA      0x00000000 -> 0x00001000
  console: [    0.000000]   Normal   0x00001000 -> 0x00003fff
  console: [    0.000000] Movable zone start PFN for each node
  console: [    0.000000] early_node_map[1] active PFN ranges
  console: [    0.000000]     0: 0x00000000 -> 0x00003fff
  console: [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16255
  console: [    0.000000] Kernel command line: console=ttyS0 printk.time=0

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/acceptance/boot_linux_console.py | 46 ++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 3aa4dbe5f9..81c96fc338 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -9,6 +9,7 @@
 # later.  See the COPYING file in the top-level directory.
 
 import logging
+import subprocess
 
 from avocado_qemu import Test
 
@@ -47,3 +48,48 @@ class BootLinuxConsole(Test):
                 break
             if 'Kernel panic - not syncing' in msg:
                 self.fail("Kernel panic reached")
+
+    def test_mips_4kc_malta(self):
+        """
+        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
+        the kernel from the Debian package.
+
+        The kernel can be rebuilt using this Debian kernel source [1] and
+        following the instructions on [2].
+
+        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
+        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/#linux-source-2.6.32_2.6.32-48
+
+        :avocado: tags=arch:mips
+        """
+        if self.arch != 'mips': # FIXME use 'arch' tag in parent class?
+            self.cancel('Currently specific to the %s target arch' % self.arch)
+
+        deb_url = ('http://snapshot.debian.org/archive/debian/20130217T032700Z/'
+                   'pool/main/l/linux-2.6/'
+                   'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
+        deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
+        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir]) # FIXME move to avocado ...
+        kernel_path = self.workdir + '/boot/vmlinux-2.6.32-5-4kc-malta'          # FIXME ... and use from assets?
+
+        self.vm.set_arch(self.arch)
+        self.vm.set_machine('malta')
+        self.vm.set_console("") # XXX this disable isa-serial to use -serial ...
+        kernel_command_line = 'console=ttyS0 printk.time=0'
+        self.vm.add_args('-m', "64",
+                         '-serial', "chardev:console", # XXX ... here.
+                         '-kernel', kernel_path,
+                         '-append', kernel_command_line)
+
+        # FIXME below to parent class?
+        self.vm.launch()
+        console = self.vm.console_socket.makefile()
+        console_logger = logging.getLogger('console')
+        while True:
+            msg = console.readline()
+            console_logger.debug(msg.strip())
+            if 'Kernel command line: %s' % kernel_command_line in msg:
+                break
+            if 'Kernel panic - not syncing' in msg:
+                self.fail("Kernel panic reached")
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH v3 4/6] tests/acceptance: Add test_mipsel_5kc_malta in BootLinuxConsole
  2018-10-13 15:15 [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 3/6] tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole Philippe Mathieu-Daudé
@ 2018-10-13 15:15 ` Philippe Mathieu-Daudé
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 5/6] tests/acceptance: Add test_sh4_r2d " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-13 15:15 UTC (permalink / raw)
  To: Alex Bennée, Cleber Rosa, Eduardo Habkost
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Lukáš Doktor, Fam Zheng

Similar to the test_x86_64_pc test, this boots a Linux kernel on a
Malta board (MIPS 5Kc little-endian) and verify the serial is working.

This test requires the dpkg-deb tool (apt/dnf install dpkg) to
extract the kernel from the Debian package.

  $ avocado run -p arch=mips64el tests/acceptance/boot_linux_console.py
  JOB ID     : 6450db71ca27757f53e13809625fc5107d0e6e4e
  JOB LOG    : /home/phil/avocado/job-results/job-2018-10-13T13.34-6450db7/job.log
   (1/3) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc: CANCEL: Currently specific to the x86_64 target arch (0.00 s)
   (2/3) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta: CANCEL: Currently specific to the mips target arch (0.00 s)
   (3/3) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mipsel_5kc_malta: PASS (0.78 s)
  RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 2
  JOB TIME   : 0.97 s

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/acceptance/boot_linux_console.py | 44 ++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 81c96fc338..e4a60297bf 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -93,3 +93,47 @@ class BootLinuxConsole(Test):
                 break
             if 'Kernel panic - not syncing' in msg:
                 self.fail("Kernel panic reached")
+
+    def test_mipsel_5kc_malta(self):
+        """
+        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
+        the kernel from the Debian package.
+
+        The kernel can be rebuilt using this Debian kernel source [1] and
+        following the instructions on [2].
+
+        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
+        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/#linux-source-2.6.32_2.6.32-48
+
+        :avocado: tags=arch:mips64el
+        """
+        if self.arch != 'mips64el':
+            self.cancel('Currently specific to the %s target arch' % self.arch)
+
+        deb_url = ('http://snapshot.debian.org/archive/debian/20130217T032700Z/'
+                   'pool/main/l/linux-2.6/'
+                   'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
+        deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
+        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir])
+        kernel_path = self.workdir + '/boot/vmlinux-2.6.32-5-5kc-malta'
+
+        self.vm.set_arch(self.arch)
+        self.vm.set_machine('malta')
+        self.vm.set_console("") # XXX
+        kernel_command_line = 'console=ttyS0 printk.time=0'
+        self.vm.add_args('-m', "64",
+                         '-serial', "chardev:console",
+                         '-kernel', kernel_path,
+                         '-append', kernel_command_line)
+
+        self.vm.launch()
+        console = self.vm.console_socket.makefile()
+        console_logger = logging.getLogger('console')
+        while True:
+            msg = console.readline()
+            console_logger.debug(msg.strip())
+            if 'Kernel command line: %s' % kernel_command_line in msg:
+                break
+            if 'Kernel panic - not syncing' in msg:
+                self.fail("Kernel panic reached")
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [PATCH v3 5/6] tests/acceptance: Add test_sh4_r2d in BootLinuxConsole
  2018-10-13 15:15 [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 4/6] tests/acceptance: Add test_mipsel_5kc_malta " Philippe Mathieu-Daudé
@ 2018-10-13 15:15 ` Philippe Mathieu-Daudé
  2018-10-13 15:56   ` Philippe Mathieu-Daudé
  2018-10-13 15:15 ` [Qemu-devel] [RFC PATCH v3 6/6] tests/acceptance: Add test_sh4_r2d in BootLinuxTracing Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-13 15:15 UTC (permalink / raw)
  To: Alex Bennée, Cleber Rosa, Eduardo Habkost, BALATON Zoltan,
	Magnus Damm
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Lukáš Doktor, Fam Zheng

Similar to the test_x86_64_pc test, this boots a Linux kernel on a
R2D board (SH4 little-endian) and verify the serial is working.

This test requires the dpkg-deb tool (apt/dnf install dpkg) to
extract the kernel from the Debian package.

Note, due to a problem with the serial on this machine, this test
is currently disabled.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/acceptance/boot_linux_console.py | 48 ++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index e4a60297bf..8f99cc0d7c 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -11,6 +11,7 @@
 import logging
 import subprocess
 
+from avocado import skip
 from avocado_qemu import Test
 
 
@@ -137,3 +138,50 @@ class BootLinuxConsole(Test):
                 break
             if 'Kernel panic - not syncing' in msg:
                 self.fail("Kernel panic reached")
+
+    @skip("console not working on r2d machine")
+    def test_sh4_r2d(self):
+        """
+        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
+        the kernel from the Debian package.
+        This test also requires the QEMU binary to be compiled with:
+
+          $ configure ... --enable-trace-backends=log
+
+        The kernel can be rebuilt using this Debian kernel source [1] and
+        following the instructions on [2].
+
+        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
+        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-30/#linux-source-2.6.32_2.6.32-30
+
+        :avocado: tags=arch:sh4
+        """
+        if self.arch != 'sh4':
+            self.cancel('Currently specific to the %s target arch' % self.arch)
+
+        deb_url = ('http://snapshot.debian.org/archive/'
+                   'debian-ports/20110116T065852Z/pool-sh4/main/l/'
+                   'linux-2.6/linux-image-2.6.32-5-sh7751r_2.6.32-30_sh4.deb')
+        deb_hash = '8025e503319dc8ad786756e3afaa8eb868e9ef59'
+        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir])
+        kernel_path = self.workdir + '/boot/vmlinuz-2.6.32-5-sh7751r'
+
+        self.vm.set_arch(self.arch)
+        self.vm.set_machine('r2d')
+        self.vm.set_console("") # XXX
+        kernel_command_line = 'console=ttyS0 printk.time=0 noiotrap'
+        self.vm.add_args('-serial', "chardev:console",
+                         '-kernel', kernel_path,
+                         '-append', kernel_command_line)
+
+        self.vm.launch()
+        console = self.vm.console_socket.makefile()
+        console_logger = logging.getLogger('console')
+        while True:
+            msg = console.readline()
+            console_logger.debug(msg.strip())
+            if 'Kernel command line: %s' % kernel_command_line in msg:
+                break
+            if 'Kernel panic - not syncing' in msg:
+                self.fail("Kernel panic reached")
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Qemu-devel] [RFC PATCH v3 6/6] tests/acceptance: Add test_sh4_r2d in BootLinuxTracing
  2018-10-13 15:15 [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 5/6] tests/acceptance: Add test_sh4_r2d " Philippe Mathieu-Daudé
@ 2018-10-13 15:15 ` Philippe Mathieu-Daudé
  2018-10-20  0:02   ` Cleber Rosa
  2018-10-15  6:41 ` [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Thomas Huth
  2018-10-19  5:13 ` Philippe Mathieu-Daudé
  7 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-13 15:15 UTC (permalink / raw)
  To: Alex Bennée, Cleber Rosa, Eduardo Habkost, BALATON Zoltan,
	Magnus Damm
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Lukáš Doktor, Fam Zheng

Similar to the test_x86_64_pc test, this boots a Linux kernel on a
R2D board (SH4 little-endian) and verify the usb is working by looking
at the usb trace events. Thus this test requires the QEMU binary to be
compiled with:

  $ configure ... --enable-trace-backends=log

This test also requires the dpkg-deb tool (apt/dnf install dpkg) to
extract the kernel from the Debian package.

  $ avocado --show=app,trace run -p arch=sh4 tests/acceptance/boot_linux_console.py
  JOB ID     : dc45be27f5d1edb8289a1ede139e107bbc55b045
  JOB LOG    : /home/phil/avocado/job-results/job-2018-10-13T14.46-dc45be2/job.log
   (1/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc: CANCEL: Currently specific to the x86_64 target arch (0.00 s)
   (2/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta: CANCEL: Currently specific to the sh4 target arch (0.00 s)
   (3/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mipsel_5kc_malta: CANCEL: Currently specific to the sh4 target arch (0.00 s)
   (4/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_sh4_r2d: SKIP: console not working on r2d machine
   (5/5) tests/acceptance/boot_linux_console.py:BootLinuxTracing.test_sh4_r2d:  /
  trace: 22770@1539434809.450006:usb_ohci_init_time usb_bit_time=1000000 usb_frame_time=83
  trace: 22770@1539434809.453017:usb_ohci_port_attach port #0
  trace: 22770@1539434809.454827:usb_ohci_reset sysbus-ohci
  trace: 22770@1539434809.454833:usb_ohci_stop sysbus-ohci: USB Suspended
  trace: 22770@1539434809.454835:usb_ohci_stop sysbus-ohci: USB Suspended
  trace: 22770@1539434809.454837:usb_ohci_port_detach port #0
  trace: 22770@1539434809.454839:usb_ohci_port_attach port #0
  trace: 22770@1539434811.588702:usb_ohci_reset sysbus-ohci
  trace: 22770@1539434811.588711:usb_ohci_stop sysbus-ohci: USB Suspended
  trace: 22770@1539434811.589062:usb_ohci_set_ctl sysbus-ohci: new state 0x80
  trace: 22770@1539434811.589067:usb_ohci_start sysbus-ohci: USB Operational
  trace: 22770@1539434811.589253:usb_ohci_hub_power_up powered up all ports
  PASS (2.43 s)
  RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 3
  JOB TIME   : 2.67 s

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/acceptance/boot_linux_console.py | 64 ++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 8f99cc0d7c..e11993bf98 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -8,11 +8,22 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or
 # later.  See the COPYING file in the top-level directory.
 
+import os
 import logging
 import subprocess
 
 from avocado import skip
 from avocado_qemu import Test
+from avocado.utils.wait import wait_for
+
+
+def read_stream_for_string(stream, expected_string, logger=None):
+    msg = stream.readline()
+    if len(msg) == 0:
+        return False
+    if logger:
+        logger.debug(msg.strip())
+    return expected_string in msg
 
 
 class BootLinuxConsole(Test):
@@ -185,3 +196,56 @@ class BootLinuxConsole(Test):
                 break
             if 'Kernel panic - not syncing' in msg:
                 self.fail("Kernel panic reached")
+
+class BootLinuxTracing(Test):
+    """
+    Boots a Linux kernel and checks that via the Tracing framework that
+    a specific trace events occured, demostrating the kernel is operational.
+
+    :avocado: enable
+    """
+
+    timeout = 60
+
+    def test_sh4_r2d(self):
+        """
+        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
+        the kernel from the Debian package.
+        This test also requires the QEMU binary to be compiled with:
+
+          $ configure ... --enable-trace-backends=log
+
+        The kernel can be rebuilt using this Debian kernel source [1] and
+        following the instructions on [2].
+
+        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
+        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-30/#linux-source-2.6.32_2.6.32-30
+
+        :avocado: tags=arch:sh4
+        """
+        if self.arch != 'sh4':
+            self.cancel('Currently specific to the %s target arch' % self.arch)
+
+        deb_url = ('http://snapshot.debian.org/archive/'
+                   'debian-ports/20110116T065852Z/pool-sh4/main/l/'
+                   'linux-2.6/linux-image-2.6.32-5-sh7751r_2.6.32-30_sh4.deb')
+        deb_hash = '8025e503319dc8ad786756e3afaa8eb868e9ef59'
+        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir])
+        kernel_path = self.workdir + '/boot/vmlinuz-2.6.32-5-sh7751r'
+        trace_path = os.path.join(self.workdir, 'trace.log')
+        trace_logger = logging.getLogger('trace')
+
+        self.vm.set_arch(self.arch)
+        self.vm.set_machine('r2d')
+        kernel_command_line = 'noiotrap'
+        self.vm.add_args('-trace', "enable=usb_ohci_*,file=" + trace_path,
+                         '-kernel', kernel_path,
+                         '-append', kernel_command_line)
+
+        self.vm.launch()
+        if not wait_for(read_stream_for_string, timeout=15, step=0,
+                        args=(open(trace_path),
+                              'usb_ohci_hub_power_up powered up all ports',
+                              trace_logger)):
+            self.fail("Machine failed to boot")
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 5/6] tests/acceptance: Add test_sh4_r2d in BootLinuxConsole
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 5/6] tests/acceptance: Add test_sh4_r2d " Philippe Mathieu-Daudé
@ 2018-10-13 15:56   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-13 15:56 UTC (permalink / raw)
  To: Alex Bennée, Cleber Rosa, Eduardo Habkost, BALATON Zoltan,
	Magnus Damm
  Cc: qemu-devel, Lukáš Doktor, Fam Zheng

On 10/13/18 5:15 PM, Philippe Mathieu-Daudé wrote:
> Similar to the test_x86_64_pc test, this boots a Linux kernel on a
> R2D board (SH4 little-endian) and verify the serial is working.
> 
> This test requires the dpkg-deb tool (apt/dnf install dpkg) to
> extract the kernel from the Debian package.
> 
> Note, due to a problem with the serial on this machine, this test
> is currently disabled.

Reading [1] "SH7751R has both SCI and SCIF ports. ttySC1 is the second
(SCIF) port." and [2] I could figure the correct kernel arguments and
the -serial argument out.

[1] http://lists.busybox.net/pipermail/buildroot/2011-October/047070.html
[2] http://lists.busybox.net/pipermail/buildroot/2011-October/047070.html

With the following patch:

-- >8 --
@@ -13,5 +13,4 @@ import logging
 import subprocess

-from avocado import skip
 from avocado_qemu import Test
 from avocado.utils.wait import wait_for
@@ -151,5 +150,4 @@ class BootLinuxConsole(Test):
                 self.fail("Kernel panic reached")

-    @skip("console not working on r2d machine")
     def test_sh4_r2d(self):
         """
@@ -182,6 +180,8 @@ class BootLinuxConsole(Test):
         self.vm.set_machine('r2d')
         self.vm.set_console("") # XXX
-        kernel_command_line = 'console=ttyS0 printk.time=0 noiotrap'
-        self.vm.add_args('-serial', "chardev:console",
+        kernel_command_line = 'console=ttySC0 printk.time=0 noiotrap'
+        self.vm.add_args('-serial', 'null',
+                         '-serial', "chardev:console",
+                         '-display', 'none',
                          '-kernel', kernel_path,
                          '-append', kernel_command_line)
---

I finally get:

 (1/4)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc:
CANCEL: Currently specific to the x86_64 target arch (0.00 s)
 (2/4)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta:
CANCEL: Currently specific to the sh4 target arch (0.00 s)
 (3/4)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mipsel_5kc_malta:
CANCEL: Currently specific to the sh4 target arch (0.00 s)
 (4/4)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_sh4_r2d: /
console: [    0.000000] Initializing cgroup subsys cpuset
console: [    0.000000] Initializing cgroup subsys cpu
console: [    0.000000] Linux version 2.6.32-5-sh7751r (Debian
2.6.32-30) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) )
#1 Thu Jan 13 08:23:18 UTC 2011
console: [    0.000000] Boot params:
console: [    0.000000] ... MOUNT_ROOT_RDONLY - 00000000
console: [    0.000000] ... RAMDISK_FLAGS     - 00000000
console: [    0.000000] ... ORIG_ROOT_DEV     - 00000000
console: [    0.000000] ... LOADER_TYPE       - 00000000
console: [    0.000000] ... INITRD_START      - 00000000
console: [    0.000000] ... INITRD_SIZE       - 00000000
console: [    0.000000] Booting machvec: RTS7751R2D
console: [    0.000000] Renesas Technology Sales RTS7751R2D support.
console: [    0.000000] FPGA version:1 (revision:0)
console: [    0.000000] Node 0: start_pfn = 0xc000, low = 0x10000
console: [    0.000000] Zone PFN ranges:
console: [    0.000000]   Normal   0x0000c000 -> 0x00010000
console: [    0.000000] Movable zone start PFN for each node
console: [    0.000000] early_node_map[1] active PFN ranges
console: [    0.000000]     0: 0x0000c000 -> 0x00010000
console: [    0.000000] Built 1 zonelists in Zone order, mobility
grouping on.  Total pages: 16256
console: [    0.000000] Kernel command line: console=ttySC0
printk.time=0 noiotrap
PASS (1.92 s)

> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/acceptance/boot_linux_console.py | 48 ++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
> 
> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
> index e4a60297bf..8f99cc0d7c 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -11,6 +11,7 @@
>  import logging
>  import subprocess
>  
> +from avocado import skip
>  from avocado_qemu import Test
>  
>  
> @@ -137,3 +138,50 @@ class BootLinuxConsole(Test):
>                  break
>              if 'Kernel panic - not syncing' in msg:
>                  self.fail("Kernel panic reached")
> +
> +    @skip("console not working on r2d machine")
> +    def test_sh4_r2d(self):
> +        """
> +        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
> +        the kernel from the Debian package.
> +        This test also requires the QEMU binary to be compiled with:
> +
> +          $ configure ... --enable-trace-backends=log
> +
> +        The kernel can be rebuilt using this Debian kernel source [1] and
> +        following the instructions on [2].
> +
> +        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
> +        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-30/#linux-source-2.6.32_2.6.32-30
> +
> +        :avocado: tags=arch:sh4
> +        """
> +        if self.arch != 'sh4':
> +            self.cancel('Currently specific to the %s target arch' % self.arch)
> +
> +        deb_url = ('http://snapshot.debian.org/archive/'
> +                   'debian-ports/20110116T065852Z/pool-sh4/main/l/'
> +                   'linux-2.6/linux-image-2.6.32-5-sh7751r_2.6.32-30_sh4.deb')
> +        deb_hash = '8025e503319dc8ad786756e3afaa8eb868e9ef59'
> +        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
> +        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir])
> +        kernel_path = self.workdir + '/boot/vmlinuz-2.6.32-5-sh7751r'
> +
> +        self.vm.set_arch(self.arch)
> +        self.vm.set_machine('r2d')
> +        self.vm.set_console("") # XXX
> +        kernel_command_line = 'console=ttyS0 printk.time=0 noiotrap'
> +        self.vm.add_args('-serial', "chardev:console",
> +                         '-kernel', kernel_path,
> +                         '-append', kernel_command_line)
> +
> +        self.vm.launch()
> +        console = self.vm.console_socket.makefile()
> +        console_logger = logging.getLogger('console')
> +        while True:
> +            msg = console.readline()
> +            console_logger.debug(msg.strip())
> +            if 'Kernel command line: %s' % kernel_command_line in msg:
> +                break
> +            if 'Kernel panic - not syncing' in msg:
> +                self.fail("Kernel panic reached")
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests
  2018-10-13 15:15 [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2018-10-13 15:15 ` [Qemu-devel] [RFC PATCH v3 6/6] tests/acceptance: Add test_sh4_r2d in BootLinuxTracing Philippe Mathieu-Daudé
@ 2018-10-15  6:41 ` Thomas Huth
  2018-10-19  5:13 ` Philippe Mathieu-Daudé
  7 siblings, 0 replies; 19+ messages in thread
From: Thomas Huth @ 2018-10-15  6:41 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	Alex Bennée, Cleber Rosa, Eduardo Habkost, BALATON Zoltan,
	Magnus Damm
  Cc: Lukáš Doktor, Fam Zheng, qemu-devel

On 2018-10-13 17:15, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> Another neanderthal approach to add multi-arch acceptance tests using Avocado.
> 
> I couldn't figure how to use the R2D serial, the kernel boots using the sm501
> display correctly, but I'm too console-oriented to write UI tests...
> 
> Magnus or Zoltan, any hint on this?

IIRC you have to use the second UART, see:

https://wiki.qemu.org/Documentation/Platforms/SH4

 Thomas

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests
  2018-10-13 15:15 [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2018-10-15  6:41 ` [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Thomas Huth
@ 2018-10-19  5:13 ` Philippe Mathieu-Daudé
  7 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-19  5:13 UTC (permalink / raw)
  To: Alex Bennée, Cleber Rosa, Eduardo Habkost, BALATON Zoltan,
	Magnus Damm
  Cc: qemu-devel@nongnu.org Developers, Lukáš Doktor, Fam Zheng

Ping for review before I send v3?

v3:
- fix patch 4 "Add test_sh4_r2d in BootLinuxConsole"
- drop patch 5? "Add test_sh4_r2d in BootLinuxTracing"

On Sat, Oct 13, 2018 at 5:15 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Another neanderthal approach to add multi-arch acceptance tests using Avocado.
>
> I couldn't figure how to use the R2D serial, the kernel boots using the sm501
> display correctly, but I'm too console-oriented to write UI tests...
>
> Magnus or Zoltan, any hint on this?

Fixed (see reply to patch #5)

>
> Thanks
>
> Phil.
>
> Since v2 (http://lists.gnu.org/archive/html/qemu-devel/2018-06/msg06370.html):
> - use Debian packaged kernels, add link to the sources and a comment
>   about how to rebuild these images (Alex)
> - use self.arch from Cleber's series
> - add mips64el kernel console test
> - add sh4 test using the tracing framework
>
> Since v1 (http://lists.gnu.org/archive/html/qemu-devel/2018-04/msg03076.html):
> - we can now run other archs (Cleber)
>
> Based-on: 20181009232607.15521-1-crosa@redhat.com
> "Acceptance Tests: basic architecture support" from Cleber Rosa
> https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg01821.html
>
> Philippe Mathieu-Daudé (6):
>   tests/acceptance: Rename the generic BootLinuxConsole test as
>     test_x86_64_pc
>   tests/acceptance: Add a kludge to not use the default console
>   tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole
>   tests/acceptance: Add test_mipsel_5kc_malta in BootLinuxConsole
>   tests/acceptance: Add test_sh4_r2d in BootLinuxConsole
>   tests/acceptance: Add test_sh4_r2d in BootLinuxTracing

Thanks,

Phil.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v3 2/6] tests/acceptance: Add a kludge to not use the default console
  2018-10-13 15:15 ` [Qemu-devel] [RFC PATCH v3 2/6] tests/acceptance: Add a kludge to not use the default console Philippe Mathieu-Daudé
@ 2018-10-19 17:37   ` Cleber Rosa
  2018-10-19 17:45     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 19+ messages in thread
From: Cleber Rosa @ 2018-10-19 17:37 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Alex Bennée, Eduardo Habkost
  Cc: Lukáš Doktor, Fam Zheng, qemu-devel



On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
> The board already instantiate the proper devices, we don't want to
> add extra devices but connect the chardev to one of the serial already
> available.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  scripts/qemu.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/qemu.py b/scripts/qemu.py
> index fca9b76990..7e779954e6 100644
> --- a/scripts/qemu.py
> +++ b/scripts/qemu.py
> @@ -221,8 +221,10 @@ class QEMUMachine(object):
>                                                   self._name + "-console.sock")
>              chardev = ('socket,id=console,path=%s,server,nowait' %
>                         self._console_address)
> -            device = '%s,chardev=console' % self._console_device_type
> -            args.extend(['-chardev', chardev, '-device', device])
> +            args.extend(['-chardev', chardev])
> +            if len(self._console_device_type):

Considering `self._console_device_type` will come from `set_console()`,
either explicitly as the "device_type" parameter, or from the list on
CONSOLE_DEV_TYPES, wouldn't it make more sense to just drop the
definitions for the machine types that don't need an explicit device?

That way, self.set_console() could be called with no arguments (instead
of the empty string).  And this check would become:

  if self._console_device_type is not None:

> +                device = '%s,chardev=console' % self._console_device_type
> +                args.extend(['-device', device])
>          return args
>  
>      def _pre_launch(self):
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 3/6] tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 3/6] tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole Philippe Mathieu-Daudé
@ 2018-10-19 17:42   ` Cleber Rosa
  2018-10-19 18:41     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 19+ messages in thread
From: Cleber Rosa @ 2018-10-19 17:42 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Alex Bennée, Eduardo Habkost
  Cc: qemu-devel, Lukáš Doktor, Fam Zheng



On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
> Similar to the test_x86_64_pc test, this boots a Linux kernel on a
> Malta board (MIPS 4Kc big-endian) and verify the serial is working.
> 
> This test requires the dpkg-deb tool (apt/dnf install dpkg) to
> extract the kernel from the Debian package.
> 

Debian packages are really "ar" archives, with a control.tar.gz and
data.tar.gz in them.  More on that later.

>   $ avocado --show=console run -p arch=mips tests/acceptance/boot_linux_console.py
>   console: [    0.000000] Initializing cgroup subsys cpuset
>   console: [    0.000000] Initializing cgroup subsys cpu
>   console: [    0.000000] Linux version 2.6.32-5-4kc-malta (Debian 2.6.32-48) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 Sat Feb 16 12:43:42 UTC 2013
>   console: [    0.000000]
>   console: [    0.000000] LINUX started...
>   console: [    0.000000] bootconsole [early0] enabled
>   console: [    0.000000] CPU revision is: 00019300 (MIPS 24Kc)
>   console: [    0.000000] FPU revision is: 00739300
>   console: [    0.000000] Determined physical RAM map:
>   console: [    0.000000]  memory: 00001000 @ 00000000 (reserved)
>   console: [    0.000000]  memory: 000ef000 @ 00001000 (ROM data)
>   console: [    0.000000]  memory: 005b7000 @ 000f0000 (reserved)
>   console: [    0.000000]  memory: 03958000 @ 006a7000 (usable)
>   console: [    0.000000] Wasting 54496 bytes for tracking 1703 unused pages
>   console: [    0.000000] Initrd not found or empty - disabling initrd
>   console: [    0.000000] Zone PFN ranges:
>   console: [    0.000000]   DMA      0x00000000 -> 0x00001000
>   console: [    0.000000]   Normal   0x00001000 -> 0x00003fff
>   console: [    0.000000] Movable zone start PFN for each node
>   console: [    0.000000] early_node_map[1] active PFN ranges
>   console: [    0.000000]     0: 0x00000000 -> 0x00003fff
>   console: [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16255
>   console: [    0.000000] Kernel command line: console=ttyS0 printk.time=0
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/acceptance/boot_linux_console.py | 46 ++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
> 
> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
> index 3aa4dbe5f9..81c96fc338 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -9,6 +9,7 @@
>  # later.  See the COPYING file in the top-level directory.
>  
>  import logging
> +import subprocess

It's definitely your call, but I like to think that
avocado.utils.process provides simpler and more capable functions:

https://avocado-framework.readthedocs.io/en/65.0/api/utils/avocado.utils.html#avocado.utils.process.run

>  
>  from avocado_qemu import Test
>  
> @@ -47,3 +48,48 @@ class BootLinuxConsole(Test):
>                  break
>              if 'Kernel panic - not syncing' in msg:
>                  self.fail("Kernel panic reached")
> +
> +    def test_mips_4kc_malta(self):
> +        """
> +        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
> +        the kernel from the Debian package.
> +
> +        The kernel can be rebuilt using this Debian kernel source [1] and
> +        following the instructions on [2].
> +
> +        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
> +        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/#linux-source-2.6.32_2.6.32-48
> +
> +        :avocado: tags=arch:mips
> +        """
> +        if self.arch != 'mips': # FIXME use 'arch' tag in parent class?
> +            self.cancel('Currently specific to the %s target arch' % self.arch)
> +

I missed how the arch tag in the parent class (common to all tests here)
would be useful for this specific test.

> +        deb_url = ('http://snapshot.debian.org/archive/debian/20130217T032700Z/'
> +                   'pool/main/l/linux-2.6/'
> +                   'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
> +        deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
> +        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
> +        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir]) # FIXME move to avocado ...

This could become:

 # from avocado.utils.process import run
 run("ar p %s data.tar.gz | tar zxf - -C %s
./boot/vmlinux-2.6.32-5-4kc-malta" % (deb_path, self.workdir), shell=True)

> +        kernel_path = self.workdir + '/boot/vmlinux-2.6.32-5-4kc-malta'          # FIXME ... and use from assets?
> +

Putting produced/processed files back into the cache would be nice
addition to the asset fetcher (or related tools).  Not there yet, though.

> +        self.vm.set_arch(self.arch)
> +        self.vm.set_machine('malta')
> +        self.vm.set_console("") # XXX this disable isa-serial to use -serial ...

See the comments on the previous patch.  Basically, if a machine doesn't
need an explicit console device to be added, set_console() should do
just that (not add one).  The ideal API would be to call set_console()
without any explicit parameter IMO.

That assumes, what I believe to be true, that we don't want to setup
multiple *console* devices per QEMUMachine, right?

Regards,
- Cleber.

> +        kernel_command_line = 'console=ttyS0 printk.time=0'
> +        self.vm.add_args('-m', "64",
> +                         '-serial', "chardev:console", # XXX ... here.
> +                         '-kernel', kernel_path,
> +                         '-append', kernel_command_line)
> +
> +        # FIXME below to parent class?
> +        self.vm.launch()
> +        console = self.vm.console_socket.makefile()
> +        console_logger = logging.getLogger('console')
> +        while True:
> +            msg = console.readline()
> +            console_logger.debug(msg.strip())
> +            if 'Kernel command line: %s' % kernel_command_line in msg:
> +                break
> +            if 'Kernel panic - not syncing' in msg:
> +                self.fail("Kernel panic reached")
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v3 2/6] tests/acceptance: Add a kludge to not use the default console
  2018-10-19 17:37   ` Cleber Rosa
@ 2018-10-19 17:45     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-19 17:45 UTC (permalink / raw)
  To: Cleber Rosa, Philippe Mathieu-Daudé,
	Alex Bennée, Eduardo Habkost
  Cc: Lukáš Doktor, Fam Zheng, qemu-devel

On 19/10/2018 19:37, Cleber Rosa wrote:
> On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
>> The board already instantiate the proper devices, we don't want to
>> add extra devices but connect the chardev to one of the serial already
>> available.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  scripts/qemu.py | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/scripts/qemu.py b/scripts/qemu.py
>> index fca9b76990..7e779954e6 100644
>> --- a/scripts/qemu.py
>> +++ b/scripts/qemu.py
>> @@ -221,8 +221,10 @@ class QEMUMachine(object):
>>                                                   self._name + "-console.sock")
>>              chardev = ('socket,id=console,path=%s,server,nowait' %
>>                         self._console_address)
>> -            device = '%s,chardev=console' % self._console_device_type
>> -            args.extend(['-chardev', chardev, '-device', device])
>> +            args.extend(['-chardev', chardev])
>> +            if len(self._console_device_type):
> 
> Considering `self._console_device_type` will come from `set_console()`,
> either explicitly as the "device_type" parameter, or from the list on
> CONSOLE_DEV_TYPES, wouldn't it make more sense to just drop the
> definitions for the machine types that don't need an explicit device?
> 
> That way, self.set_console() could be called with no arguments (instead
> of the empty string).  And this check would become:
> 
>   if self._console_device_type is not None:

Clever Cleber!

> 
>> +                device = '%s,chardev=console' % self._console_device_type
>> +                args.extend(['-device', device])
>>          return args
>>  
>>      def _pre_launch(self):
>>
> 
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/6] tests/acceptance: Rename the generic BootLinuxConsole test as test_x86_64_pc
  2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 1/6] tests/acceptance: Rename the generic BootLinuxConsole test as test_x86_64_pc Philippe Mathieu-Daudé
@ 2018-10-19 18:15   ` Cleber Rosa
  0 siblings, 0 replies; 19+ messages in thread
From: Cleber Rosa @ 2018-10-19 18:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Alex Bennée, Eduardo Habkost
  Cc: qemu-devel, Lukáš Doktor, Fam Zheng



On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/acceptance/boot_linux_console.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
> index ba3ac036da..3aa4dbe5f9 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -15,7 +15,7 @@ from avocado_qemu import Test
>  
>  class BootLinuxConsole(Test):
>      """
> -    Boots a x86_64 Linux kernel and checks that the console is operational
> +    Boots a Linux kernel and checks that the console is operational
>      and the kernel command line is properly passed from QEMU to the kernel
>  
>      :avocado: enable
> @@ -23,7 +23,7 @@ class BootLinuxConsole(Test):
>  
>      timeout = 60
>  
> -    def test(self):
> +    def test_x86_64_pc(self):
>          if self.arch != 'x86_64':
>              self.cancel('Currently specific to the x86_64 target arch')
>          kernel_url = ('https://mirrors.kernel.org/fedora/releases/28/'
> 


This looks right, but given "self.arch" is still not on master, so I'm
holding on to giving the reviewed-by/tested-by.

Question: do you believe a maintainer and/or developer would want to
test specific machine types?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 3/6] tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole
  2018-10-19 17:42   ` Cleber Rosa
@ 2018-10-19 18:41     ` Philippe Mathieu-Daudé
  2018-10-19 21:17       ` Cleber Rosa
  0 siblings, 1 reply; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-19 18:41 UTC (permalink / raw)
  To: Cleber Rosa, Philippe Mathieu-Daudé,
	Alex Bennée, Eduardo Habkost
  Cc: Lukáš Doktor, Fam Zheng, qemu-devel

On 19/10/2018 19:42, Cleber Rosa wrote:
> 
> 
> On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
>> Similar to the test_x86_64_pc test, this boots a Linux kernel on a
>> Malta board (MIPS 4Kc big-endian) and verify the serial is working.
>>
>> This test requires the dpkg-deb tool (apt/dnf install dpkg) to
>> extract the kernel from the Debian package.
>>
> 
> Debian packages are really "ar" archives, with a control.tar.gz and
> data.tar.gz in them.  More on that later.
> 
>>   $ avocado --show=console run -p arch=mips tests/acceptance/boot_linux_console.py
>>   console: [    0.000000] Initializing cgroup subsys cpuset
>>   console: [    0.000000] Initializing cgroup subsys cpu
>>   console: [    0.000000] Linux version 2.6.32-5-4kc-malta (Debian 2.6.32-48) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 Sat Feb 16 12:43:42 UTC 2013
>>   console: [    0.000000]
>>   console: [    0.000000] LINUX started...
>>   console: [    0.000000] bootconsole [early0] enabled
>>   console: [    0.000000] CPU revision is: 00019300 (MIPS 24Kc)
>>   console: [    0.000000] FPU revision is: 00739300
>>   console: [    0.000000] Determined physical RAM map:
>>   console: [    0.000000]  memory: 00001000 @ 00000000 (reserved)
>>   console: [    0.000000]  memory: 000ef000 @ 00001000 (ROM data)
>>   console: [    0.000000]  memory: 005b7000 @ 000f0000 (reserved)
>>   console: [    0.000000]  memory: 03958000 @ 006a7000 (usable)
>>   console: [    0.000000] Wasting 54496 bytes for tracking 1703 unused pages
>>   console: [    0.000000] Initrd not found or empty - disabling initrd
>>   console: [    0.000000] Zone PFN ranges:
>>   console: [    0.000000]   DMA      0x00000000 -> 0x00001000
>>   console: [    0.000000]   Normal   0x00001000 -> 0x00003fff
>>   console: [    0.000000] Movable zone start PFN for each node
>>   console: [    0.000000] early_node_map[1] active PFN ranges
>>   console: [    0.000000]     0: 0x00000000 -> 0x00003fff
>>   console: [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16255
>>   console: [    0.000000] Kernel command line: console=ttyS0 printk.time=0
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  tests/acceptance/boot_linux_console.py | 46 ++++++++++++++++++++++++++
>>  1 file changed, 46 insertions(+)
>>
>> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
>> index 3aa4dbe5f9..81c96fc338 100644
>> --- a/tests/acceptance/boot_linux_console.py
>> +++ b/tests/acceptance/boot_linux_console.py
>> @@ -9,6 +9,7 @@
>>  # later.  See the COPYING file in the top-level directory.
>>  
>>  import logging
>> +import subprocess
> 
> It's definitely your call, but I like to think that
> avocado.utils.process provides simpler and more capable functions:
> 
> https://avocado-framework.readthedocs.io/en/65.0/api/utils/avocado.utils.html#avocado.utils.process.run

OK

> 
>>  
>>  from avocado_qemu import Test
>>  
>> @@ -47,3 +48,48 @@ class BootLinuxConsole(Test):
>>                  break
>>              if 'Kernel panic - not syncing' in msg:
>>                  self.fail("Kernel panic reached")
>> +
>> +    def test_mips_4kc_malta(self):
>> +        """
>> +        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
>> +        the kernel from the Debian package.
>> +
>> +        The kernel can be rebuilt using this Debian kernel source [1] and
>> +        following the instructions on [2].
>> +
>> +        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
>> +        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/#linux-source-2.6.32_2.6.32-48
>> +
>> +        :avocado: tags=arch:mips
>> +        """
>> +        if self.arch != 'mips': # FIXME use 'arch' tag in parent class?
>> +            self.cancel('Currently specific to the %s target arch' % self.arch)
>> +
> 
> I missed how the arch tag in the parent class (common to all tests here)
> would be useful for this specific test.

I probably forgot to remove it.

> 
>> +        deb_url = ('http://snapshot.debian.org/archive/debian/20130217T032700Z/'
>> +                   'pool/main/l/linux-2.6/'
>> +                   'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
>> +        deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
>> +        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
>> +        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir]) # FIXME move to avocado ...
> 
> This could become:
> 
>  # from avocado.utils.process import run
>  run("ar p %s data.tar.gz | tar zxf - -C %s
> ./boot/vmlinux-2.6.32-5-4kc-malta" % (deb_path, self.workdir), shell=True)

OK!

> 
>> +        kernel_path = self.workdir + '/boot/vmlinux-2.6.32-5-4kc-malta'          # FIXME ... and use from assets?
>> +
> 
> Putting produced/processed files back into the cache would be nice
> addition to the asset fetcher (or related tools).  Not there yet, though.

OK :/

> 
>> +        self.vm.set_arch(self.arch)
>> +        self.vm.set_machine('malta')
>> +        self.vm.set_console("") # XXX this disable isa-serial to use -serial ...
> 
> See the comments on the previous patch.  Basically, if a machine doesn't
> need an explicit console device to be added, set_console() should do
> just that (not add one).  The ideal API would be to call set_console()
> without any explicit parameter IMO.

Sure.

> 
> That assumes, what I believe to be true, that we don't want to setup
> multiple *console* devices per QEMUMachine, right?

There might be weird corner-cases but usually machines only have one
type of (default) console.

> 
> Regards,
> - Cleber.
> 
>> +        kernel_command_line = 'console=ttyS0 printk.time=0'
>> +        self.vm.add_args('-m', "64",
>> +                         '-serial', "chardev:console", # XXX ... here.
>> +                         '-kernel', kernel_path,
>> +                         '-append', kernel_command_line)
>> +
>> +        # FIXME below to parent class?
>> +        self.vm.launch()
>> +        console = self.vm.console_socket.makefile()
>> +        console_logger = logging.getLogger('console')
>> +        while True:
>> +            msg = console.readline()
>> +            console_logger.debug(msg.strip())
>> +            if 'Kernel command line: %s' % kernel_command_line in msg:
>> +                break
>> +            if 'Kernel panic - not syncing' in msg:
>> +                self.fail("Kernel panic reached")
>>
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 3/6] tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole
  2018-10-19 18:41     ` Philippe Mathieu-Daudé
@ 2018-10-19 21:17       ` Cleber Rosa
  2018-10-19 22:51         ` Cleber Rosa
  0 siblings, 1 reply; 19+ messages in thread
From: Cleber Rosa @ 2018-10-19 21:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Alex Bennée, Eduardo Habkost
  Cc: Lukáš Doktor, Fam Zheng, qemu-devel



On 10/19/18 2:41 PM, Philippe Mathieu-Daudé wrote:
> On 19/10/2018 19:42, Cleber Rosa wrote:
>>
>>
>> On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
>>> Similar to the test_x86_64_pc test, this boots a Linux kernel on a
>>> Malta board (MIPS 4Kc big-endian) and verify the serial is working.
>>>
>>> This test requires the dpkg-deb tool (apt/dnf install dpkg) to
>>> extract the kernel from the Debian package.
>>>
>>
>> Debian packages are really "ar" archives, with a control.tar.gz and
>> data.tar.gz in them.  More on that later.
>>
>>>   $ avocado --show=console run -p arch=mips tests/acceptance/boot_linux_console.py
>>>   console: [    0.000000] Initializing cgroup subsys cpuset
>>>   console: [    0.000000] Initializing cgroup subsys cpu
>>>   console: [    0.000000] Linux version 2.6.32-5-4kc-malta (Debian 2.6.32-48) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 Sat Feb 16 12:43:42 UTC 2013
>>>   console: [    0.000000]
>>>   console: [    0.000000] LINUX started...
>>>   console: [    0.000000] bootconsole [early0] enabled
>>>   console: [    0.000000] CPU revision is: 00019300 (MIPS 24Kc)
>>>   console: [    0.000000] FPU revision is: 00739300
>>>   console: [    0.000000] Determined physical RAM map:
>>>   console: [    0.000000]  memory: 00001000 @ 00000000 (reserved)
>>>   console: [    0.000000]  memory: 000ef000 @ 00001000 (ROM data)
>>>   console: [    0.000000]  memory: 005b7000 @ 000f0000 (reserved)
>>>   console: [    0.000000]  memory: 03958000 @ 006a7000 (usable)
>>>   console: [    0.000000] Wasting 54496 bytes for tracking 1703 unused pages
>>>   console: [    0.000000] Initrd not found or empty - disabling initrd
>>>   console: [    0.000000] Zone PFN ranges:
>>>   console: [    0.000000]   DMA      0x00000000 -> 0x00001000
>>>   console: [    0.000000]   Normal   0x00001000 -> 0x00003fff
>>>   console: [    0.000000] Movable zone start PFN for each node
>>>   console: [    0.000000] early_node_map[1] active PFN ranges
>>>   console: [    0.000000]     0: 0x00000000 -> 0x00003fff
>>>   console: [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16255
>>>   console: [    0.000000] Kernel command line: console=ttyS0 printk.time=0
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>> ---
>>>  tests/acceptance/boot_linux_console.py | 46 ++++++++++++++++++++++++++
>>>  1 file changed, 46 insertions(+)
>>>
>>> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
>>> index 3aa4dbe5f9..81c96fc338 100644
>>> --- a/tests/acceptance/boot_linux_console.py
>>> +++ b/tests/acceptance/boot_linux_console.py
>>> @@ -9,6 +9,7 @@
>>>  # later.  See the COPYING file in the top-level directory.
>>>  
>>>  import logging
>>> +import subprocess
>>
>> It's definitely your call, but I like to think that
>> avocado.utils.process provides simpler and more capable functions:
>>
>> https://avocado-framework.readthedocs.io/en/65.0/api/utils/avocado.utils.html#avocado.utils.process.run
> 
> OK
> 
>>
>>>  
>>>  from avocado_qemu import Test
>>>  
>>> @@ -47,3 +48,48 @@ class BootLinuxConsole(Test):
>>>                  break
>>>              if 'Kernel panic - not syncing' in msg:
>>>                  self.fail("Kernel panic reached")
>>> +
>>> +    def test_mips_4kc_malta(self):
>>> +        """
>>> +        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
>>> +        the kernel from the Debian package.
>>> +
>>> +        The kernel can be rebuilt using this Debian kernel source [1] and
>>> +        following the instructions on [2].
>>> +
>>> +        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
>>> +        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/#linux-source-2.6.32_2.6.32-48
>>> +
>>> +        :avocado: tags=arch:mips
>>> +        """
>>> +        if self.arch != 'mips': # FIXME use 'arch' tag in parent class?
>>> +            self.cancel('Currently specific to the %s target arch' % self.arch)
>>> +
>>
>> I missed how the arch tag in the parent class (common to all tests here)
>> would be useful for this specific test.
> 
> I probably forgot to remove it.
> 

I think I now know what you meant.  With the current approach we have:

$ avocado run -p arch=x86_64 tests/acceptance/boot_linux_console.py
JOB ID     : 3209c26bceffc372f245b121d6ac77a7e36e7134
JOB LOG    :
/home/cleber/avocado/job-results/job-2018-10-19T16.58-3209c26/job.log
 (1/2)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc:
PASS (2.05 s)
 (2/2)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta:
CANCEL: Currently specific to the x86_64 target arch (0.00 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 1
JOB TIME   : 2.21 s

There's a bug in the CANCEL message, because the test is "mips" specific
and not specific to the arch parameter given.  I believe you'd like to
reuse the arch given in the "tags=", right?

- Cleber.

>>
>>> +        deb_url = ('http://snapshot.debian.org/archive/debian/20130217T032700Z/'
>>> +                   'pool/main/l/linux-2.6/'
>>> +                   'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
>>> +        deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
>>> +        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
>>> +        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir]) # FIXME move to avocado ...
>>
>> This could become:
>>
>>  # from avocado.utils.process import run
>>  run("ar p %s data.tar.gz | tar zxf - -C %s
>> ./boot/vmlinux-2.6.32-5-4kc-malta" % (deb_path, self.workdir), shell=True)
> 
> OK!
> 
>>
>>> +        kernel_path = self.workdir + '/boot/vmlinux-2.6.32-5-4kc-malta'          # FIXME ... and use from assets?
>>> +
>>
>> Putting produced/processed files back into the cache would be nice
>> addition to the asset fetcher (or related tools).  Not there yet, though.
> 
> OK :/
> 
>>
>>> +        self.vm.set_arch(self.arch)
>>> +        self.vm.set_machine('malta')
>>> +        self.vm.set_console("") # XXX this disable isa-serial to use -serial ...
>>
>> See the comments on the previous patch.  Basically, if a machine doesn't
>> need an explicit console device to be added, set_console() should do
>> just that (not add one).  The ideal API would be to call set_console()
>> without any explicit parameter IMO.
> 
> Sure.
> 
>>
>> That assumes, what I believe to be true, that we don't want to setup
>> multiple *console* devices per QEMUMachine, right?
> 
> There might be weird corner-cases but usually machines only have one
> type of (default) console.
> 
>>
>> Regards,
>> - Cleber.
>>
>>> +        kernel_command_line = 'console=ttyS0 printk.time=0'
>>> +        self.vm.add_args('-m', "64",
>>> +                         '-serial', "chardev:console", # XXX ... here.
>>> +                         '-kernel', kernel_path,
>>> +                         '-append', kernel_command_line)
>>> +
>>> +        # FIXME below to parent class?
>>> +        self.vm.launch()
>>> +        console = self.vm.console_socket.makefile()
>>> +        console_logger = logging.getLogger('console')
>>> +        while True:
>>> +            msg = console.readline()
>>> +            console_logger.debug(msg.strip())
>>> +            if 'Kernel command line: %s' % kernel_command_line in msg:
>>> +                break
>>> +            if 'Kernel panic - not syncing' in msg:
>>> +                self.fail("Kernel panic reached")
>>>
>>

-- 
Cleber Rosa
[ Sr Software Engineer - Virtualization Team - Red Hat ]
[ Avocado Test Framework - avocado-framework.github.io ]
[  7ABB 96EB 8B46 B94D 5E0F  E9BB 657E 8D33 A5F2 09F3  ]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 3/6] tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole
  2018-10-19 21:17       ` Cleber Rosa
@ 2018-10-19 22:51         ` Cleber Rosa
  2018-10-20  9:57           ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 19+ messages in thread
From: Cleber Rosa @ 2018-10-19 22:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Alex Bennée, Eduardo Habkost
  Cc: Lukáš Doktor, Fam Zheng, qemu-devel



On 10/19/18 5:17 PM, Cleber Rosa wrote:
> 
> 
> On 10/19/18 2:41 PM, Philippe Mathieu-Daudé wrote:
>> On 19/10/2018 19:42, Cleber Rosa wrote:
>>>
>>>
>>> On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
>>>> Similar to the test_x86_64_pc test, this boots a Linux kernel on a
>>>> Malta board (MIPS 4Kc big-endian) and verify the serial is working.
>>>>
>>>> This test requires the dpkg-deb tool (apt/dnf install dpkg) to
>>>> extract the kernel from the Debian package.
>>>>
>>>
>>> Debian packages are really "ar" archives, with a control.tar.gz and
>>> data.tar.gz in them.  More on that later.
>>>
>>>>   $ avocado --show=console run -p arch=mips tests/acceptance/boot_linux_console.py
>>>>   console: [    0.000000] Initializing cgroup subsys cpuset
>>>>   console: [    0.000000] Initializing cgroup subsys cpu
>>>>   console: [    0.000000] Linux version 2.6.32-5-4kc-malta (Debian 2.6.32-48) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 Sat Feb 16 12:43:42 UTC 2013
>>>>   console: [    0.000000]
>>>>   console: [    0.000000] LINUX started...
>>>>   console: [    0.000000] bootconsole [early0] enabled
>>>>   console: [    0.000000] CPU revision is: 00019300 (MIPS 24Kc)
>>>>   console: [    0.000000] FPU revision is: 00739300
>>>>   console: [    0.000000] Determined physical RAM map:
>>>>   console: [    0.000000]  memory: 00001000 @ 00000000 (reserved)
>>>>   console: [    0.000000]  memory: 000ef000 @ 00001000 (ROM data)
>>>>   console: [    0.000000]  memory: 005b7000 @ 000f0000 (reserved)
>>>>   console: [    0.000000]  memory: 03958000 @ 006a7000 (usable)
>>>>   console: [    0.000000] Wasting 54496 bytes for tracking 1703 unused pages
>>>>   console: [    0.000000] Initrd not found or empty - disabling initrd
>>>>   console: [    0.000000] Zone PFN ranges:
>>>>   console: [    0.000000]   DMA      0x00000000 -> 0x00001000
>>>>   console: [    0.000000]   Normal   0x00001000 -> 0x00003fff
>>>>   console: [    0.000000] Movable zone start PFN for each node
>>>>   console: [    0.000000] early_node_map[1] active PFN ranges
>>>>   console: [    0.000000]     0: 0x00000000 -> 0x00003fff
>>>>   console: [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16255
>>>>   console: [    0.000000] Kernel command line: console=ttyS0 printk.time=0
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>> ---
>>>>  tests/acceptance/boot_linux_console.py | 46 ++++++++++++++++++++++++++
>>>>  1 file changed, 46 insertions(+)
>>>>
>>>> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
>>>> index 3aa4dbe5f9..81c96fc338 100644
>>>> --- a/tests/acceptance/boot_linux_console.py
>>>> +++ b/tests/acceptance/boot_linux_console.py
>>>> @@ -9,6 +9,7 @@
>>>>  # later.  See the COPYING file in the top-level directory.
>>>>  
>>>>  import logging
>>>> +import subprocess
>>>
>>> It's definitely your call, but I like to think that
>>> avocado.utils.process provides simpler and more capable functions:
>>>
>>> https://avocado-framework.readthedocs.io/en/65.0/api/utils/avocado.utils.html#avocado.utils.process.run
>>
>> OK
>>
>>>
>>>>  
>>>>  from avocado_qemu import Test
>>>>  
>>>> @@ -47,3 +48,48 @@ class BootLinuxConsole(Test):
>>>>                  break
>>>>              if 'Kernel panic - not syncing' in msg:
>>>>                  self.fail("Kernel panic reached")
>>>> +
>>>> +    def test_mips_4kc_malta(self):
>>>> +        """
>>>> +        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
>>>> +        the kernel from the Debian package.
>>>> +
>>>> +        The kernel can be rebuilt using this Debian kernel source [1] and
>>>> +        following the instructions on [2].
>>>> +
>>>> +        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
>>>> +        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/#linux-source-2.6.32_2.6.32-48
>>>> +
>>>> +        :avocado: tags=arch:mips
>>>> +        """
>>>> +        if self.arch != 'mips': # FIXME use 'arch' tag in parent class?
>>>> +            self.cancel('Currently specific to the %s target arch' % self.arch)
>>>> +
>>>
>>> I missed how the arch tag in the parent class (common to all tests here)
>>> would be useful for this specific test.
>>
>> I probably forgot to remove it.
>>
> 
> I think I now know what you meant.  With the current approach we have:
> 
> $ avocado run -p arch=x86_64 tests/acceptance/boot_linux_console.py
> JOB ID     : 3209c26bceffc372f245b121d6ac77a7e36e7134
> JOB LOG    :
> /home/cleber/avocado/job-results/job-2018-10-19T16.58-3209c26/job.log
>  (1/2)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc:
> PASS (2.05 s)
>  (2/2)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta:
> CANCEL: Currently specific to the x86_64 target arch (0.00 s)
> RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
> CANCEL 1
> JOB TIME   : 2.21 s
> 
> There's a bug in the CANCEL message, because the test is "mips" specific
> and not specific to the arch parameter given.  I believe you'd like to
> reuse the arch given in the "tags=", right?
> 

Continuing on this assumption (that it can be useful to access the tags
during the test) I prototype this:

https://github.com/clebergnu/avocado/commit/7c5b04ed76bad5570f05e24ce168c8477283424d

And with that, this on top of this commit:

https://github.com/clebergnu/qemu/commit/359b8b4e10575646a2efa1bcb58ab74053233514

Basically, it allows one to run many arch specific tests at once,
without specifying/restricting one arch:

$ avocado run tests/acceptance/boot_linux_console.py
JOB ID     : 3ade8b6c547f853e1b169cd1846f69f5221fd9f0
JOB LOG    :
/home/cleber/avocado/job-results/job-2018-10-19T18.30-3ade8b6/job.log
 (1/2)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc:
PASS (2.00 s)
 (2/2)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta:
PASS (0.53 s)
RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 2.70 s

And the proper behavior when setting a arch:

$ avocado run -p arch=mips tests/acceptance/boot_linux_console.py
JOB ID     : 75902f6b02707c9c0d509229f092e14e8b2f3933
JOB LOG    :
/home/cleber/avocado/job-results/job-2018-10-19T18.50-75902f6/job.log
 (1/2)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc:
CANCEL: Currently specific to the targets: x86_64 (0.00 s)
 (2/2)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta:
PASS (0.54 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 1
JOB TIME   : 0.71 s

How does that look?

- Cleber.

> - Cleber.
> 
>>>
>>>> +        deb_url = ('http://snapshot.debian.org/archive/debian/20130217T032700Z/'
>>>> +                   'pool/main/l/linux-2.6/'
>>>> +                   'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
>>>> +        deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
>>>> +        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
>>>> +        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir]) # FIXME move to avocado ...
>>>
>>> This could become:
>>>
>>>  # from avocado.utils.process import run
>>>  run("ar p %s data.tar.gz | tar zxf - -C %s
>>> ./boot/vmlinux-2.6.32-5-4kc-malta" % (deb_path, self.workdir), shell=True)
>>
>> OK!
>>
>>>
>>>> +        kernel_path = self.workdir + '/boot/vmlinux-2.6.32-5-4kc-malta'          # FIXME ... and use from assets?
>>>> +
>>>
>>> Putting produced/processed files back into the cache would be nice
>>> addition to the asset fetcher (or related tools).  Not there yet, though.
>>
>> OK :/
>>
>>>
>>>> +        self.vm.set_arch(self.arch)
>>>> +        self.vm.set_machine('malta')
>>>> +        self.vm.set_console("") # XXX this disable isa-serial to use -serial ...
>>>
>>> See the comments on the previous patch.  Basically, if a machine doesn't
>>> need an explicit console device to be added, set_console() should do
>>> just that (not add one).  The ideal API would be to call set_console()
>>> without any explicit parameter IMO.
>>
>> Sure.
>>
>>>
>>> That assumes, what I believe to be true, that we don't want to setup
>>> multiple *console* devices per QEMUMachine, right?
>>
>> There might be weird corner-cases but usually machines only have one
>> type of (default) console.
>>
>>>
>>> Regards,
>>> - Cleber.
>>>
>>>> +        kernel_command_line = 'console=ttyS0 printk.time=0'
>>>> +        self.vm.add_args('-m', "64",
>>>> +                         '-serial', "chardev:console", # XXX ... here.
>>>> +                         '-kernel', kernel_path,
>>>> +                         '-append', kernel_command_line)
>>>> +
>>>> +        # FIXME below to parent class?
>>>> +        self.vm.launch()
>>>> +        console = self.vm.console_socket.makefile()
>>>> +        console_logger = logging.getLogger('console')
>>>> +        while True:
>>>> +            msg = console.readline()
>>>> +            console_logger.debug(msg.strip())
>>>> +            if 'Kernel command line: %s' % kernel_command_line in msg:
>>>> +                break
>>>> +            if 'Kernel panic - not syncing' in msg:
>>>> +                self.fail("Kernel panic reached")
>>>>
>>>
> 

-- 
Cleber Rosa
[ Sr Software Engineer - Virtualization Team - Red Hat ]
[ Avocado Test Framework - avocado-framework.github.io ]
[  7ABB 96EB 8B46 B94D 5E0F  E9BB 657E 8D33 A5F2 09F3  ]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [RFC PATCH v3 6/6] tests/acceptance: Add test_sh4_r2d in BootLinuxTracing
  2018-10-13 15:15 ` [Qemu-devel] [RFC PATCH v3 6/6] tests/acceptance: Add test_sh4_r2d in BootLinuxTracing Philippe Mathieu-Daudé
@ 2018-10-20  0:02   ` Cleber Rosa
  0 siblings, 0 replies; 19+ messages in thread
From: Cleber Rosa @ 2018-10-20  0:02 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	Alex Bennée, Eduardo Habkost, BALATON Zoltan, Magnus Damm
  Cc: qemu-devel, Lukáš Doktor, Fam Zheng



On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
> Similar to the test_x86_64_pc test, this boots a Linux kernel on a
> R2D board (SH4 little-endian) and verify the usb is working by looking
> at the usb trace events. Thus this test requires the QEMU binary to be
> compiled with:
> 
>   $ configure ... --enable-trace-backends=log
> 
> This test also requires the dpkg-deb tool (apt/dnf install dpkg) to
> extract the kernel from the Debian package.
> 
>   $ avocado --show=app,trace run -p arch=sh4 tests/acceptance/boot_linux_console.py
>   JOB ID     : dc45be27f5d1edb8289a1ede139e107bbc55b045
>   JOB LOG    : /home/phil/avocado/job-results/job-2018-10-13T14.46-dc45be2/job.log
>    (1/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc: CANCEL: Currently specific to the x86_64 target arch (0.00 s)
>    (2/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta: CANCEL: Currently specific to the sh4 target arch (0.00 s)
>    (3/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mipsel_5kc_malta: CANCEL: Currently specific to the sh4 target arch (0.00 s)
>    (4/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_sh4_r2d: SKIP: console not working on r2d machine
>    (5/5) tests/acceptance/boot_linux_console.py:BootLinuxTracing.test_sh4_r2d:  /
>   trace: 22770@1539434809.450006:usb_ohci_init_time usb_bit_time=1000000 usb_frame_time=83
>   trace: 22770@1539434809.453017:usb_ohci_port_attach port #0
>   trace: 22770@1539434809.454827:usb_ohci_reset sysbus-ohci
>   trace: 22770@1539434809.454833:usb_ohci_stop sysbus-ohci: USB Suspended
>   trace: 22770@1539434809.454835:usb_ohci_stop sysbus-ohci: USB Suspended
>   trace: 22770@1539434809.454837:usb_ohci_port_detach port #0
>   trace: 22770@1539434809.454839:usb_ohci_port_attach port #0
>   trace: 22770@1539434811.588702:usb_ohci_reset sysbus-ohci
>   trace: 22770@1539434811.588711:usb_ohci_stop sysbus-ohci: USB Suspended
>   trace: 22770@1539434811.589062:usb_ohci_set_ctl sysbus-ohci: new state 0x80
>   trace: 22770@1539434811.589067:usb_ohci_start sysbus-ohci: USB Operational
>   trace: 22770@1539434811.589253:usb_ohci_hub_power_up powered up all ports
>   PASS (2.43 s)
>   RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 3
>   JOB TIME   : 2.67 s
> 

And with similar changes, on this point of this series:

$ avocado run tests/acceptance/boot_linux_console.py
JOB ID     : 857fef1b8c0ce59a79d452f27e996ed2743404b1
JOB LOG    :
/home/cleber/avocado/job-results/job-2018-10-19T19.58-857fef1/job.log
 (1/5)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc:
PASS (2.04 s)
 (2/5)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta:
PASS (0.57 s)
 (3/5)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mipsel_5kc_malta:
PASS (0.59 s)
 (4/5)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_sh4_r2d:
SKIP: console not working on r2d machine
 (5/5)
tests/acceptance/boot_linux_console.py:BootLinuxTracing.test_sh4_r2d:
PASS (1.01 s)
RESULTS    : PASS 4 | ERROR 0 | FAIL 0 | SKIP 1 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 4.57 s

- Cleber.

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/acceptance/boot_linux_console.py | 64 ++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
> 
> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
> index 8f99cc0d7c..e11993bf98 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -8,11 +8,22 @@
>  # This work is licensed under the terms of the GNU GPL, version 2 or
>  # later.  See the COPYING file in the top-level directory.
>  
> +import os
>  import logging
>  import subprocess
>  
>  from avocado import skip
>  from avocado_qemu import Test
> +from avocado.utils.wait import wait_for
> +
> +
> +def read_stream_for_string(stream, expected_string, logger=None):
> +    msg = stream.readline()
> +    if len(msg) == 0:
> +        return False
> +    if logger:
> +        logger.debug(msg.strip())
> +    return expected_string in msg
>  
>  
>  class BootLinuxConsole(Test):
> @@ -185,3 +196,56 @@ class BootLinuxConsole(Test):
>                  break
>              if 'Kernel panic - not syncing' in msg:
>                  self.fail("Kernel panic reached")
> +
> +class BootLinuxTracing(Test):
> +    """
> +    Boots a Linux kernel and checks that via the Tracing framework that
> +    a specific trace events occured, demostrating the kernel is operational.
> +
> +    :avocado: enable
> +    """
> +
> +    timeout = 60
> +
> +    def test_sh4_r2d(self):
> +        """
> +        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
> +        the kernel from the Debian package.
> +        This test also requires the QEMU binary to be compiled with:
> +
> +          $ configure ... --enable-trace-backends=log
> +
> +        The kernel can be rebuilt using this Debian kernel source [1] and
> +        following the instructions on [2].
> +
> +        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
> +        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-30/#linux-source-2.6.32_2.6.32-30
> +
> +        :avocado: tags=arch:sh4
> +        """
> +        if self.arch != 'sh4':
> +            self.cancel('Currently specific to the %s target arch' % self.arch)
> +
> +        deb_url = ('http://snapshot.debian.org/archive/'
> +                   'debian-ports/20110116T065852Z/pool-sh4/main/l/'
> +                   'linux-2.6/linux-image-2.6.32-5-sh7751r_2.6.32-30_sh4.deb')
> +        deb_hash = '8025e503319dc8ad786756e3afaa8eb868e9ef59'
> +        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
> +        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir])
> +        kernel_path = self.workdir + '/boot/vmlinuz-2.6.32-5-sh7751r'
> +        trace_path = os.path.join(self.workdir, 'trace.log')
> +        trace_logger = logging.getLogger('trace')
> +
> +        self.vm.set_arch(self.arch)
> +        self.vm.set_machine('r2d')
> +        kernel_command_line = 'noiotrap'
> +        self.vm.add_args('-trace', "enable=usb_ohci_*,file=" + trace_path,
> +                         '-kernel', kernel_path,
> +                         '-append', kernel_command_line)
> +
> +        self.vm.launch()
> +        if not wait_for(read_stream_for_string, timeout=15, step=0,
> +                        args=(open(trace_path),
> +                              'usb_ohci_hub_power_up powered up all ports',
> +                              trace_logger)):
> +            self.fail("Machine failed to boot")
> 

-- 
Cleber Rosa
[ Sr Software Engineer - Virtualization Team - Red Hat ]
[ Avocado Test Framework - avocado-framework.github.io ]
[  7ABB 96EB 8B46 B94D 5E0F  E9BB 657E 8D33 A5F2 09F3  ]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [Qemu-devel] [PATCH v3 3/6] tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole
  2018-10-19 22:51         ` Cleber Rosa
@ 2018-10-20  9:57           ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-20  9:57 UTC (permalink / raw)
  To: Cleber Rosa, Philippe Mathieu-Daudé,
	Alex Bennée, Eduardo Habkost
  Cc: Lukáš Doktor, Fam Zheng, qemu-devel

On 20/10/2018 00:51, Cleber Rosa wrote:
> 
> 
> On 10/19/18 5:17 PM, Cleber Rosa wrote:
>>
>>
>> On 10/19/18 2:41 PM, Philippe Mathieu-Daudé wrote:
>>> On 19/10/2018 19:42, Cleber Rosa wrote:
>>>>
>>>>
>>>> On 10/13/18 11:15 AM, Philippe Mathieu-Daudé wrote:
>>>>> Similar to the test_x86_64_pc test, this boots a Linux kernel on a
>>>>> Malta board (MIPS 4Kc big-endian) and verify the serial is working.
>>>>>
>>>>> This test requires the dpkg-deb tool (apt/dnf install dpkg) to
>>>>> extract the kernel from the Debian package.
>>>>>
>>>>
>>>> Debian packages are really "ar" archives, with a control.tar.gz and
>>>> data.tar.gz in them.  More on that later.
>>>>
>>>>>   $ avocado --show=console run -p arch=mips tests/acceptance/boot_linux_console.py
>>>>>   console: [    0.000000] Initializing cgroup subsys cpuset
>>>>>   console: [    0.000000] Initializing cgroup subsys cpu
>>>>>   console: [    0.000000] Linux version 2.6.32-5-4kc-malta (Debian 2.6.32-48) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 Sat Feb 16 12:43:42 UTC 2013
>>>>>   console: [    0.000000]
>>>>>   console: [    0.000000] LINUX started...
>>>>>   console: [    0.000000] bootconsole [early0] enabled
>>>>>   console: [    0.000000] CPU revision is: 00019300 (MIPS 24Kc)
>>>>>   console: [    0.000000] FPU revision is: 00739300
>>>>>   console: [    0.000000] Determined physical RAM map:
>>>>>   console: [    0.000000]  memory: 00001000 @ 00000000 (reserved)
>>>>>   console: [    0.000000]  memory: 000ef000 @ 00001000 (ROM data)
>>>>>   console: [    0.000000]  memory: 005b7000 @ 000f0000 (reserved)
>>>>>   console: [    0.000000]  memory: 03958000 @ 006a7000 (usable)
>>>>>   console: [    0.000000] Wasting 54496 bytes for tracking 1703 unused pages
>>>>>   console: [    0.000000] Initrd not found or empty - disabling initrd
>>>>>   console: [    0.000000] Zone PFN ranges:
>>>>>   console: [    0.000000]   DMA      0x00000000 -> 0x00001000
>>>>>   console: [    0.000000]   Normal   0x00001000 -> 0x00003fff
>>>>>   console: [    0.000000] Movable zone start PFN for each node
>>>>>   console: [    0.000000] early_node_map[1] active PFN ranges
>>>>>   console: [    0.000000]     0: 0x00000000 -> 0x00003fff
>>>>>   console: [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16255
>>>>>   console: [    0.000000] Kernel command line: console=ttyS0 printk.time=0
>>>>>
>>>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>>> ---
>>>>>  tests/acceptance/boot_linux_console.py | 46 ++++++++++++++++++++++++++
>>>>>  1 file changed, 46 insertions(+)
>>>>>
>>>>> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
>>>>> index 3aa4dbe5f9..81c96fc338 100644
>>>>> --- a/tests/acceptance/boot_linux_console.py
>>>>> +++ b/tests/acceptance/boot_linux_console.py
>>>>> @@ -9,6 +9,7 @@
>>>>>  # later.  See the COPYING file in the top-level directory.
>>>>>  
>>>>>  import logging
>>>>> +import subprocess
>>>>
>>>> It's definitely your call, but I like to think that
>>>> avocado.utils.process provides simpler and more capable functions:
>>>>
>>>> https://avocado-framework.readthedocs.io/en/65.0/api/utils/avocado.utils.html#avocado.utils.process.run
>>>
>>> OK
>>>
>>>>
>>>>>  
>>>>>  from avocado_qemu import Test
>>>>>  
>>>>> @@ -47,3 +48,48 @@ class BootLinuxConsole(Test):
>>>>>                  break
>>>>>              if 'Kernel panic - not syncing' in msg:
>>>>>                  self.fail("Kernel panic reached")
>>>>> +
>>>>> +    def test_mips_4kc_malta(self):
>>>>> +        """
>>>>> +        This test requires the dpkg-deb tool (apt/dnf install dpkg) to extract
>>>>> +        the kernel from the Debian package.
>>>>> +
>>>>> +        The kernel can be rebuilt using this Debian kernel source [1] and
>>>>> +        following the instructions on [2].
>>>>> +
>>>>> +        [1] https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official
>>>>> +        [2] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/#linux-source-2.6.32_2.6.32-48
>>>>> +
>>>>> +        :avocado: tags=arch:mips
>>>>> +        """
>>>>> +        if self.arch != 'mips': # FIXME use 'arch' tag in parent class?
>>>>> +            self.cancel('Currently specific to the %s target arch' % self.arch)
>>>>> +
>>>>
>>>> I missed how the arch tag in the parent class (common to all tests here)
>>>> would be useful for this specific test.
>>>
>>> I probably forgot to remove it.
>>>
>>
>> I think I now know what you meant.  With the current approach we have:
>>
>> $ avocado run -p arch=x86_64 tests/acceptance/boot_linux_console.py
>> JOB ID     : 3209c26bceffc372f245b121d6ac77a7e36e7134
>> JOB LOG    :
>> /home/cleber/avocado/job-results/job-2018-10-19T16.58-3209c26/job.log
>>  (1/2)
>> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc:
>> PASS (2.05 s)
>>  (2/2)
>> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta:
>> CANCEL: Currently specific to the x86_64 target arch (0.00 s)
>> RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
>> CANCEL 1
>> JOB TIME   : 2.21 s
>>
>> There's a bug in the CANCEL message, because the test is "mips" specific
>> and not specific to the arch parameter given.  I believe you'd like to
>> reuse the arch given in the "tags=", right?
>>
> 
> Continuing on this assumption (that it can be useful to access the tags
> during the test) I prototype this:
> 
> https://github.com/clebergnu/avocado/commit/7c5b04ed76bad5570f05e24ce168c8477283424d
> 
> And with that, this on top of this commit:
> 
> https://github.com/clebergnu/qemu/commit/359b8b4e10575646a2efa1bcb58ab74053233514
> 
> Basically, it allows one to run many arch specific tests at once,
> without specifying/restricting one arch:
> 
> $ avocado run tests/acceptance/boot_linux_console.py
> JOB ID     : 3ade8b6c547f853e1b169cd1846f69f5221fd9f0
> JOB LOG    :
> /home/cleber/avocado/job-results/job-2018-10-19T18.30-3ade8b6/job.log
>  (1/2)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc:
> PASS (2.00 s)
>  (2/2)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta:
> PASS (0.53 s)
> RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
> CANCEL 0
> JOB TIME   : 2.70 s
> 
> And the proper behavior when setting a arch:
> 
> $ avocado run -p arch=mips tests/acceptance/boot_linux_console.py
> JOB ID     : 75902f6b02707c9c0d509229f092e14e8b2f3933
> JOB LOG    :
> /home/cleber/avocado/job-results/job-2018-10-19T18.50-75902f6/job.log
>  (1/2)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc:
> CANCEL: Currently specific to the targets: x86_64 (0.00 s)
>  (2/2)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_4kc_malta:
> PASS (0.54 s)
> RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
> CANCEL 1
> JOB TIME   : 0.71 s
> 
> How does that look?

YES! This is _exactly_ what I wanted and how I plan to use this framework :)

> 
> - Cleber.
> 
>> - Cleber.
>>
>>>>
>>>>> +        deb_url = ('http://snapshot.debian.org/archive/debian/20130217T032700Z/'
>>>>> +                   'pool/main/l/linux-2.6/'
>>>>> +                   'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
>>>>> +        deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
>>>>> +        deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
>>>>> +        subprocess.check_call(['dpkg-deb', '--extract', deb_path, self.workdir]) # FIXME move to avocado ...
>>>>
>>>> This could become:
>>>>
>>>>  # from avocado.utils.process import run
>>>>  run("ar p %s data.tar.gz | tar zxf - -C %s
>>>> ./boot/vmlinux-2.6.32-5-4kc-malta" % (deb_path, self.workdir), shell=True)
>>>
>>> OK!
>>>
>>>>
>>>>> +        kernel_path = self.workdir + '/boot/vmlinux-2.6.32-5-4kc-malta'          # FIXME ... and use from assets?
>>>>> +
>>>>
>>>> Putting produced/processed files back into the cache would be nice
>>>> addition to the asset fetcher (or related tools).  Not there yet, though.
>>>
>>> OK :/
>>>
>>>>
>>>>> +        self.vm.set_arch(self.arch)
>>>>> +        self.vm.set_machine('malta')
>>>>> +        self.vm.set_console("") # XXX this disable isa-serial to use -serial ...
>>>>
>>>> See the comments on the previous patch.  Basically, if a machine doesn't
>>>> need an explicit console device to be added, set_console() should do
>>>> just that (not add one).  The ideal API would be to call set_console()
>>>> without any explicit parameter IMO.
>>>
>>> Sure.
>>>
>>>>
>>>> That assumes, what I believe to be true, that we don't want to setup
>>>> multiple *console* devices per QEMUMachine, right?
>>>
>>> There might be weird corner-cases but usually machines only have one
>>> type of (default) console.
>>>
>>>>
>>>> Regards,
>>>> - Cleber.
>>>>
>>>>> +        kernel_command_line = 'console=ttyS0 printk.time=0'
>>>>> +        self.vm.add_args('-m', "64",
>>>>> +                         '-serial', "chardev:console", # XXX ... here.
>>>>> +                         '-kernel', kernel_path,
>>>>> +                         '-append', kernel_command_line)
>>>>> +
>>>>> +        # FIXME below to parent class?
>>>>> +        self.vm.launch()
>>>>> +        console = self.vm.console_socket.makefile()
>>>>> +        console_logger = logging.getLogger('console')
>>>>> +        while True:
>>>>> +            msg = console.readline()
>>>>> +            console_logger.debug(msg.strip())
>>>>> +            if 'Kernel command line: %s' % kernel_command_line in msg:
>>>>> +                break
>>>>> +            if 'Kernel panic - not syncing' in msg:
>>>>> +                self.fail("Kernel panic reached")
>>>>>
>>>>
>>
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-10-20  9:57 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-13 15:15 [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Philippe Mathieu-Daudé
2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 1/6] tests/acceptance: Rename the generic BootLinuxConsole test as test_x86_64_pc Philippe Mathieu-Daudé
2018-10-19 18:15   ` Cleber Rosa
2018-10-13 15:15 ` [Qemu-devel] [RFC PATCH v3 2/6] tests/acceptance: Add a kludge to not use the default console Philippe Mathieu-Daudé
2018-10-19 17:37   ` Cleber Rosa
2018-10-19 17:45     ` Philippe Mathieu-Daudé
2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 3/6] tests/acceptance: Add test_mips_4kc_malta in BootLinuxConsole Philippe Mathieu-Daudé
2018-10-19 17:42   ` Cleber Rosa
2018-10-19 18:41     ` Philippe Mathieu-Daudé
2018-10-19 21:17       ` Cleber Rosa
2018-10-19 22:51         ` Cleber Rosa
2018-10-20  9:57           ` Philippe Mathieu-Daudé
2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 4/6] tests/acceptance: Add test_mipsel_5kc_malta " Philippe Mathieu-Daudé
2018-10-13 15:15 ` [Qemu-devel] [PATCH v3 5/6] tests/acceptance: Add test_sh4_r2d " Philippe Mathieu-Daudé
2018-10-13 15:56   ` Philippe Mathieu-Daudé
2018-10-13 15:15 ` [Qemu-devel] [RFC PATCH v3 6/6] tests/acceptance: Add test_sh4_r2d in BootLinuxTracing Philippe Mathieu-Daudé
2018-10-20  0:02   ` Cleber Rosa
2018-10-15  6:41 ` [Qemu-devel] [PATCH v3 0/6] Avocado: more multi-arch tests Thomas Huth
2018-10-19  5:13 ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.