From patchwork Wed Feb 10 22:10:47 2021 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: 380261 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1577597jah; Wed, 10 Feb 2021 14:52:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBwBWpCH54BN5ceaElrGmeOAh9+0TqVlhlvIq8TkbQfXAXFkL29jcBdN2SNMhn8nWfHR22 X-Received: by 2002:a25:b8ca:: with SMTP id g10mr7010198ybm.517.1612997526583; Wed, 10 Feb 2021 14:52:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612997526; cv=none; d=google.com; s=arc-20160816; b=JyQ9C4Etpx07me4Lx8E9JDGxz6kCX8ltb+Ijj+PIF8/Jpsx7F8xvrpXA01gG6a3EVk zGTbuSQV2TuinR6tiUmACaDqCkBM2TKeGB1jEuhSwgxxy9ljHXZtzOY0nTfOs81D9+9S Fi0CVZJPsngMNIVjYrdnhttLNiTCUpjWRuEbPwZx+YApXzZQ8UnSP/XlJD8PIFpipel6 Fkyq7qgh7IRd2AUJI2Qk+dHvOzc1If+mQbMgvg1BmKvRKn43kJFKTNDCsP7SaeFp+WCJ TugEYDGLAIeZfKSUIuKRG6L2QuVUxr2HRbcErY0rq8/ZQC0LB6Hw6nZ3fb2GczfdJGLK DhWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=j4XmWVEBX2ENQRRduA5gKPU5AX0OB2Qj1ZjmkgHICaE=; b=JZmuSS/K6kOILzg6mxvNmEOBj4H7g+NS/Uh8Axg9niopxS5TbXRSPb2uZYPgpFazJj jEMO4+8/dJyfsofGwJDcErkZrXitSvsaDonRQ3UWWczBhEAoGz5YTEBUU2dBmEea09gE EYpbAToiUEOymFMENdIVsEjM97JHZfY4kV/tLdQyDhxXyvfZxQK0mX+f7tK5JJza1mEs IZ/8Ykiz2CjFI2t9OrBWgP1vNHXE81nFtgzqSc37Jz0VIrxoO6ly5dxuFDcBB2NspJuE uXJvL92Jl+2eKRNczrOfdqcouzjpZ++tAXFJpyzrW3ktr4pHjNPiHIYIKW+juEMMpBDS SAsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="fa6NFK/B"; 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=fail (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 x71si862973ybg.103.2021.02.10.14.52.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Feb 2021 14:52:06 -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=fail header.i=@linaro.org header.s=google header.b="fa6NFK/B"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9yL8-0007x3-2O for patch@linaro.org; Wed, 10 Feb 2021 17:52:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9xqD-0006w2-Na for qemu-devel@nongnu.org; Wed, 10 Feb 2021 17:20:09 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:55202) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9xqA-0006oI-DX for qemu-devel@nongnu.org; Wed, 10 Feb 2021 17:20:09 -0500 Received: by mail-wm1-x330.google.com with SMTP id w4so3205138wmi.4 for ; Wed, 10 Feb 2021 14:20:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j4XmWVEBX2ENQRRduA5gKPU5AX0OB2Qj1ZjmkgHICaE=; b=fa6NFK/B+UnoWsiE/5MwVW2nbwy14i6XChQfMDtKBl/B1grK17ouQUx9SpYU12Aqit UU8dDvjIfrZGxX0fcBDVAdV/qAwWasvnxNkrFqkNYRckV9Jmlx/5XMiDODyCxOYte9Pf dr6r8D2qHzmxpLdCJrLdEF/U6PYsocIjzBTv20XMm8hVURCF/HM/xuKlPfsQ6ZwkDAAc HOa/5YynFMSs9PTp+IndKQDcVSv1knnbg08Z+IKTfpU96Nk2dcy8wgTE4VhpfyFf44fb o2EwG4TLfJsIf4BisEHKpybzi3lCQNhNw7kzM+ZAtU/Q4H3Q/aPQEEOVzvNFSXLgS/Wk 2aGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j4XmWVEBX2ENQRRduA5gKPU5AX0OB2Qj1ZjmkgHICaE=; b=QQ/huGELzLY3ahgOqtBWbe3R37MblahT312ju9/lwkLVSvNOiB5EJKu/d9GV6VTR6P G7a9eOiIPTVUYwiDDSKDfBjw5/J2YlmZClWnn4nOYfYoKCQUM7SFcwQwMVyruWZvaylx flI7bCHRANxYpu22/eQJkvECVPadz97M5rZZ0REOAw6ZZBa3JneEaz8+VGZe+m8cY3n5 trVxzxYTL5KAAG4/QQLDIUZy33A3aGN8LhD5g4jCDYeDxlMqR1AMV8Ty8ZkMvq/We1Qs RKJPhBQ+KUxbUWfepBn2yfiPkFmNuGjH/AXURND4kiNtS9i+wiudHgR+NyJnl4LHTIOZ JduQ== X-Gm-Message-State: AOAM5325PpQlZ1rh0XRbahBkMSfbuMBWljZwY2D2ziXEqxmdcZ4XSRCr fi5v+fYp0rsyG5kAcJoiyUridQ== X-Received: by 2002:a1c:c904:: with SMTP id f4mr1270608wmb.14.1612995604850; Wed, 10 Feb 2021 14:20:04 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o83sm5038838wme.37.2021.02.10.14.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 14:20:04 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1376C1FF9E; Wed, 10 Feb 2021 22:10:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 15/21] tests/acceptance: add a new set of tests to exercise plugins Date: Wed, 10 Feb 2021 22:10:47 +0000 Message-Id: <20210210221053.18050-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210210221053.18050-1-alex.bennee@linaro.org> References: <20210210221053.18050-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , robhenry@microsoft.com, mahmoudabdalghany@outlook.com, aaron@os.amperecomputing.com, cota@braap.org, Wainer dos Santos Moschetta , Cleber Rosa , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is just a simple test to count the instructions executed by a kernel. However a later test will detect a failure condition when icount is enabled. Signed-off-by: Alex Bennée Message-Id: <20210209182749.31323-7-alex.bennee@linaro.org> --- tests/acceptance/tcg_plugins.py | 103 ++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 tests/acceptance/tcg_plugins.py -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé Tested-by: Wainer dos Santos Moschetta diff --git a/tests/acceptance/tcg_plugins.py b/tests/acceptance/tcg_plugins.py new file mode 100644 index 0000000000..b512979769 --- /dev/null +++ b/tests/acceptance/tcg_plugins.py @@ -0,0 +1,103 @@ +# TCG Plugins tests +# +# These are a little more involved than the basic tests run by check-tcg. +# +# Copyright (c) 2021 Linaro +# +# Author: +# Alex Bennée +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import logging +import time +import tempfile +import mmap +import re + +from boot_linux_console import LinuxKernelTest + + +class PluginKernelBase(LinuxKernelTest): + """ + Boots a Linux kernel with a TCG plugin enabled. + """ + + timeout = 120 + KERNEL_COMMON_COMMAND_LINE = 'printk.time=1 panic=-1 ' + + def run_vm(self, kernel_path, kernel_command_line, + plugin, plugin_log, console_pattern, args): + + logger = logging.getLogger('plugin') + start_time = time.time() + vm = self.get_vm() + vm.set_console() + vm.add_args('-kernel', kernel_path, + '-append', kernel_command_line, + '-plugin', plugin, + '-d', 'plugin', + '-D', plugin_log, + '-net', 'none', + '-no-reboot') + if args: + vm.add_args(*args) + + try: + vm.launch() + except: + # fails if plugins not enabled + self.cancel("TCG Plugins not enabled") + + self.wait_for_console_pattern(console_pattern, vm) + elapsed = time.time() - start_time + logger.info('elapsed time %.2f sec' % elapsed) + # ensure logs are flushed + vm.shutdown() + return elapsed + + +class PluginKernelNormal(PluginKernelBase): + + def _grab_aarch64_kernel(self): + kernel_url = ('http://security.debian.org/' + 'debian-security/pool/updates/main/l/linux-signed-arm64/' + 'linux-image-4.19.0-12-arm64_4.19.152-1_arm64.deb') + kernel_sha1 = '2036c2792f80ac9c4ccaae742b2e0a28385b6010' + kernel_deb = self.fetch_asset(kernel_url, asset_hash=kernel_sha1) + kernel_path = self.extract_from_deb(kernel_deb, + "/boot/vmlinuz-4.19.0-12-arm64") + return kernel_path + + def test_aarch64_virt_insn(self): + """ + :avocado: tags=accel:tcg + :avocado: tags=arch:aarch64 + :avocado: tags=machine:virt + :avocado: tags=cpu:cortex-a57 + """ + kernel_path = self._grab_aarch64_kernel() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyAMA0') + console_pattern = 'Kernel panic - not syncing: VFS:' + + plugin_log = tempfile.NamedTemporaryFile(mode="r+t", prefix="plugin", + suffix=".log") + + self.run_vm(kernel_path, kernel_command_line, + "tests/plugin/libinsn.so", plugin_log.name, + console_pattern, + args=('-cpu', 'cortex-a53')) + + logger = logging.getLogger() + + with plugin_log as lf, \ + mmap.mmap(lf.fileno(), 0, access=mmap.ACCESS_READ) as s: + + m = re.search(br"insns: (?P\d+)", s) + if "count" in m.groupdict(): + logger.debug("reported %d instructions", + int(m.group("count"))) + else: + logger.debug("Failed to find instruction count") + self.fail