diff mbox series

[RFC,7/7] avocado: Add tests booting the Malta machine

Message ID 20180419164642.9536-8-f4bug@amsat.org
State New
Headers show
Series avocado: Add acceptance tests parsing the Linux boot console | expand

Commit Message

Philippe Mathieu-Daudé April 19, 2018, 4:46 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/avocado/test_linux-boot-console.py      | 92 +++++++++++++++++++
 .../parameters.yaml                           |  2 +
 2 files changed, 94 insertions(+)

Comments

Cleber Rosa May 1, 2018, 9:20 p.m. UTC | #1
On 04/19/2018 12:46 PM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/avocado/test_linux-boot-console.py      | 92 +++++++++++++++++++
>  .../parameters.yaml                           |  2 +
>  2 files changed, 94 insertions(+)
> 
> diff --git a/tests/avocado/test_linux-boot-console.py b/tests/avocado/test_linux-boot-console.py
> index f54d10dd79..4ae1e3bf37 100644
> --- a/tests/avocado/test_linux-boot-console.py
> +++ b/tests/avocado/test_linux-boot-console.py
> @@ -86,3 +86,95 @@ class TestAlphaClipperBoot2_6(test.QemuTest):
>  
>      def tearDown(self):
>          os.remove(self.console_path)
> +
> +
> +class TestMips4kcMaltaBoot2_6(test.QemuTest):
> +    """
> +    :avocado: enable
> +    :avocado: tags=arch_mips
> +    """
> +    ARCH = "mips"
> +
> +    def kernel_url(self):
> +        return 'http://people.debian.org/~aurel32/qemu/mips/vmlinux-2.6.32-5-4kc-malta'
> +
> +    def setUp(self):
> +        self.console_path = tempfile.mkstemp()[1]
> +        kernel_path = cachedfile(self.kernel_url())
> +        self.vm._args.extend(['-machine', 'malta'])
> +        self.vm._args.extend(['-m', '64'])
> +        self.vm._args.extend(['-kernel', kernel_path])
> +        self.vm._args.extend(['-append', '"console=ttyS0 printk.time=0"'])
> +        self.vm._args.extend(['-chardev', 'socket,id=uart0,server,nowait,path=' + self.console_path])
> +        self.vm._args.extend(['-serial', 'chardev:uart0'])
> +        self.vm._args.extend(['-nographic'])
> +
> +    def test_boot_console(self):
> +        """
> +        :avocado: tags=uart,printk
> +        """
> +        if self.params.get('arch') != self.ARCH:
> +            return
> +
> +        self.vm.launch(self.console_path)
> +        console = self.vm.get_console(console_address=self.console_path, login=False)
> +        # no filesystem provided on purpose, wait for the Kernel panic
> +        bootlog = console.read_until_any_line_matches(["Kernel panic - not syncing: VFS: Unable to mount root fs"], timeout=6.0)[1]
> +        console.close()
> +        # check Super I/O
> +        self.assertIn(u'ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A', bootlog)
> +        self.assertIn(u'ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A', bootlog)
> +        self.assertIn(u'i8042 KBD port at 0x60,0x64 irq 1', bootlog)
> +        self.assertIn(u'i8042 AUX port at 0x60,0x64 irq 12', bootlog)
> +        # check PCI (network interface)
> +        self.assertIn(u'registered as PCnet/PCI II 79C970A', bootlog)
> +        self.vm.shutdown()
> +
> +    def tearDown(self):
> +        os.remove(self.console_path)
> +
> +# FIXME this is a copy of TestMips4kcMaltaBoot2_6 with a different the kernel url
> +class TestMips4kcMaltaBoot3_2(test.QemuTest):
> +    """
> +    :avocado: enable
> +    :avocado: tags=arch_mips
> +    """
> +    ARCH = "mips"
> +
> +    def kernel_url(self):
> +        return 'http://people.debian.org/~aurel32/qemu/mips/vmlinux-3.2.0-4-4kc-malta'
> +
> +    def setUp(self):
> +        self.console_path = tempfile.mkstemp()[1]
> +        kernel_path = cachedfile(self.kernel_url())
> +        self.vm._args.extend(['-machine', 'malta'])
> +        self.vm._args.extend(['-m', '64'])
> +        self.vm._args.extend(['-kernel', kernel_path])
> +        self.vm._args.extend(['-append', '"console=ttyS0 printk.time=0"'])
> +        self.vm._args.extend(['-chardev', 'socket,id=uart0,server,nowait,path=' + self.console_path])
> +        self.vm._args.extend(['-serial', 'chardev:uart0'])
> +        self.vm._args.extend(['-nographic'])
> +
> +    def test_boot_console(self):
> +        """
> +        :avocado: tags=uart,printk
> +        """
> +        if self.params.get('arch') != self.ARCH:
> +            return
> +
> +        self.vm.launch(self.console_path)
> +        console = self.vm.get_console(console_address=self.console_path, login=False)
> +        # no filesystem provided on purpose, wait for the Kernel panic
> +        bootlog = console.read_until_any_line_matches(["Kernel panic - not syncing: VFS: Unable to mount root fs"], timeout=6.0)[1]
> +        console.close()
> +        # check Super I/O
> +        self.assertIn(u'ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A', bootlog)
> +        self.assertIn(u'ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A', bootlog)
> +        self.assertIn(u'i8042 KBD port at 0x60,0x64 irq 1', bootlog)
> +        self.assertIn(u'i8042 AUX port at 0x60,0x64 irq 12', bootlog)
> +        # check PCI (network interface)
> +        self.assertIn(u'registered as PCnet/PCI II 79C970A', bootlog)
> +        self.vm.shutdown()
> +
> +    def tearDown(self):
> +        os.remove(self.console_path)
> diff --git a/tests/avocado/test_linux-boot-console.py.data/parameters.yaml b/tests/avocado/test_linux-boot-console.py.data/parameters.yaml
> index ed8c08058c..156f271a73 100644
> --- a/tests/avocado/test_linux-boot-console.py.data/parameters.yaml
> +++ b/tests/avocado/test_linux-boot-console.py.data/parameters.yaml
> @@ -1,3 +1,5 @@
>  architecture: !mux
>      alpha:
>          arch: alpha
> +    mips:
> +        arch: mips
> 

