From patchwork Fri Dec 20 12:04:33 2019 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: 182263 Delivered-To: patch@linaro.org Received: by 2002:a92:1f98:0:0:0:0:0 with SMTP id f24csp462309ilf; Fri, 20 Dec 2019 04:29:20 -0800 (PST) X-Google-Smtp-Source: APXvYqydo/StV1jvKkNxbKOxxNuvXOo+Hxvg/OIS+gNZIz1R/sxwXNs3ssx5tBavHbtubMrBnKkT X-Received: by 2002:a05:6830:1704:: with SMTP id 4mr14389331otk.294.1576844960668; Fri, 20 Dec 2019 04:29:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576844960; cv=none; d=google.com; s=arc-20160816; b=GNUpgYgd0nMcPdQW0J1F/Cb1jWnl/Oq12uOlnNAyBFGShYGg0q94tZQg/IK7hnGrlI 1tdO/OPTh3hkzq9d+ZRXYf6yEp1d8wA2pvBg/5rQA9JqpXZbFFVSX+WETbpasEcgSimJ RAiz8ogGWjxxH5hl/DTKBvonIYrFwvK0gYmoyBV4LM9MLkhRowUnr9dAJXIX5Ke5l7uv /3n2vwYvV+rrQT8kMTqrQK4NAQkuY7H4BMhVRQlz5MYfNHro3Mo+NuIqb4bIrXfwN+8J HMrmuj2FJkdTKBLPxzfhOVEzgUWXef4LPe4OV4v3Hy6UaT052/E7oHLhiyUp/MuAij3V fU5w== 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=Fd9ZwTx/nGTAxWisTrByxsrJjTVOwFrJUX5QQ3jkZWE=; b=rF/YDONtT5fnHzFAoHK8ooJgzDdxBNGeZ5RF+C+qG2Gi+x0dOslhPB982e93yRJULH xvPfxYYWkuTucH0pBuHRnjBARzPoNPyu/7tnegC6GofRXBz+ji5dUOzcQj634vLspxVW 6jR8YBGnI3AdjANr8gsXOOjPPjWOEhquCUBRUfKGPIvyduIwjQ/qJS9Lt7Do6o/Sk99s iETRRlPeqb8UebbJMxIq3XTYAijkdMhi671eqciwGTbQ3989MYLOY3yOnt4/p5FAu6/L UGCiX/eK5Kbbwc/YUD/2W+HcMqdwmu6/x9NaPp8HRPxjEpIyaEPlaH03r9QvvP7MaENB MD4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PnGgh0R+; 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 t12si4866389otm.224.2019.12.20.04.29.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Dec 2019 04:29:20 -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=PnGgh0R+; 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]:54502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiHPE-000301-1n for patch@linaro.org; Fri, 20 Dec 2019 07:29:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54392) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiH1v-00055K-Ax for qemu-devel@nongnu.org; Fri, 20 Dec 2019 07:05:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiH1r-0008UH-SW for qemu-devel@nongnu.org; Fri, 20 Dec 2019 07:05:14 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:34209) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiH1q-0008Qy-1x for qemu-devel@nongnu.org; Fri, 20 Dec 2019 07:05:10 -0500 Received: by mail-wr1-x434.google.com with SMTP id t2so9206000wrr.1 for ; Fri, 20 Dec 2019 04:05:09 -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=Fd9ZwTx/nGTAxWisTrByxsrJjTVOwFrJUX5QQ3jkZWE=; b=PnGgh0R+FuLJoLXgbUOqWoo88UXexq87sfNDL34DCTUZmg70y4egxTu3eHegGz20LV DdBYyM0xfslU5mbvOGCwgn7/Us1mj7ZodKEknlgvGeY9EH5/muHQ9d584zBBYpLozkT+ 03dTcXtXQvytcRaFRgad8ywVZzSoWz4MHdLbYRlvhJ9qJO2ilVc/divVDsG9qWUbc1nU xQdhTadQOHjXsDcdqm1R8YBQwPbGYTBMJoT1Boti1EJXjMDzll5iu0tRys5zm3SVaQhA yx2/zsP4BZzohxRkz/jNon4qKSYrv/nh+zhHQfvnZ9gcEiwaBpDRfC9iQTV5zvqobcDR PwPg== 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=Fd9ZwTx/nGTAxWisTrByxsrJjTVOwFrJUX5QQ3jkZWE=; b=CSkdT2/0HkxwhJORyHOf7XxuqtCWf4KtaiKufSVPEqxE2uOd9XNLFAk24PoV/pgoSJ M3FSaWi/ku+5nva7r+1lFT/IBT24o3GA9DP2sbvF+tAAK61r4npFND8DNGVGaE5CSShS mYelVdsXmYC12dEaP78hLZcmsI5/qQdv8FMlDhXonJuCD6PEVByCT3laUpHoJ1bkjVVm A+w/mqIUF91OLUl2GBJp9QKeMOWJcBB769xsBcIyjRstgduVQShKTC4JhaXGg8aDeIuy v6R41apMBUwFmif0V6UT5UUhdtTeTiY1kmhk+rXzzou0W/1WliESB70R+fDzuTu7TZiy 4ffw== X-Gm-Message-State: APjAAAWPQjByVwaMlbgo5F0PthjUsebIGXmHG9D+UPi30s8bg0nnqaft haeuaDIg0G0eVkqrYMhVUmFBnQ== X-Received: by 2002:a5d:548e:: with SMTP id h14mr15983487wrv.380.1576843508480; Fri, 20 Dec 2019 04:05:08 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k19sm9331183wmi.42.2019.12.20.04.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 04:04:53 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9850E1FFA3; Fri, 20 Dec 2019 12:04:40 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v4 16/21] tests/guest-debug: add a simple test runner Date: Fri, 20 Dec 2019 12:04:33 +0000 Message-Id: <20191220120438.16114-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220120438.16114-1-alex.bennee@linaro.org> References: <20191220120438.16114-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 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: damien.hedde@greensocs.com, =?utf-8?q?Alex_Benn=C3=A9e?= , luis.machado@linaro.org, alan.hayward@arm.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- tests/guest-debug/run-test.py | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 tests/guest-debug/run-test.py -- 2.20.1 diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py new file mode 100755 index 00000000000..8c49ee2f225 --- /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ée +# +# 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 = argparse.ArgumentParser(description="A gdbstub test runner") + parser.add_argument("--qemu", help="Qemu binary for test", + required=True) + parser.add_argument("--qargs", help="Qemu arguments for test") + parser.add_argument("--binary", help="Binary to debug", + required=True) + parser.add_argument("--test", help="GDB test script", + required=True) + parser.add_argument("--gdb", help="The gdb binary to use", default=None) + + return parser.parse_args() + +if __name__ == '__main__': + args = get_args() + + # Search for a gdb we can use + if not args.gdb: + args.gdb = shutil.which("gdb-multiarch") + if not args.gdb: + args.gdb = 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 = "%s %s %s -s -S" % (args.qemu, args.qargs, args.binary) + else: + cmd = "%s %s -g 1234 %s" % (args.qemu, args.qargs, args.binary) + + inferior = subprocess.Popen(shlex.split(cmd)) + + # Now launch gdb with our test and collect the result + gdb_cmd = "%s %s -ex 'target remote localhost:1234' -x %s" % (args.gdb, args.binary, args.test) + + result = subprocess.call(gdb_cmd, shell=True); + + exit(result)