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

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