The reply to PATCH 0 showed that by a bit more configuration, all of
this code could be dropped.  That approach also solved the check for
architecture and canceling tests if they don't match.

I'd like to understand if this approach makes sense, or if you can see
any drawbacks.

Thanks!
- Cleber.
diff mbox series

Patch

diff --git a/tests/avocado/test_linux-boot-console.py b/tests/avocado/test_linux-boot-console.py
index f54d10dd79..4ae1e3bf37 100644
--- a/tests/avocado/test_linux-boot-console.py
+++ b/tests/avocado/test_linux-boot-console.py
@@ -86,3 +86,95 @@  class TestAlphaClipperBoot2_6(test.QemuTest):
 
     def tearDown(self):
         os.remove(self.console_path)
+
+
+class TestMips4kcMaltaBoot2_6(test.QemuTest):
+    """
+    :avocado: enable
+    :avocado: tags=arch_mips
+    """
+    ARCH = "mips"
+
+    def kernel_url(self):
+        return 'http://people.debian.org/~aurel32/qemu/mips/vmlinux-2.6.32-5-4kc-malta'
+
+    def setUp(self):
+        self.console_path = tempfile.mkstemp()[1]
+        kernel_path = cachedfile(self.kernel_url())
+        self.vm._args.extend(['-machine', 'malta'])
+        self.vm._args.extend(['-m', '64'])
+        self.vm._args.extend(['-kernel', kernel_path])
+        self.vm._args.extend(['-append', '"console=ttyS0 printk.time=0"'])
+        self.vm._args.extend(['-chardev', 'socket,id=uart0,server,nowait,path=' + self.console_path])
+        self.vm._args.extend(['-serial', 'chardev:uart0'])
+        self.vm._args.extend(['-nographic'])
+
+    def test_boot_console(self):
+        """
+        :avocado: tags=uart,printk
+        """
+        if self.params.get('arch') != self.ARCH:
+            return
+
+        self.vm.launch(self.console_path)
+        console = self.vm.get_console(console_address=self.console_path, login=False)
+        # no filesystem provided on purpose, wait for the Kernel panic
+        bootlog = console.read_until_any_line_matches(["Kernel panic - not syncing: VFS: Unable to mount root fs"], timeout=6.0)[1]
+        console.close()
+        # check Super I/O
+        self.assertIn(u'ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A', bootlog)
+        self.assertIn(u'ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A', bootlog)
+        self.assertIn(u'i8042 KBD port at 0x60,0x64 irq 1', bootlog)
+        self.assertIn(u'i8042 AUX port at 0x60,0x64 irq 12', bootlog)
+        # check PCI (network interface)
+        self.assertIn(u'registered as PCnet/PCI II 79C970A', bootlog)
+        self.vm.shutdown()
+
+    def tearDown(self):
+        os.remove(self.console_path)
+
+# FIXME this is a copy of TestMips4kcMaltaBoot2_6 with a different the kernel url
+class TestMips4kcMaltaBoot3_2(test.QemuTest):
+    """
+    :avocado: enable
+    :avocado: tags=arch_mips
+    """
+    ARCH = "mips"
+
+    def kernel_url(self):
+        return 'http://people.debian.org/~aurel32/qemu/mips/vmlinux-3.2.0-4-4kc-malta'
+
+    def setUp(self):
+        self.console_path = tempfile.mkstemp()[1]
+        kernel_path = cachedfile(self.kernel_url())
+        self.vm._args.extend(['-machine', 'malta'])
+        self.vm._args.extend(['-m', '64'])
+        self.vm._args.extend(['-kernel', kernel_path])
+        self.vm._args.extend(['-append', '"console=ttyS0 printk.time=0"'])
+        self.vm._args.extend(['-chardev', 'socket,id=uart0,server,nowait,path=' + self.console_path])
+        self.vm._args.extend(['-serial', 'chardev:uart0'])
+        self.vm._args.extend(['-nographic'])
+
+    def test_boot_console(self):
+        """
+        :avocado: tags=uart,printk
+        """
+        if self.params.get('arch') != self.ARCH:
+            return
+
+        self.vm.launch(self.console_path)
+        console = self.vm.get_console(console_address=self.console_path, login=False)
+        # no filesystem provided on purpose, wait for the Kernel panic
+        bootlog = console.read_until_any_line_matches(["Kernel panic - not syncing: VFS: Unable to mount root fs"], timeout=6.0)[1]
+        console.close()
+        # check Super I/O
+        self.assertIn(u'ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A', bootlog)
+        self.assertIn(u'ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A', bootlog)
+        self.assertIn(u'i8042 KBD port at 0x60,0x64 irq 1', bootlog)
+        self.assertIn(u'i8042 AUX port at 0x60,0x64 irq 12', bootlog)
+        # check PCI (network interface)
+        self.assertIn(u'registered as PCnet/PCI II 79C970A', bootlog)
+        self.vm.shutdown()
+
+    def tearDown(self):
+        os.remove(self.console_path)
diff --git a/tests/avocado/test_linux-boot-console.py.data/parameters.yaml b/tests/avocado/test_linux-boot-console.py.data/parameters.yaml
index ed8c08058c..156f271a73 100644
--- a/tests/avocado/test_linux-boot-console.py.data/parameters.yaml
+++ b/tests/avocado/test_linux-boot-console.py.data/parameters.yaml
@@ -1,3 +1,5 @@ 
 architecture: !mux
     alpha:
         arch: alpha
+    mips:
+        arch: mips