From patchwork Tue Feb 7 20:44:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 651268 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp3103245pva; Tue, 7 Feb 2023 12:45:35 -0800 (PST) X-Google-Smtp-Source: AK7set9mYvN8050tj8Vhk9XBAH01KxkAlak4rciYBDQBe7hzjKs80LNae+ePITs4o0YTP/YGb1y7 X-Received: by 2002:ad4:5dca:0:b0:532:2dd4:fea5 with SMTP id m10-20020ad45dca000000b005322dd4fea5mr6919813qvh.7.1675802735633; Tue, 07 Feb 2023 12:45:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675802735; cv=none; d=google.com; s=arc-20160816; b=ewZSxBP0M968o+PWKy1kHajBbbW0WgvLmyTWicJXjErQhRWbehYo1QP4d6JIZ2uOGh Ey4C4LQKzgCv+fIZJuPiFCNM9nOJp8YDbr/LV6eXzb38LNAKI4VG6zIn6UQ48V73Ylhl sbTbpnPERSWqkXR+RFF662Na9sbIIk5ERL5WV7IdBQA1JPDRLEDJT7CgElsCnTp3gIhi KZXiw1SG2E65kvkURuEcCJTjf9rWkmd2k3VJtKJH0olmT/NcPOaHhIKnq+mBXUT7I4YV 1s3mrrxxk+dJJPttTYR6qd1MbXWcyKiEKizKdAAvGk4zBeHlRcB76uuDVsozJf0U2Eug eoxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=BCYtPFtyqePX+GuVb/E/tXIxhHB+OeSyenBZtfPgpu8=; b=pEg+x9bJNtnje2z6weEwHqOUOUQaC1PwLnJy1fSKnCUV2NPdhLVD36X2uUusCRC5gy e66PZ/bWX+FNgQboezdERvXXAqN4FheDJqjzxJAexTsGNLGUT4kdbFvCzyxsdLkxPZgI aQGZGvQpEf6nsryCAtPlKK7dewN2F+7RDaoWTX8GCDXooz8V0KrcSuUDGiDKcqr+9fiw LidUxaJPhAkc70KKU60VDpvDf7NIFBPknd4dbPX4CT7bOs7UTXnUV3W0EKDCxYLt9YXh jUDl1T5gqy1jcrBjvnq4CjbtQx/RQnSADu3hv0RPOf4AeRTcjZqU+RJiciZYTqS2Gkcq myGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WZGyuM+Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u20-20020a05620a455400b00708f1710705si12608959qkp.115.2023.02.07.12.45.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Feb 2023 12:45:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WZGyuM+Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Anders Roxell , Cleber Rosa , =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée 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ée +# +# 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 = 'printk.time=0 root=/dev/vda' + + def setUp(self): + super().setUp() + + # We need zstd for all the lkft tests + zstd = find_command('zstd', False) + if zstd is False: + self.cancel('Could not find "zstd", which is required to ' + 'decompress rootfs') + self.zstd = 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 = self.params.get('lkft', + default = self._get_unique_tag_val('lkft')) + + # Most Linux's use ttyS0 for their serial port + console = self.params.get('console', + default = self._get_unique_tag_val('console')) + if console: + self.console = console + else: + self.console = "ttyS0" + + # Does the machine shutdown QEMU nicely on "halt" + self.shutdown = self.params.get('shutdown', + default = self._get_unique_tag_val('shutdown')) + + # The name of the kernel Image file + image = self.params.get('image', + default = self._get_unique_tag_val('image')) + if not image: + self.image = "Image" + else: + self.image = image + + # The block device drive type + drive = self.params.get('drive', + default = self._get_unique_tag_val('drive')) + if not drive: + self.drive = "virtio-blk-device" + else: + self.drive = drive + + def wait_for_console_pattern(self, success_message, vm=None): + wait_for_console_pattern(self, success_message, + failure_message='Kernel panic - not syncing', + vm=vm) + + def fetch_lkft_assets(self, dt=None): + """ + Fetch the LKFT assets. They are stored in a standard way so we + use the per-test tags to fetch details. + """ + base_url = f"https://storage.tuxboot.com/{self.lkft}/" + kernel_image = self.fetch_asset(base_url + self.image) + disk_image_zst = self.fetch_asset(base_url + "rootfs.ext4.zst") + + cmd = f"{self.zstd} -d {disk_image_zst} -o {self.workdir}/rootfs.ext4" + process.run(cmd) + + if dt: + dtb = self.fetch_asset(base_url + dt) + else: + dtb = None + + return (kernel_image, self.workdir + "/rootfs.ext4", dtb) + + def prepare_run(self, kernel, disk, dtb=None): + """ + Setup to run and add the common parameters to the system + """ + self.vm.set_console() + + # all block devices are raw ext4's + blockdev = "driver=raw,file.driver=file," \ + + f"file.filename={disk},node-name=hd0" + + kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + \ + f" console={self.console}" + + self.vm.add_args('-kernel', kernel, + '-append', kernel_command_line, + '-blockdev', blockdev, + '-device', f"{self.drive},drive=hd0") + + # 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 == "nowait": + self.vm.shutdown() + else: + self.vm.wait() + + def common_lkft(self, dt=None, haltmsg="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) = 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=arch:aarch64 + :avocado: tags=cpu:cortex-a57 + :avocado: tags=machine:virt + :avocado: tags=lkft:arm64 + :avocado: tags=console:ttyAMA0 + :avocado: tags=shutdown:nowait + """ + self.common_lkft() + + def test_arm64be(self): + """ + :avocado: tags=arch:aarch64 + :avocado: tags=cpu:cortex-a57 + :avocado: tags=machine:virt + :avocado: tags=lkft:arm64be + :avocado: tags=console:ttyAMA0 + :avocado: tags=shutdown:nowait + """ + self.common_lkft() + + def test_armv5(self): + """ + :avocado: tags=arch:arm + :avocado: tags=cpu:arm926 + :avocado: tags=machine:versatilepb + :avocado: tags=lkft:armv5 + :avocado: tags=image:zImage + :avocado: tags=drive:virtio-blk-pci + :avocado: tags=console:ttyAMA0 + :avocado: tags=shutdown:nowait + """ + self.common_lkft(dt="versatile-pb.dtb") + + def test_armv7(self): + """ + :avocado: tags=arch:arm + :avocado: tags=cpu:cortex-a15 + :avocado: tags=machine:virt + :avocado: tags=lkft:armv7 + :avocado: tags=image:zImage + :avocado: tags=console:ttyAMA0 + :avocado: tags=shutdown:nowait + """ + self.common_lkft() + + def test_armv7be(self): + """ + :avocado: tags=arch:arm + :avocado: tags=cpu:cortex-a15 + :avocado: tags=machine:virt + :avocado: tags=lkft:armv7be + :avocado: tags=image:zImage + :avocado: tags=console:ttyAMA0 + :avocado: tags=shutdown:nowait + """ + self.common_lkft() + + def test_i386(self): + """ + :avocado: tags=arch:i386 + :avocado: tags=cpu:coreduo + :avocado: tags=machine:q35 + :avocado: tags=lkft:i386 + :avocado: tags=image:bzImage + :avocado: tags=drive:virtio-blk-pci + :avocado: tags=shutdown:nowait + """ + self.common_lkft() + + # def test_mips32(self): + # """ + # :avocado: tags=arch:mips + # :avocado: tags=machine:malta + # :avocado: tags=lkft:mips32 + # :avocado: tags=image:vmlinux + # :avocado: tags=drive:virtio-blk-pci + # :avocado: tags=shutdown:nowait + # """ + # self.common_lkft() + + def test_riscv32(self): + """ + :avocado: tags=arch:riscv32 + :avocado: tags=machine:virt + :avocado: tags=lkft:riscv32 + """ + self.common_lkft() + + def test_riscv64(self): + """ + :avocado: tags=arch:riscv64 + :avocado: tags=machine:virt + :avocado: tags=lkft:riscv64 + """ + self.common_lkft() + + def test_s390(self): + """ + :avocado: tags=arch:s390x + :avocado: tags=lkft:s390 + :avocado: tags=image:bzImage + :avocado: tags=drive:virtio-blk-ccw + :avocado: tags=shutdown:nowait + """ + self.common_lkft(haltmsg="Requesting system halt")