From nobody Fri Dec 19 06:31:01 2025 Delivered-To: importer@patchew.org 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; 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=1579016157; cv=none; d=zohomail.com; s=zohoarc; b=O9J10BbLKvASy78qpg1RWpqM+VfUETcN+1AIaRdWksTtfLQ5EuA5KeGqRG5mv6DatzYNuXHQTkuJ3SfKa1L4fIz1BYJgj2fkGno6p/i06V2a8kcBvz78FYWQpRVAB6mT7DbMfRbYHy4cs2vMuuQCj3G7zCV8Ojph/lQd1tIoBnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579016157; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LEKvEpKhHPViJyLx2EXDEbN/QgNSwiOpcgG9WyeULSA=; b=gU0AVOjxzcQdXGTl3QA9YueMovMd5Td9uyY/80cW4cr2NiMWeOcxmUHSuhq/Om4yU+d3/logIkIyJ5y1uAhyL4mx8sGfd3aEpuv6+agmWIU+CeJf0SfZLgGPZ0SjOXIjZ5Y3e4RMPInYQN9dVNjUOfsq08d5Q8eKpAm5GidmXj8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579016157575673.0092700895464; Tue, 14 Jan 2020 07:35:57 -0800 (PST) Received: from localhost ([::1]:42256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irOEW-0004Qy-7H for importer@patchew.org; Tue, 14 Jan 2020 10:35:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39802) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irNy0-0008U8-GU for qemu-devel@nongnu.org; Tue, 14 Jan 2020 10:18:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irNxz-00089s-9l for qemu-devel@nongnu.org; Tue, 14 Jan 2020 10:18:52 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:54455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1irNxz-00088F-2Y for qemu-devel@nongnu.org; Tue, 14 Jan 2020 10:18:51 -0500 Received: by mail-wm1-x32c.google.com with SMTP id b19so14212429wmj.4 for ; Tue, 14 Jan 2020 07:18:50 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z3sm19933150wrs.94.2020.01.14.07.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 07:18:46 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F41651FF8C; Tue, 14 Jan 2020 15:09:56 +0000 (GMT) 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=LEKvEpKhHPViJyLx2EXDEbN/QgNSwiOpcgG9WyeULSA=; b=BdV2npNYgh2Or/5VOFsAlYXs1P02sIBeywwV152kmehNM/VCCXY/3EoiiFFRqs45qc GrfrFKNW993M6YQQ+l9xSfhoLi+Rfyx6GTuqYwT4ofm+ipetLinfI4vQo8kjoSyICyE9 xMYUpy2ya+r4yiEjRg3PP6w94Cgv22sqGnBR86FT3WTVQvnVoDqrWhpUVN/SVFQf8rzl BjzzK5n9PxX4XSW2p6pLcxLlMdy5P2bVUUh0jG2dhEwgYLNHKgFK3KNgQpIg1/tLv6Ev DFO/teLflsBHKH5O/T2hVdB0FSjF4XjfrPaW94bhP/5f9Wc3cYswJh2Q5p7opQhBWsTi YecA== 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=LEKvEpKhHPViJyLx2EXDEbN/QgNSwiOpcgG9WyeULSA=; b=nhF9hhoggA+YRAyx/4qwoM+Lh8TKvapl+k0QHlCKQbCgmhXChwAL/5Ck+C/u/s30L1 L7yWH3M/cm7xJHjOfbBvkAfnBYYmg8XendXqcQ8CuZU0BZW6CUsP/D3xThn1zknuE/hw t+mdHZTEEWft8MrOj4ad2FunV8FJt56uWUJgtl9+/h6Qr5APllAm7iuTkbXzrrC2omXF sHAmGoCjgnDrGQkQnXHmOgLREehXA7KmwKJ4ZDB2ZUgIvbmilkrnWQy5C+x9N5DD11MS FaN3Mpbnrz6QErKNlg6JbAniXSBYggx/iibuubRXJ3nR8880MHMYBmhvgpUwzy8/213L YHBA== X-Gm-Message-State: APjAAAV0diqvu57qB7pVvBm4OPTM3sNQTrIJOPKMecF0pTMRy0ceD9Go 51xGkkuXkT/0YjoKbTHq+Crgiw== X-Google-Smtp-Source: APXvYqw+8JsPmqj/MAPAobxevrEsrDxqo5az2CghVZ7uwMAbnjuJJ7eXLKM0ihZ8jaJJdJ+onpu52g== X-Received: by 2002:a1c:66d6:: with SMTP id a205mr27933680wmc.171.1579015130072; Tue, 14 Jan 2020 07:18:50 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 17/22] tests/guest-debug: add a simple test runner Date: Tue, 14 Jan 2020 15:09:48 +0000 Message-Id: <20200114150953.27659-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200114150953.27659-1-alex.bennee@linaro.org> References: <20200114150953.27659-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32c 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: qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) The test runners job is to start QEMU with guest debug enabled and then spawn a gdb process running a test script that exercises the functionality it wants to test. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- tests/guest-debug/run-test.py | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 tests/guest-debug/run-test.py diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py new file mode 100755 index 0000000000..8c49ee2f22 --- /dev/null +++ b/tests/guest-debug/run-test.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# +# Run a gdbstub test case +# +# Copyright (c) 2019 Linaro +# +# Author: Alex Benn=C3=A9e +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import argparse +import subprocess +import shutil +import shlex + +def get_args(): + parser =3D argparse.ArgumentParser(description=3D"A gdbstub test runne= r") + parser.add_argument("--qemu", help=3D"Qemu binary for test", + required=3DTrue) + parser.add_argument("--qargs", help=3D"Qemu arguments for test") + parser.add_argument("--binary", help=3D"Binary to debug", + required=3DTrue) + parser.add_argument("--test", help=3D"GDB test script", + required=3DTrue) + parser.add_argument("--gdb", help=3D"The gdb binary to use", default= =3DNone) + + return parser.parse_args() + +if __name__ =3D=3D '__main__': + args =3D get_args() + + # Search for a gdb we can use + if not args.gdb: + args.gdb =3D shutil.which("gdb-multiarch") + if not args.gdb: + args.gdb =3D shutil.which("gdb") + if not args.gdb: + print("We need gdb to run the test") + exit(-1) + + # Launch QEMU with binary + if "system" in args.qemu: + cmd =3D "%s %s %s -s -S" % (args.qemu, args.qargs, args.binary) + else: + cmd =3D "%s %s -g 1234 %s" % (args.qemu, args.qargs, args.binary) + + inferior =3D subprocess.Popen(shlex.split(cmd)) + + # Now launch gdb with our test and collect the result + gdb_cmd =3D "%s %s -ex 'target remote localhost:1234' -x %s" % (args.g= db, args.binary, args.test) + + result =3D subprocess.call(gdb_cmd, shell=3DTrue); + + exit(result) --=20 2.20.1