From nobody Tue May 21 02:16:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1675802736; cv=none; d=zohomail.com; s=zohoarc; b=YOIg83alDcLSBnZBgibjHgSql0gpjfRcJuKwyoY3/2t1qhN0r7C1ggv7buDcjVnoK5s8cqSUbNQGoK0gU+r1/3ESy5OY9dQyP7goo3sJDn1W4XJATfX32rTt77h0YUWvbF7w3OFU9fdWpgveJJxpsCPHm7idDtoXeCx5Z/RxaYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675802736; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=BCYtPFtyqePX+GuVb/E/tXIxhHB+OeSyenBZtfPgpu8=; b=JGFWY2y9/YSxGM9Cj0ZVayxIAngdmuaj3bQcD/2fFB/ig11ZUpjavbbD8+JSItpM4/bg3t/LuRUd3lxo5sOQKSkXR9giUWDMXKPWDxV1OExXaQ1CsLfm3qcg2XUNgFEI1ObJxT6uO0lpjtiagVJFXh2ymhiAAnzkPVyqjd/gXlo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167580273618458.90622700753477; Tue, 7 Feb 2023 12:45:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPUpa-0004gn-Mc; Tue, 07 Feb 2023 15:44:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPUpY-0004gN-KQ for qemu-devel@nongnu.org; Tue, 07 Feb 2023 15:44:44 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pPUpW-0005KB-1Q for qemu-devel@nongnu.org; Tue, 07 Feb 2023 15:44:44 -0500 Received: by mail-wm1-x32e.google.com with SMTP id hn2-20020a05600ca38200b003dc5cb96d46so14053164wmb.4 for ; Tue, 07 Feb 2023 12:44:41 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id v16-20020a05600c471000b003dd1bd66e0dsm16748970wmo.3.2023.02.07.12.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 12:44:39 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 673861FFB7; Tue, 7 Feb 2023 20:44:39 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BCYtPFtyqePX+GuVb/E/tXIxhHB+OeSyenBZtfPgpu8=; b=WZGyuM+QUWnW2eAjWvhhaGW1MSmeZmycrhpEYDm3gtG0I5xh93So7HnvS5C+oXvDH2 YKD9HpGCs9PKYhMcHfKQYA3nAwWEi+aP36jWJT/V5ulL0vGz6uvFPxq68VTVv+i0SBUF mKUQCFgGHMnfX4z9acACNOR8wKsCeh91ghhg+Ntqm0tQaoW/WXZP25zbavkAdNORyn1c MVITWiU+74VsDAkNOmOR+340khuJ1Gq4ARJfBoCyWwXpkgruMQ3tEzHMWM377ZjjSxI4 7tteL31twjs06miWMa26UalhVfdAJJmJeGelyG966EE8ifIR8gAUalyItQ55e3ApSn68 BB3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BCYtPFtyqePX+GuVb/E/tXIxhHB+OeSyenBZtfPgpu8=; b=wrRjHm3Wf8TcPdxp3QvTf4W2TAwY3KOsAo75CUckJpFkPRebMEmw3Bb1xYFTErOV9H MHQ2cnqbdSrfpXm6rhJvfmlxy4Zc3vmuqcQPJZFl4SMGUJtXiTuE19OYhqBNfEN7lHbz pLNOO9xx9CiOa9VJ37EcsbpAKNQTXCGT7pVqiHsux+yqPIZV+8uE6Tahtq49i6SXD58R 9tLufjnzSOpqjBJEwjCzrDUC1KapQM8J18x9Qyf3OrwlpItERzj6+6xa72Zx5NmSVFlE e5vvCqVnN3uYEl55ppE8kvzjbLLHeKBEIYb0fjEXiFRo/PgiAMwP9uc4oIoSwL0QzyxY myVQ== X-Gm-Message-State: AO0yUKVWLZhJ6yu2qJcXLHHbwhhVk33FaiGxONuQ8JYmN5wcF6BLm1Xq kh2wAWC0sHTahkuSBFLgp+bX9g== X-Google-Smtp-Source: AK7set/U/iZr/tlNMz2XzD0yea/gec4PnLaPjV8bqupAblVJqXJpST20fbYdKhEgQBVPHwAbQyJBRA== X-Received: by 2002:a05:600c:a294:b0:3e0:10d:f1c with SMTP id hu20-20020a05600ca29400b003e0010d0f1cmr4393935wmb.37.1675802680360; Tue, 07 Feb 2023 12:44:40 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Anders Roxell , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Beraldo Leal Subject: [RFC PATCH] tests: add LKFT baseline test to avocado Date: Tue, 7 Feb 2023 20:44:33 +0000 Message-Id: <20230207204433.752020-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1675802737718100001 The Linux Kernel Function Test (LKFT) project uses QEMU to test a wide variety of kernel configurations on wide range of our emulated platforms. They publish a known good set of images at: https://storage.tuxboot.com/ to help with bisecting regressions in either the kernel, firmware or QEMU itself. The tests are pretty lightweight as they contain just a kernel with a minimal rootfs which boots a lot faster than most of the distros. In time they might be persuaded to version there known good baselines and we can then enable proper checksums. Total run time: 140s Overall coverage rate: lines......: 8.7% (96412 of 1106284 lines) functions..: 10.8% (11515 of 106651 functions) branches...: 8.3% (30685 of 370255 branches) Signed-off-by: Alex Benn=C3=A9e Cc: Anders Roxell Reviewed-by: Fabiano Rosas --- tests/avocado/lkft_baselines.py | 257 ++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100755 tests/avocado/lkft_baselines.py diff --git a/tests/avocado/lkft_baselines.py b/tests/avocado/lkft_baselines= .py new file mode 100755 index 0000000000..f347150df7 --- /dev/null +++ b/tests/avocado/lkft_baselines.py @@ -0,0 +1,257 @@ +# Functional test that boots known good lkft images +# +# Copyright (c) 2023 Linaro Ltd. +# +# Author: +# Alex Benn=C3=A9e +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import time + +from avocado_qemu import QemuSystemTest +from avocado_qemu import exec_command, exec_command_and_wait_for_pattern +from avocado_qemu import wait_for_console_pattern +from avocado.utils import process +from avocado.utils.path import find_command + + +class LKFTBaselineTest(QemuSystemTest): + KERNEL_COMMON_COMMAND_LINE =3D 'printk.time=3D0 root=3D/dev/vda' + + def setUp(self): + super().setUp() + + # We need zstd for all the lkft tests + zstd =3D find_command('zstd', False) + if zstd is False: + self.cancel('Could not find "zstd", which is required to ' + 'decompress rootfs') + self.zstd =3D zstd + + # Process the LKFT specific tags, most machines work with + # reasonable defaults but we sometimes need to tweak the + # config. + + # The lfkt tag matches the root directory + self.lkft =3D self.params.get('lkft', + default =3D self._get_unique_tag_val('= lkft')) + + # Most Linux's use ttyS0 for their serial port + console =3D self.params.get('console', + default =3D self._get_unique_tag_val('co= nsole')) + if console: + self.console =3D console + else: + self.console =3D "ttyS0" + + # Does the machine shutdown QEMU nicely on "halt" + self.shutdown =3D self.params.get('shutdown', + default =3D self._get_unique_tag_val('= shutdown')) + + # The name of the kernel Image file + image =3D self.params.get('image', + default =3D self._get_unique_tag_val('imag= e')) + if not image: + self.image =3D "Image" + else: + self.image =3D image + + # The block device drive type + drive =3D self.params.get('drive', + default =3D self._get_unique_tag_val('driv= e')) + if not drive: + self.drive =3D "virtio-blk-device" + else: + self.drive =3D drive + + def wait_for_console_pattern(self, success_message, vm=3DNone): + wait_for_console_pattern(self, success_message, + failure_message=3D'Kernel panic - not syn= cing', + vm=3Dvm) + + def fetch_lkft_assets(self, dt=3DNone): + """ + Fetch the LKFT assets. They are stored in a standard way so we + use the per-test tags to fetch details. + """ + base_url =3D f"https://storage.tuxboot.com/{self.lkft}/" + kernel_image =3D self.fetch_asset(base_url + self.image) + disk_image_zst =3D self.fetch_asset(base_url + "rootfs.ext4.zst") + + cmd =3D f"{self.zstd} -d {disk_image_zst} -o {self.workdir}/rootfs= .ext4" + process.run(cmd) + + if dt: + dtb =3D self.fetch_asset(base_url + dt) + else: + dtb =3D None + + return (kernel_image, self.workdir + "/rootfs.ext4", dtb) + + def prepare_run(self, kernel, disk, dtb=3DNone): + """ + Setup to run and add the common parameters to the system + """ + self.vm.set_console() + + # all block devices are raw ext4's + blockdev =3D "driver=3Draw,file.driver=3Dfile," \ + + f"file.filename=3D{disk},node-name=3Dhd0" + + kernel_command_line =3D self.KERNEL_COMMON_COMMAND_LINE + \ + f" console=3D{self.console}" + + self.vm.add_args('-kernel', kernel, + '-append', kernel_command_line, + '-blockdev', blockdev, + '-device', f"{self.drive},drive=3Dhd0") + + # Some machines need an explicit DTB + if dtb: + self.vm.add_args('-dtb', dtb) + + def run_tuxtest_tests(self, haltmsg): + """ + Wait for the system to boot up, wait for the login prompt and + then do a few things on the console. Trigger a shutdown and + wait to exit cleanly. + """ + self.wait_for_console_pattern("Welcome to TuxTest") + time.sleep(0.1) + exec_command(self, 'root') + time.sleep(0.1) + exec_command(self, 'cat /proc/interrupts') + time.sleep(0.1) + exec_command(self, 'cat /proc/self/maps') + time.sleep(0.1) + exec_command(self, 'uname -a') + time.sleep(0.1) + exec_command_and_wait_for_pattern(self, 'halt', haltmsg) + + # Wait for VM to shut down gracefully if it can + if self.shutdown =3D=3D "nowait": + self.vm.shutdown() + else: + self.vm.wait() + + def common_lkft(self, dt=3DNone, haltmsg=3D"reboot: System halted"): + """ + Common path for LKFT tests. Unless we need to do something + special with the command line we can process most things using + the tag metadata. + """ + (kernel, disk, dtb) =3D self.fetch_lkft_assets(dt) + + self.prepare_run(kernel, disk, dtb) + self.vm.launch() + self.run_tuxtest_tests(haltmsg) + + def test_arm64(self): + """ + :avocado: tags=3Darch:aarch64 + :avocado: tags=3Dcpu:cortex-a57 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dlkft:arm64 + :avocado: tags=3Dconsole:ttyAMA0 + :avocado: tags=3Dshutdown:nowait + """ + self.common_lkft() + + def test_arm64be(self): + """ + :avocado: tags=3Darch:aarch64 + :avocado: tags=3Dcpu:cortex-a57 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dlkft:arm64be + :avocado: tags=3Dconsole:ttyAMA0 + :avocado: tags=3Dshutdown:nowait + """ + self.common_lkft() + + def test_armv5(self): + """ + :avocado: tags=3Darch:arm + :avocado: tags=3Dcpu:arm926 + :avocado: tags=3Dmachine:versatilepb + :avocado: tags=3Dlkft:armv5 + :avocado: tags=3Dimage:zImage + :avocado: tags=3Ddrive:virtio-blk-pci + :avocado: tags=3Dconsole:ttyAMA0 + :avocado: tags=3Dshutdown:nowait + """ + self.common_lkft(dt=3D"versatile-pb.dtb") + + def test_armv7(self): + """ + :avocado: tags=3Darch:arm + :avocado: tags=3Dcpu:cortex-a15 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dlkft:armv7 + :avocado: tags=3Dimage:zImage + :avocado: tags=3Dconsole:ttyAMA0 + :avocado: tags=3Dshutdown:nowait + """ + self.common_lkft() + + def test_armv7be(self): + """ + :avocado: tags=3Darch:arm + :avocado: tags=3Dcpu:cortex-a15 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dlkft:armv7be + :avocado: tags=3Dimage:zImage + :avocado: tags=3Dconsole:ttyAMA0 + :avocado: tags=3Dshutdown:nowait + """ + self.common_lkft() + + def test_i386(self): + """ + :avocado: tags=3Darch:i386 + :avocado: tags=3Dcpu:coreduo + :avocado: tags=3Dmachine:q35 + :avocado: tags=3Dlkft:i386 + :avocado: tags=3Dimage:bzImage + :avocado: tags=3Ddrive:virtio-blk-pci + :avocado: tags=3Dshutdown:nowait + """ + self.common_lkft() + + # def test_mips32(self): + # """ + # :avocado: tags=3Darch:mips + # :avocado: tags=3Dmachine:malta + # :avocado: tags=3Dlkft:mips32 + # :avocado: tags=3Dimage:vmlinux + # :avocado: tags=3Ddrive:virtio-blk-pci + # :avocado: tags=3Dshutdown:nowait + # """ + # self.common_lkft() + + def test_riscv32(self): + """ + :avocado: tags=3Darch:riscv32 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dlkft:riscv32 + """ + self.common_lkft() + + def test_riscv64(self): + """ + :avocado: tags=3Darch:riscv64 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dlkft:riscv64 + """ + self.common_lkft() + + def test_s390(self): + """ + :avocado: tags=3Darch:s390x + :avocado: tags=3Dlkft:s390 + :avocado: tags=3Dimage:bzImage + :avocado: tags=3Ddrive:virtio-blk-ccw + :avocado: tags=3Dshutdown:nowait + """ + self.common_lkft(haltmsg=3D"Requesting system halt") --=20 2.39.1