yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-Acceptance-tests-add-Linux-kernel-boot-and-console-c.patch

ae23c9
From a326b17336ae12d9fa492ea34b9b1b08150262d0 Mon Sep 17 00:00:00 2001
ae23c9
From: Yash Mankad <ymankad@redhat.com>
ae23c9
Date: Wed, 12 Dec 2018 00:14:39 +0000
ae23c9
Subject: [PATCH 11/13] Acceptance tests: add Linux kernel boot and console
ae23c9
 checking test
ae23c9
MIME-Version: 1.0
ae23c9
Content-Type: text/plain; charset=UTF-8
ae23c9
Content-Transfer-Encoding: 8bit
ae23c9
ae23c9
RH-Author: Yash Mankad <ymankad@redhat.com>
ae23c9
Message-id: <d56f34e8ffd54d5df93dadface61538e5a3c99ab.1544573601.git.ymankad@redhat.com>
ae23c9
Patchwork-id: 83433
ae23c9
O-Subject: [RHEL-8.0 qemu-kvm PATCH v2 5/7] Acceptance tests: add Linux kernel boot and console checking test
ae23c9
Bugzilla: 1655807
ae23c9
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ae23c9
ae23c9
From: Cleber Rosa <crosa@redhat.com>
ae23c9
ae23c9
This test boots a Linux kernel, and checks that the given command
ae23c9
line was effective in two ways:
ae23c9
ae23c9
 * It makes the kernel use the set "console device" as a console
ae23c9
 * The kernel records the command line as expected in the console
ae23c9
ae23c9
Given that way too many error conditions may occur, and detecting the
ae23c9
kernel boot progress status may not be trivial, this test relies on a
ae23c9
timeout to handle unexpected situations.  Also, it's *not* tagged as a
ae23c9
quick test for obvious reasons.
ae23c9
ae23c9
It may be useful, while interactively running/debugging this test, or
ae23c9
tests similar to this one, to show some of the logging channels.
ae23c9
Example:
ae23c9
ae23c9
 $ avocado --show=QMP,console run boot_linux_console.py
ae23c9
ae23c9
Signed-off-by: Cleber Rosa <crosa@redhat.com>
ae23c9
Message-Id: <20180530184156.15634-6-crosa@redhat.com>
ae23c9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
ae23c9
(cherry picked from commit c1cc73f407b890c4e7ab5bf520c0637e0364e92a)
ae23c9
Signed-off-by: Yash Mankad <ymankad@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 tests/acceptance/boot_linux_console.py | 47 ++++++++++++++++++++++++++++++++++
ae23c9
 1 file changed, 47 insertions(+)
ae23c9
 create mode 100644 tests/acceptance/boot_linux_console.py
ae23c9
ae23c9
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
ae23c9
new file mode 100644
ae23c9
index 0000000..98324f7
ae23c9
--- /dev/null
ae23c9
+++ b/tests/acceptance/boot_linux_console.py
ae23c9
@@ -0,0 +1,47 @@
ae23c9
+# Functional test that boots a Linux kernel and checks the console
ae23c9
+#
ae23c9
+# Copyright (c) 2018 Red Hat, Inc.
ae23c9
+#
ae23c9
+# Author:
ae23c9
+#  Cleber Rosa <crosa@redhat.com>
ae23c9
+#
ae23c9
+# This work is licensed under the terms of the GNU GPL, version 2 or
ae23c9
+# later.  See the COPYING file in the top-level directory.
ae23c9
+
ae23c9
+import logging
ae23c9
+
ae23c9
+from avocado_qemu import Test
ae23c9
+
ae23c9
+
ae23c9
+class BootLinuxConsole(Test):
ae23c9
+    """
ae23c9
+    Boots a x86_64 Linux kernel and checks that the console is operational
ae23c9
+    and the kernel command line is properly passed from QEMU to the kernel
ae23c9
+
ae23c9
+    :avocado: enable
ae23c9
+    :avocado: tags=x86_64
ae23c9
+    """
ae23c9
+
ae23c9
+    timeout = 60
ae23c9
+
ae23c9
+    def test(self):
ae23c9
+        kernel_url = ('https://mirrors.kernel.org/fedora/releases/28/'
ae23c9
+                      'Everything/x86_64/os/images/pxeboot/vmlinuz')
ae23c9
+        kernel_hash = '238e083e114c48200f80d889f7e32eeb2793e02a'
ae23c9
+        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
ae23c9
+
ae23c9
+        self.vm.set_machine('pc')
ae23c9
+        self.vm.set_console()
ae23c9
+        kernel_command_line = 'console=ttyS0'
ae23c9
+        self.vm.add_args('-kernel', kernel_path,
ae23c9
+                         '-append', kernel_command_line)
ae23c9
+        self.vm.launch()
ae23c9
+        console = self.vm.console_socket.makefile()
ae23c9
+        console_logger = logging.getLogger('console')
ae23c9
+        while True:
ae23c9
+            msg = console.readline()
ae23c9
+            console_logger.debug(msg.strip())
ae23c9
+            if 'Kernel command line: %s' % kernel_command_line in msg:
ae23c9
+                break
ae23c9
+            if 'Kernel panic - not syncing' in msg:
ae23c9
+                self.fail("Kernel panic reached")
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9