From nobody Mon Feb 9 20:57:07 2026 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=1755614472; cv=none; d=zohomail.com; s=zohoarc; b=G5u50/g8/pksllaP5fjdh4jhuvIPJTH72uUusipnr/F2J/AXyA5VYDlqhPhQJWFJ5J+u1Meu/AlgymveI87sIfaPUoSZezB+iprqsLdeHp12pn2uOdjeFElsQUypSaUZwRWQ3dfUUmlQDayWichcSSIOhizYL9znc1mzBtUZx0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755614472; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9/VN3GPgg1jh0q/5htuJyzPpfUsFvwOK+Czt3j5TkpY=; b=krSwDLQ2dPeGk9mBsxA7bLKhwTqJ2GAS+nB28i46sbYTXryEEXZiwCDWbKDu7Vo8eDQPnwbR4PXVaBZFME/TEAkv98iVpV3/D3oB1QW0lYmTd9bpKfHKCQlIO0KQenH/JjekC0fpSZYCAEfFL+mU5as3zgFmg3uRGIz5bjhruI4= 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 1755614472860254.27927580020912; Tue, 19 Aug 2025 07:41:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uoNV7-0007Ma-4F; Tue, 19 Aug 2025 10:39:49 -0400 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 1uoNV6-0007M3-0I for qemu-devel@nongnu.org; Tue, 19 Aug 2025 10:39:48 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uoNV4-0007rJ-E1 for qemu-devel@nongnu.org; Tue, 19 Aug 2025 10:39:47 -0400 Received: by mail-pf1-x443.google.com with SMTP id d2e1a72fcca58-76e34c4ce54so4093228b3a.0 for ; Tue, 19 Aug 2025 07:39:46 -0700 (PDT) Received: from gromero0.. (201-1-50-181.dsl.telesp.net.br. [201.1.50.181]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76e7d0d98dfsm2769781b3a.17.2025.08.19.07.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Aug 2025 07:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755614385; x=1756219185; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9/VN3GPgg1jh0q/5htuJyzPpfUsFvwOK+Czt3j5TkpY=; b=Xgvf/IQParZmoMLO4GTK4CMc2rk79D98R+R+b7YwPWAU3ken21rhNdrkZDmPj//o/j T3YkhplUYf4z8r0J+uhlR/BbYW7pP1IgZMW3CgGMFRZRBDcKgIdsj8UnotErYGUjM8uE VNZLzH8ikW9ZIXLksP2rTLsRDBJAW58nENoruqgFwNxz3RqFlKtFt06pq+tRU101M3ZZ /44B07AGfy+7HwB/zxJdrGCq2aCmV+gSW+/4ic/X0OSiD3RMhb90bY5+eEWJ4Vyt12/h KQ1b+sUyaCnLaO6N0nZlwJFKFmp446lWVrneybsFphxyv++bWTfavyMJdaHDeXDzKZcI gTPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755614385; x=1756219185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9/VN3GPgg1jh0q/5htuJyzPpfUsFvwOK+Czt3j5TkpY=; b=qKWLTbZlX7rHWzKa+0ni6YW5Byk8Yu+vkdQP91G+N/Tr9VKXkAbDDnDWZ4QLvX4NvP jOsls9LXR7Pw6KK3JXxPZvm83xzq9A7QGYPy4q0mAVQ355A0xKmdIB6IyVAnms3BWCkq 82N4GX6WI57M0KEnnfYCXP79v9eQRsSmbrdmouTalt/EElWEOlITaNrcGgcJdJpxqHnV Fc09AFoIoVaEIKxN5qOlNSToC50vFu8TUO0FQk7l/lfeVRpZxzK4Tita4lRP6GIcW5DW pqpkS/BIz3OiZ7YMovBceaZLK/8n4FiEYmcgpe1Lz2afyznUPZ3JjCTR4nYcP5OHR3Es nr9w== X-Gm-Message-State: AOJu0YwPu/uzZGVb6NItkwxvXOCHhcSA4nUssUS1RpOrdejA2SzyaErP 1+/TPmgfSRMzrflNsKs/P70b1R9H7+r9jAIasNnOwYqDSwBnxZB8AGRuIuYYNregHEAtcL1PPJR mQLVhZRi0Aw== X-Gm-Gg: ASbGncuF+CtB9DQJ61juinrGkgSJefN1zFvsYUjuCRzGNrlI7QzJZLFVwJboHcUxH1B S41kpFzoHwhnx/K+3uWA7wr0iI4makaKylIECrtj+1Pfl4jaiFLqu/4BNaJDbfGD3P5v9zyzZ6/ 7y7yVnYieh7pC6hAaUhPDYLPGQlyFWjsl1DvwuBiooBiLo/v5n9zQgZyMHjGyBfhbQdTp1YPipG jEyDk4MvYumYrVcfuCaQgCHWSQPdMLGaCqNMZ7xKxRv/pKK8DRkbf0PANmmMFFnbtdcPYGXUnU+ rlgbH5fO3MooaqnojX2Qm8P00K469j7Toqocl35LF1RGw7c/RVgUTN1lRnrFL2/UotmwVlVdNsc 6haEI4rXY0nV0wqiaHbaJheynsB7s/5ZGa/C5YgeFAH0KBM7WNEPFzMUlug== X-Google-Smtp-Source: AGHT+IFvvVzq/mDGhAHxBgNDdgBj9NMOEGMxFSqDozyz8NqRgw2HMt91v5UYyc7sAG21gsR58b/IGQ== X-Received: by 2002:a05:6a00:27a1:b0:76b:fdac:d884 with SMTP id d2e1a72fcca58-76e81407892mr2921789b3a.3.1755614384430; Tue, 19 Aug 2025 07:39:44 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com Cc: qemu-arm@nongnu.org, 1844144@gmail.com, gustavo.romero@linaro.org Subject: [PATCH 1/4] tests/guest-debug: Make QEMU optional in run-test.py Date: Tue, 19 Aug 2025 14:39:13 +0000 Message-Id: <20250819143916.4138035-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250819143916.4138035-1-gustavo.romero@linaro.org> References: <20250819143916.4138035-1-gustavo.romero@linaro.org> 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=2607:f8b0:4864:20::443; envelope-from=gustavo.romero@linaro.org; helo=mail-pf1-x443.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=unavailable 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: 1755614475739124100 This commit makes QEMU optional in run-test.py, allowing it to be used as a GDB runner, i.e., to call GDB and pass a test script to it without launching QEMU. In this configuration, it is the test script=E2=80=99s duty= to configure and run the VMs that GDB connects to. The --binary option continues to be required when --qemu is passed. sys.argv now includes the full path to the test script in addition to the script=E2=80=99s arguments, which allows unittest introspection to work properly in case it is used in the test script. Signed-off-by: Gustavo Romero --- tests/guest-debug/run-test.py | 81 +++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index 75e9c92e03..7fa17aedca 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -22,10 +22,10 @@ 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) + required=3DFalse) parser.add_argument("--qargs", help=3D"Qemu arguments for test") parser.add_argument("--binary", help=3D"Binary to debug", - required=3DTrue) + required=3DFalse) parser.add_argument("--test", help=3D"GDB test script") parser.add_argument('test_args', nargs=3D'*', help=3D"Additional args for GDB test script. " @@ -53,7 +53,7 @@ def log(output, msg): if __name__ =3D=3D '__main__': args =3D get_args() =20 - # Search for a gdb we can use + # Search for a gdb we can use. if not args.gdb: args.gdb =3D shutil.which("gdb-multiarch") if not args.gdb: @@ -73,41 +73,49 @@ def log(output, msg): socket_dir =3D TemporaryDirectory("qemu-gdbstub") socket_name =3D os.path.join(socket_dir.name, "gdbstub.socket") =20 - # Launch QEMU with binary - if "system" in args.qemu: - if args.no_suspend: - suspend =3D '' - else: - suspend =3D ' -S' - cmd =3D f'{args.qemu} {args.qargs} {args.binary}' \ - f'{suspend} -gdb unix:path=3D{socket_name},server=3Don' - else: - if args.no_suspend: - suspend =3D ',suspend=3Dn' - else: - suspend =3D '' - cmd =3D f'{args.qemu} {args.qargs} -g {socket_name}{suspend}' \ - f' {args.binary}' - - log(output, "QEMU CMD: %s" % (cmd)) - inferior =3D subprocess.Popen(shlex.split(cmd)) + if args.qemu and not args.binary: + print("QEMU needs a binary to run, but no binary provided") + exit(-1) =20 - # Now launch gdb with our test and collect the result - gdb_cmd =3D "%s %s" % (args.gdb, args.binary) + if args.qemu: + # Launch QEMU with binary. + if "system" in args.qemu: + if args.no_suspend: + suspend =3D '' + else: + suspend =3D ' -S' + cmd =3D f'{args.qemu} {args.qargs} {args.binary}' \ + f'{suspend} -gdb unix:path=3D{socket_name},server=3Don' + else: + if args.no_suspend: + suspend =3D ',suspend=3Dn' + else: + suspend =3D '' + cmd =3D f'{args.qemu} {args.qargs} -g {socket_name}{suspend}' \ + f' {args.binary}' + + log(output, "QEMU CMD: %s" % (cmd)) + inferior =3D subprocess.Popen(shlex.split(cmd)) + + # Now launch gdb with our test and collect the result. + gdb_cmd =3D args.gdb + if args.binary: + gdb_cmd +=3D " %s" % (args.binary) if args.gdb_args: gdb_cmd +=3D " %s" % (args.gdb_args) - # run quietly and ignore .gdbinit + # Run quietly and ignore .gdbinit. gdb_cmd +=3D " -q -n -batch" - # disable pagination + # Disable pagination. gdb_cmd +=3D " -ex 'set pagination off'" - # disable prompts in case of crash + # Disable prompts in case of crash. gdb_cmd +=3D " -ex 'set confirm off'" - # connect to remote - gdb_cmd +=3D " -ex 'target remote %s'" % (socket_name) - # finally the test script itself + # Connect automatically to remote only if QEMU is launched. + if args.qemu: + gdb_cmd +=3D " -ex 'target remote %s'" % (socket_name) + # Finally the test script itself. if args.test: - if args.test_args: - gdb_cmd +=3D f" -ex \"py sys.argv=3D{args.test_args}\"" + argv =3D [args.test] + args.test_args + gdb_cmd +=3D f" -ex \"py sys.argv=3D{argv}\"" gdb_cmd +=3D " -x %s" % (args.test) =20 =20 @@ -129,10 +137,11 @@ def log(output, msg): log(output, "GDB crashed? (%d, %d) SKIPPING" % (result, result - 1= 28)) exit(0) =20 - try: - inferior.wait(2) - except subprocess.TimeoutExpired: - log(output, "GDB never connected? Killed guest") - inferior.kill() + if args.qemu: + try: + inferior.wait(2) + except subprocess.TimeoutExpired: + log(output, "GDB never connected? Killed guest") + inferior.kill() =20 exit(result) --=20 2.34.1 From nobody Mon Feb 9 20:57:07 2026 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=1755614455; cv=none; d=zohomail.com; s=zohoarc; b=BjS9CeFvhz2JmvUGpqvS3NUPCa/fKfVVllYcKx30//WYRtv9yXxdGkwbL4Qj/sf3dGBX6GDdsly8i73/rapt181DBxkOt9jG86hMFmvhI5CTGnN63WUvrvgJa9mZ48yO1ZAeRAP38iwvl0z3MJYu1h41p4ilAEwoPTCPDS208E8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755614455; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bpkf+k5WP9D7t0RxDyD9FNYxub6lt0Xa3IB6Yu63rSs=; b=iOeN1spjHWZa38Zj/4XGaD+S2xxPpsItoQBW/jXKE8pDhw6PAo1giQ3/4BSmP3BtiLTBb5ZpdoOe9PdwEYf6fMITz7eERaQDDg6byWF5i0LIlk1IaJWyYSoeaX2WxFlhadUoP53AOFelanSTBulb5G/2Z4/0ZCgRpFpgOMPRjKU= 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 1755614455194369.61386229156403; Tue, 19 Aug 2025 07:40:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uoNV9-0007NU-Vm; Tue, 19 Aug 2025 10:39:52 -0400 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 1uoNV8-0007NB-L6 for qemu-devel@nongnu.org; Tue, 19 Aug 2025 10:39:50 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uoNV6-0007ro-T9 for qemu-devel@nongnu.org; Tue, 19 Aug 2025 10:39:50 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-76e2eb3726cso3403402b3a.3 for ; Tue, 19 Aug 2025 07:39:48 -0700 (PDT) Received: from gromero0.. (201-1-50-181.dsl.telesp.net.br. [201.1.50.181]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76e7d0d98dfsm2769781b3a.17.2025.08.19.07.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Aug 2025 07:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755614387; x=1756219187; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bpkf+k5WP9D7t0RxDyD9FNYxub6lt0Xa3IB6Yu63rSs=; b=RYD35A7CwXXtgpMbqsiifcbYDTmp708We+qgXEWbjVPWYy9SSBpHQhW5Akb9oIFkDq MiIgv3ZH9R+bQxvB+eVkiNyylPb7e2F0pxiWzCbuK3RGtoYFaqqwYZynSzcSxahqUPtN 1VmAWj+Gt6PdKPlhkIyA5koqK77/D9dfi6Gk1zn9MMqn6T9iDVNv/1mpQ47QQH6C6L/L tLCV0KoAZEbBXquVsu7ANHomRtSRqzhZA3jaOfEQ4XQKJ4BqZc4v7hIIpuUsTxgyYpiJ gBfEHafNsmLrIaTlKBDZRpxtHKuH7mxiqRcXKE2aI+Ti+KRCSg4YgWyQ53h4dHsz0L8c gKFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755614387; x=1756219187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bpkf+k5WP9D7t0RxDyD9FNYxub6lt0Xa3IB6Yu63rSs=; b=nmhK+Hg9Qg3+6iE7nkE541NRM82WolIXH1dhRg25ivSOvLFKzkZAc3kI9/DqdBtsuL DPkXLeLBL7yOpmugvh4MftzritPzP/F+BiezczeJUol9P00nZ8o46zZNHNS1gywv/jIY ycvCPtUwfo4ghA9PtUMAnteqcLurxO9xNG29dVzRSTXzbeWoeGgwDNtByhAEgUiTbMk5 kM9z9BdSAK3uqvdLeWiQFE/3s0kJx+/cUN2zn/mGsRpvOjZ8yrkJxWDYqF8jMCJ2pBaJ a6yU8nvyGeqX6BStkbbxPLldJ8I+J8RzMD0Usrn5YiTk2Ysfr0L8rwGpAn9lDEeYpNjT 5Wbw== X-Gm-Message-State: AOJu0YyEQ48hcwvlL0Ny9a4WhyeaUjpQWhgVlSwrIs4IWVT7Ijd4fK1d vGA5YGFPyHPhKSIO59IOQwbi06CMGRyaRV41/zkbqcl15ZVLDJnONx274dAxW5gcUT5JMdFe9/i xd3HNgoA= X-Gm-Gg: ASbGncvg+7r8zOS4nKMUMq+mVCcdkPRoOXT0kuhzAMnwgslhEQiOydxSGhAnzddg5s2 SnWy+W58hgb6UUPO+zYuE4dfZkLVD0iuRk6TqWAUaLAHUelf979NykwUpum0jJx77eopNXmUC7e NlZEvYH/Yc0ExzoU7HC7xlXau1fBzf9SNBHzhaRJS9Unz0kGPnjAT2iIGBxwJtQsFvro1lG2ha/ o6T70WKVnb7pg0Y6mHPMd7tU6xEkyU/FVUocf/M24JxzSnSxEdgap208PyCw7elm/Z3xUXKnSHh 8vg0htnjrwm8aPPC5PP1N5cJSH10082aVHowqYgT9qohH7sfFgpXeqt1WgOfs41DFsstKca0ul/ ugf+EIEFyWHKpEMVdTPIpJ/4AJ9t9T/aLAnsdVWdbA7CGLYZ/jeBWsfRqTQ== X-Google-Smtp-Source: AGHT+IFWEL25s6qK8e/rwE6Z+4eAjA+HeOQ8UWL085SUxuhBr0S9WVdFIdX9DkczZh9B/I6TwGtgLg== X-Received: by 2002:a05:6a00:1741:b0:76b:e936:607 with SMTP id d2e1a72fcca58-76e80dd34c3mr3141180b3a.0.1755614386830; Tue, 19 Aug 2025 07:39:46 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com Cc: qemu-arm@nongnu.org, 1844144@gmail.com, gustavo.romero@linaro.org Subject: [PATCH 2/4] tests/functional: Support tests that require a runner Date: Tue, 19 Aug 2025 14:39:14 +0000 Message-Id: <20250819143916.4138035-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250819143916.4138035-1-gustavo.romero@linaro.org> References: <20250819143916.4138035-1-gustavo.romero@linaro.org> MIME-Version: 1.0 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=2607:f8b0:4864:20::434; envelope-from=gustavo.romero@linaro.org; helo=mail-pf1-x434.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=unavailable 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: 1755614457597116600 Content-Type: text/plain; charset="utf-8" Add support for running tests that require a specific runner. The test is specified via a tuple (name, runner, protocol), where name is the test name as found in the tests/functional directory without the 'test_' prefix and the .py extension, runner is an array containing the runner and any arguments required by the runner, and protocol is the test protocol used by Meson to determine whether the test passed or failed. The test tuples are added to arrays that follow the current naming logic but with the suffix '_with_runner' appended to their names. In Meson it's not easy to select an element in an array at runtime based on its type, so it's simpler to have a new array for these new test types than use the current ones from the tests that don't require a runner, and so avoid mixing strings and tuples in the same array. Currently there is only one runner, the GDB runner, but more runners can be defined and associated to a test via the tuple. Signed-off-by: Gustavo Romero --- meson.build | 4 +++ tests/functional/meson.build | 62 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/meson.build b/meson.build index 50c774a195..8d482f0809 100644 --- a/meson.build +++ b/meson.build @@ -75,6 +75,10 @@ have_user =3D have_linux_user or have_bsd_user =20 sh =3D find_program('sh') python =3D import('python').find_installation() +# Meson python.get_path() on 'purelib' or 'platlib' doesn't properly retur= n the +# site-packages dir in pyvenv, so it is built manually. +python_ver =3D python.language_version() +python_site_packages =3D meson.build_root() / 'pyvenv/lib/python' + python= _ver / 'site-packages' =20 cc =3D meson.get_compiler('c') all_languages =3D ['c'] diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 311c6f1806..1f70b70fd4 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -349,6 +349,23 @@ tests_xtensa_system_thorough =3D [ 'xtensa_replay', ] =20 +# Tests that require a specific runner. +gdb =3D find_program('gdb-multiarch', required: false) +if gdb.found() + gdb_runner_script =3D meson.project_source_root() + '/tests/guest-deb= ug/run-test.py' + gdb_runner =3D [gdb_runner_script, '--gdb', gdb, '--test'] + + # A test with a runner is a tuple (name, runner, protocol). + # The tests must be elements of an array named like: + # + # test____with_runner =3D [ + # ['test0', gdb_runner, 'exitcode'], + # ... + # ] +else + message('GDB multiarch not found, skipping functional tests that rely = on it.') +endif + precache_all =3D [] foreach speed : ['quick', 'thorough'] foreach dir : target_dirs @@ -372,9 +389,11 @@ foreach speed : ['quick', 'thorough'] suites =3D ['func-quick', 'func-' + target_base] target_tests =3D get_variable('tests_' + target_base + '_' + sysmode= + '_quick', []) \ + get_variable('tests_generic_' + sysmode) + target_tests_r =3D get_variable('tests_' + target_base + '_' + sysmo= de + '_quick_with_runner', []) else suites =3D ['func-' + speed, 'func-' + target_base + '-' + speed, sp= eed] target_tests =3D get_variable('tests_' + target_base + '_' + sysmode= + '_' + speed, []) + target_tests_r =3D get_variable('tests_' + target_base + '_' + sysmo= de + '_' + speed + '_with_runner', []) endif =20 test_deps =3D [roms, keymap_targets] @@ -423,6 +442,49 @@ foreach speed : ['quick', 'thorough'] priority: test_timeouts.get(test, 90), suite: suites) endforeach + + # Prepare tests that require a specific runner. + foreach test : target_tests_r + testname =3D '@0@-@1@'.format(target_base, test[0]) + testfile =3D 'test_' + test[0] + '.py' + testpath =3D meson.current_source_dir() / testfile + teststamp =3D testname + '.tstamp' + testrunner =3D test[1] + testproto =3D test[2] + + test_precache_env =3D environment() + test_precache_env.set('QEMU_TEST_PRECACHE', meson.current_build_dir(= ) / teststamp) + # python_site_packages, i.e., site packages from Python in pyvenv, is + # added to PYTHONPATH because some runners can run a program that ha= s its + # own Python hooks that, by its turn, will search for modules based = on + # PYTHONPATH independently of the Python used by the runner, like, f= or + # example, GDB using libpython. + test_precache_env.set('PYTHONPATH', meson.project_source_root() / 'p= ython' + + ':' + meson.current_source_dir()= + + ':' + python_site_packages) + precache =3D custom_target('func-precache-' + testname, + output: teststamp, + command: [testrunner, testpath], + depend_files: files(testpath), + build_by_default: false, + env: test_precache_env) + precache_all +=3D precache + + # See comment above about python_site_packages in test_precache_env. + # Don't append to test_env since it will affect previous uses of it. + test_r_env =3D test_env + test_r_env.append('PYTHONPATH', python_site_packages) + + test('func-' + testname, + python, + depends: [test_deps, test_emulator, emulator_modules, plugin_mo= dules], + env: test_r_env, + args: [testrunner, testpath], + protocol: testproto, + timeout: test_timeouts.get(test[0], 90), + priority: test_timeouts.get(test[0], 90), + suite: suites) + endforeach endforeach endforeach =20 --=20 2.34.1 From nobody Mon Feb 9 20:57:07 2026 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=1755614485; cv=none; d=zohomail.com; s=zohoarc; b=UeX94SDgdkUwU+P0Pry+zu9hczoacM/Ty8O+RwFHGw94PL/QjgSJ1NYss8k3gb2A5DnF0KK+RoPzmaN7SUbKb+beAgHgTJ+2wNcYzIMvMRdO5B0BGXL1nFULQmQxXzGUVxa4WlrwyWbPWFDqWjcJLFC3Z534b6X5SDrX/snq0UQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755614485; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Bg+k3hCxedWSieuVGpi9ScxqcvbuIhQ+IUaNh83oJgU=; b=L/ehEs4mmEv8XUMLg61v4i+nbcrueRaIn9V/tcWB8ND6BphMwcko+jzDi/ziCvDWCNqBq5hww1GOw9+IZfD2yx5ETKbEM5UgeSZ4SmzxdVknf5/NmaCgnLM20+Op9dvcSrMZHrLWEoD/z6NyvfzFj28Dv2oUtPRfFCnmYkCLtmA= 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 1755614485794775.914252772966; Tue, 19 Aug 2025 07:41:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uoNVC-0007PU-8Q; Tue, 19 Aug 2025 10:39:54 -0400 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 1uoNVA-0007Ny-Ij for qemu-devel@nongnu.org; Tue, 19 Aug 2025 10:39:52 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uoNV8-0007sE-Qb for qemu-devel@nongnu.org; Tue, 19 Aug 2025 10:39:52 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-76e2ebe86ecso6139141b3a.3 for ; Tue, 19 Aug 2025 07:39:50 -0700 (PDT) Received: from gromero0.. (201-1-50-181.dsl.telesp.net.br. [201.1.50.181]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76e7d0d98dfsm2769781b3a.17.2025.08.19.07.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Aug 2025 07:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755614389; x=1756219189; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bg+k3hCxedWSieuVGpi9ScxqcvbuIhQ+IUaNh83oJgU=; b=UqqFoPtlEenOMevwVcVChSm1/Ob6vkbHvN7OOkjsuFb7VCM1T/9f8K9anPvfdCmfj6 BU/nU76NWiDI9ypRtjmng/b3HKoD5YUtd7fEyN7GqK9yqGBNvuKplI5I9aAcqCmHWqBv ZFiMlss5pZspbphJqwO69J83OLgTP1Q/isXEaejEZM/0F0WKDT1kC4eAKAehlvsfMv13 N5C0bRc0Uu7p5BP06EXfpiCJfItSBbqG6L4qv3aV1T3dxWMhmfKZ/aBlbXjNi+mS5Bd7 TL9nVUue3nrQcLYzoupub4ZxMFV72HS1I+NI0QkKlnGOw2EC7A1zmrjmtonQeXb6FSm0 9dow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755614389; x=1756219189; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bg+k3hCxedWSieuVGpi9ScxqcvbuIhQ+IUaNh83oJgU=; b=wlZI1zy0bIpjFJLU06kv+L1s+vDUCm2v4/3yUPAwtL82n969GIqp4PZrxYSAwiGccf 6YP+rYf4iWGBMKHphyCI5GalgQTpsdN/g53rLZUjI2e+fjNeQlW5dwR4YZbqhNcEDbzn h1dMHlKqc+Utu7tUpgiI+60q2hpQYvw5OtUF+98Qmri8oAdgaCebiPw1MuFgCT9Ia4Zw wG0D1EXjWoRmVXiuhCrRr2XTTcPdBvVQMv77BxIv0INu3DwES1eaoDxcQbjA7KKlp4gg K0zVDSg7kGjSN7x9YmO1mL/C/WKqzxVwK7sLeLnqkT52IGpAB/gR5XuMj5vb6zoReqNu O7Qw== X-Gm-Message-State: AOJu0YxS5xOwWS/DD8/yIonFRrkhNqGHnHu7tfACwUrx9g8+TRchOPYQ lZkU8ii++tL9UiQMQrn/7X1QEVcmfB/574SNS/cAZdIzBiZGTjcfF6ZzPX/MMMKn67kFpB1NA8e prOEa5sY= X-Gm-Gg: ASbGncs2a/UdSPLrCias3WOKcs0zQmSZCW4wuZSnbEQU5p9/WZVyV9BsqjfIHp2Xh7Z wVmCBD0VYx6tihun3iquvqwmn35jDd4LTyxYlhxTB42q394JA4k6kGgdaZ8zON+G3h866YTD40r wrQx8FgNbwgaSfm7D6e35YksLruwUYCr6fEby93TlQ3SvsCsUiq+/wNzCCpST5E8mar7GNvVxx1 nH50GbAKvKE/GAzPvl0YAZigKmu3MgC3GXziPe5XKp12QpnN6h3GFm+tfCSGblp9MmYXpre/qab OjEmcq/GoWJjHNtEpOTr/Q2EWNZVUV+oRUOj4zZfonUi2tFvI7zu+06+cRIXSfTckF8IpbcmYMA FWK5yRMQmwW8pxVfyAeOZb6SaporBYDkAthiGfMxJMhwkwZFnygYLiUh7vr+LCr+YURPU X-Google-Smtp-Source: AGHT+IEQPB8dlBCjPRoo4crzTen0dvdrgPYMiDq9BkmQNghMGicvOR5AGdOPpStkm9SS0/utOaEf5w== X-Received: by 2002:a05:6a21:3394:b0:240:1e63:2e13 with SMTP id adf61e73a8af0-2430d4c7384mr4097668637.41.1755614389253; Tue, 19 Aug 2025 07:39:49 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com Cc: qemu-arm@nongnu.org, 1844144@gmail.com, gustavo.romero@linaro.org Subject: [PATCH 3/4] tests/functional: Mark main in QemuBaseTest class as a static method Date: Tue, 19 Aug 2025 14:39:15 +0000 Message-Id: <20250819143916.4138035-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250819143916.4138035-1-gustavo.romero@linaro.org> References: <20250819143916.4138035-1-gustavo.romero@linaro.org> MIME-Version: 1.0 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=2607:f8b0:4864:20::42c; envelope-from=gustavo.romero@linaro.org; helo=mail-pf1-x42c.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: 1755614487439116600 Content-Type: text/plain; charset="utf-8" The main() method in the QemuBaseTest class has no parameters but is defined as a regular method. Currently, this does not cause any issues because in the functional tests main() is always called directly from QemuBaseTest (never from instances), but the way this method is defined makes its signature wrong, implying a 'self'. Hence, it's best practice to define such a method as a static method, so decorate it with @staticmethod. Signed-off-by: Gustavo Romero Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/functional/qemu_test/testcase.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu= _test/testcase.py index 5caf7b13fe..fbeb171058 100644 --- a/tests/functional/qemu_test/testcase.py +++ b/tests/functional/qemu_test/testcase.py @@ -235,6 +235,7 @@ def tearDown(self): self.log.removeHandler(self._log_fh) self._log_fh.close() =20 + @staticmethod def main(): warnings.simplefilter("default") os.environ["PYTHONWARNINGS"] =3D "default" --=20 2.34.1 From nobody Mon Feb 9 20:57:07 2026 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=1755614489; cv=none; d=zohomail.com; s=zohoarc; b=KzjiN5lNy7BXUfEuOonrLld48G89TI0OrjTngp9dvMvbyTagUyUSfITtl862Qes6ik6lP1CRQIOleAvi+JF7VPmh1Ul5HZk/z91IJAkWMU04nIwNySIiybQ5B9vDrjZ3wYS4rY5toOZkeqZNERibq9vaS4JooFItURdojKHsVrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755614489; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=htBca9WWi4zYUSeYT7afxg87xpdN1FE0D9KeyL5j5AM=; b=LzAN7kSkmaB4rGnqRuiQfEz+tT9m66nk3ZIWiNcror8jKhhNIvGwPRdfvU0qJBqvw4BSWnrqBBbx0W8QNoXt4dRGYRKclGDkvqS56aU3Bmi4PvXYBR/WRwNW8k0ANXNrETZh8/y69WZrQ79etK3swrJXF9HAD2RfFTHqMZPc5BA= 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 1755614489643909.2850684532217; Tue, 19 Aug 2025 07:41:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uoNVG-0007RB-1w; Tue, 19 Aug 2025 10:39:58 -0400 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 1uoNVE-0007Py-5P for qemu-devel@nongnu.org; Tue, 19 Aug 2025 10:39:56 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uoNVB-0007sw-G4 for qemu-devel@nongnu.org; Tue, 19 Aug 2025 10:39:55 -0400 Received: by mail-pf1-x444.google.com with SMTP id d2e1a72fcca58-76e2ea94c7dso5936223b3a.2 for ; Tue, 19 Aug 2025 07:39:53 -0700 (PDT) Received: from gromero0.. (201-1-50-181.dsl.telesp.net.br. [201.1.50.181]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76e7d0d98dfsm2769781b3a.17.2025.08.19.07.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Aug 2025 07:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755614392; x=1756219192; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=htBca9WWi4zYUSeYT7afxg87xpdN1FE0D9KeyL5j5AM=; b=so6YGbQHiESpzKDuJ5wSwMDwC+UX1YnAI2pbri/+jHwykp/OAXd4pf5qooe3I11rDq b7i4YJl21PHHEGDrH0nG/fKOhTalqMC5nUDs9AQS/zuLeMIS2jNHje+dhA/5hwZ+lytM 7QPb4UIDCnjsCnXXtL0xBHkr7liC7qM+A6ZU22+FB8vRoxnxX601nM6chKOBRMzYlXDs rFLs2CgOc4RnOxHgl2bOUiDLkKmZ1WCY8A/4hr4waWg8NEGE+AAOdTF6TGwVsuVvR5wg MTBShjtuAZ6gMzDqXIhcZOkum1ysK97z5EtkAvkJWs+zcfK02s9/hGSIUPCYjprVysfO MMNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755614392; x=1756219192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=htBca9WWi4zYUSeYT7afxg87xpdN1FE0D9KeyL5j5AM=; b=ukW4jgu3HG4JTYlc7/Nuor/iGJHuOJ+Q4D0grLp/c/TIG58nkzkoRKPDCzf/IiX6kb +HaAGBXe1VR+WdjLvXF+/+BZphsbmA/gpt8Z4jVOGA2hvkrjIMhHIW+Efyz3DK5xCuRF BiNCSkXYpfrzt0VmMt6RpnKWMzBKe2OSbXZdsZnjZzHO20VSEHqauWwtJ6y1a7GIo1mA 6CBoi2wWLzPrD3JMVZBwwwuqOaOBxl2AeBhcFrLB1cr3TAnWPPyZ3C8e0Vn5Ta8oTJ6I yZVCM2izJzmwR4e5dlwPDIamIkcax4+fIqEMR7DsudEOVGSORIIt8aQd8Q8HG6joq8Ar YI+w== X-Gm-Message-State: AOJu0Yy9qVObf9n6YIXXY8BXHWqVRYq7JPTWPLkmNI6wTT1qeAWNiyUN 4UuuYinChp5KKPVE0UElvEslTPDWcYwwN+mM5ofRjeTGiRB+7b53zAClsJZSGhag6GFfzBy+5jA DnnJ61ENrKw== X-Gm-Gg: ASbGncvVJwo1jk5Ds08N2/sgfiYuIIDPsX/ISOnK04czLdfgzR3CeoIbpNz6Es+2oSr UQ+05+4slEwvXV0/rfbSpVcet1XZNBZGOEqeXBxChe+kYp2QUjI/LxFGdRv9aD8+20HMGDCIrBh GwnWAbV7514vsYVa1zihVE8ScfzQm+V8dZg1/On7cFXQPmVyLco9Pj+XncGG4xd4H2h2tNmR5Pt AR99HJQP8js7CHP3VHatzGP5oTnodkHvfUdHc8oi14REuue76KCHI8bhgoU7WPzzyzLwaRJHvmZ JqD1ugf+YioJYArdFXSJQffUlLrPvvMPp3lo0H4yHU7q7rqerJAXS9NWKd98f9EM9v/Nx3susen Wkstl5OJGOLodokiV3+QTHgdScUSd/1o8+07IXpW8MT5AxXHau7CVdErQiQ== X-Google-Smtp-Source: AGHT+IEx3Q6tQcr0sv8b4sOLPataRsLGDIjvC/+A9k9t64NhoPVWVQd1vqF9bM6R0aeqdgUBCB/07Q== X-Received: by 2002:a05:6a00:4b46:b0:748:e585:3c42 with SMTP id d2e1a72fcca58-76e810fb847mr3391377b3a.15.1755614391719; Tue, 19 Aug 2025 07:39:51 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com Cc: qemu-arm@nongnu.org, 1844144@gmail.com, gustavo.romero@linaro.org Subject: [PATCH 4/4] tests/functional: Adapt reverse_debugging to run w/o Avocado Date: Tue, 19 Aug 2025 14:39:16 +0000 Message-Id: <20250819143916.4138035-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250819143916.4138035-1-gustavo.romero@linaro.org> References: <20250819143916.4138035-1-gustavo.romero@linaro.org> 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=2607:f8b0:4864:20::444; envelope-from=gustavo.romero@linaro.org; helo=mail-pf1-x444.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: 1755614491807116600 This commit removes Avocado as a dependency for running the reverse_debugging test. The main benefit, beyond eliminating an extra dependency, is that there is no longer any need to handle GDB packets manually. This removes the need for ad-hoc functions dealing with endianness and arch-specific register numbers, making the test easier to read. The timeout variable is also removed, since Meson now manages timeouts automatically. The reverse_debugging test is now executed through a runner, because it requires GDB in addition to QMP. The runner is responsible for invoking GDB with the appropriate arguments and for passing the test script to GDB. Since the test now runs inside GDB, its output, particularly from 'stepi' commands, which cannot be disabled, interleaves with the TAP output from unittest. To avoid this conflict, the test no longer uses Meson=E2=80=99s 'tap' protocol and instead relies on the simpler 'exitcode' protocol. reverse_debugging is kept "skipped" for aarch64, ppc64, and x86_64, so won't run unless QEMU_TEST_FLAKY_TESTS=3D1 is set in the test environment, before running 'make check-functional' or 'meson test [...]'. Signed-off-by: Gustavo Romero --- tests/functional/meson.build | 15 +- tests/functional/reverse_debugging.py | 158 +++++++++--------- .../functional/test_aarch64_reverse_debug.py | 19 +-- tests/functional/test_ppc64_reverse_debug.py | 17 +- tests/functional/test_x86_64_reverse_debug.py | 21 +-- 5 files changed, 111 insertions(+), 119 deletions(-) diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 1f70b70fd4..9eb11dad9f 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -93,7 +93,6 @@ tests_aarch64_system_thorough =3D [ 'aarch64_raspi3', 'aarch64_raspi4', 'aarch64_replay', - 'aarch64_reverse_debug', 'aarch64_rme_virt', 'aarch64_rme_sbsaref', 'aarch64_sbsaref', @@ -254,7 +253,6 @@ tests_ppc64_system_thorough =3D [ 'ppc64_powernv', 'ppc64_pseries', 'ppc64_replay', - 'ppc64_reverse_debug', 'ppc64_tuxrun', 'ppc64_mac99', ] @@ -340,7 +338,6 @@ tests_x86_64_system_thorough =3D [ 'x86_64_hotplug_cpu', 'x86_64_kvm_xen', 'x86_64_replay', - 'x86_64_reverse_debug', 'x86_64_tuxrun', ] =20 @@ -362,6 +359,18 @@ if gdb.found() # ['test0', gdb_runner, 'exitcode'], # ... # ] + + tests_aarch64_system_thorough_with_runner =3D [ + ['aarch64_reverse_debug', gdb_runner, 'exitcode'], + ] + + tests_ppc64_system_thorough_with_runner =3D [ + ['ppc64_reverse_debug', gdb_runner, 'exitcode'], + ] + + tests_x86_64_system_thorough_with_runner =3D [ + ['x86_64_reverse_debug', gdb_runner, 'exitcode'], + ] else message('GDB multiarch not found, skipping functional tests that rely = on it.') endif diff --git a/tests/functional/reverse_debugging.py b/tests/functional/rever= se_debugging.py index f9a1d395f1..f4ee9a68bd 100644 --- a/tests/functional/reverse_debugging.py +++ b/tests/functional/reverse_debugging.py @@ -1,16 +1,26 @@ -# Reverse debugging test -# # SPDX-License-Identifier: GPL-2.0-or-later # +# Reverse debugging test +# # Copyright (c) 2020 ISP RAS +# Copyright (c) 2025 Linaro Limited # # Author: # Pavel Dovgalyuk +# Gustavo Romero (Run without Avocado) # # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -import os + +try: + import gdb +except ModuleNotFoundError: + from sys import exit + exit("This script must be launched via tests/guest-debug/run-test.py!") import logging +import os +import subprocess + =20 from qemu_test import LinuxKernelTest, get_qemu_img from qemu_test.ports import Ports @@ -28,13 +38,9 @@ class ReverseDebugging(LinuxKernelTest): that the execution is stopped at the last of them. """ =20 - timeout =3D 10 STEPS =3D 10 - endian_is_le =3D True =20 def run_vm(self, record, shift, args, replay_path, image_path, port): - from avocado.utils import datadrainer - logger =3D logging.getLogger('replay') vm =3D self.get_vm(name=3D'record' if record else 'replay') vm.set_console() @@ -52,59 +58,46 @@ def run_vm(self, record, shift, args, replay_path, imag= e_path, port): if args: vm.add_args(*args) vm.launch() - console_drainer =3D datadrainer.LineLogger(vm.console_socket.filen= o(), - logger=3Dself.log.getChild('console'), - stop_check=3D(lambda : not vm.is_runni= ng())) - console_drainer.start() + return vm =20 @staticmethod - def get_reg_le(g, reg): - res =3D g.cmd(b'p%x' % reg) - num =3D 0 - for i in range(len(res))[-2::-2]: - num =3D 0x100 * num + int(res[i:i + 2], 16) - return num + def gdb_connect(host, port): + # Set debug on connection to get the qSupport string. + gdb.execute("set debug remote 1") + r =3D gdb.execute(f"target remote {host}:{port}", False, True) + gdb.execute("set debug remote 0") + + return r =20 @staticmethod - def get_reg_be(g, reg): - res =3D g.cmd(b'p%x' % reg) - return int(res, 16) - - def get_reg(self, g, reg): - # value may be encoded in BE or LE order - if self.endian_is_le: - return self.get_reg_le(g, reg) - else: - return self.get_reg_be(g, reg) + def get_pc(): + val =3D gdb.parse_and_eval("$pc") + pc =3D int(val) =20 - def get_pc(self, g): - return self.get_reg(g, self.REG_PC) + return pc =20 - def check_pc(self, g, addr): - pc =3D self.get_pc(g) + def check_pc(self, addr): + pc =3D self.get_pc() if pc !=3D addr: self.fail('Invalid PC (read %x instead of %x)' % (pc, addr)) =20 @staticmethod - def gdb_step(g): - g.cmd(b's', b'T05thread:01;') + def gdb_step(): + gdb.execute("stepi") =20 @staticmethod - def gdb_bstep(g): - g.cmd(b'bs', b'T05thread:01;') + def gdb_bstep(): + gdb.execute("reverse-stepi") =20 @staticmethod def vm_get_icount(vm): return vm.qmp('query-replay')['return']['icount'] =20 def reverse_debugging(self, shift=3D7, args=3DNone): - from avocado.utils import gdb - from avocado.utils import process - logger =3D logging.getLogger('replay') =20 - # create qcow2 for snapshots + # Create qcow2 for snapshots logger.info('creating qcow2 image for VM snapshots') image_path =3D os.path.join(self.workdir, 'disk.qcow2') qemu_img =3D get_qemu_img(self) @@ -112,11 +105,11 @@ def reverse_debugging(self, shift=3D7, args=3DNone): self.skipTest('Could not find "qemu-img", which is required to= ' 'create the temporary qcow2 image') cmd =3D '%s create -f qcow2 %s 128M' % (qemu_img, image_path) - process.run(cmd) + subprocess.run(cmd, shell=3DTrue) =20 replay_path =3D os.path.join(self.workdir, 'replay.bin') =20 - # record the log + # Record the log. vm =3D self.run_vm(True, shift, args, replay_path, image_path, -1) while self.vm_get_icount(vm) <=3D self.STEPS: pass @@ -125,72 +118,71 @@ def reverse_debugging(self, shift=3D7, args=3DNone): =20 logger.info("recorded log with %s+ steps" % last_icount) =20 - # replay and run debug commands + # Replay and run debug commands. with Ports() as ports: port =3D ports.find_free_port() vm =3D self.run_vm(False, shift, args, replay_path, image_path= , port) - logger.info('connecting to gdbstub') - g =3D gdb.GDBRemote('127.0.0.1', port, False, False) - g.connect() - r =3D g.cmd(b'qSupported') - if b'qXfer:features:read+' in r: - g.cmd(b'qXfer:features:read:target.xml:0,ffb') - if b'ReverseStep+' not in r: + logger.info('Connecting to gdbstub') + r =3D self.gdb_connect('127.0.0.1', port) + if 'ReverseStep+' not in r: self.fail('Reverse step is not supported by QEMU') - if b'ReverseContinue+' not in r: + if 'ReverseContinue+' not in r: self.fail('Reverse continue is not supported by QEMU') =20 - logger.info('stepping forward') + logger.info('Stepping forward') steps =3D [] - # record first instruction addresses + # Record first instruction addresses. for _ in range(self.STEPS): - pc =3D self.get_pc(g) - logger.info('saving position %x' % pc) + pc =3D self.get_pc() + logger.info('Saving position %x' % pc) steps.append(pc) - self.gdb_step(g) + self.gdb_step() =20 - # visit the recorded instruction in reverse order - logger.info('stepping backward') + # Visit the recorded instruction in reverse order. + logger.info('Stepping backward') for addr in steps[::-1]: - self.gdb_bstep(g) - self.check_pc(g, addr) - logger.info('found position %x' % addr) + self.gdb_bstep() + self.check_pc(addr) + logger.info('Found position %x' % addr) =20 - # visit the recorded instruction in forward order - logger.info('stepping forward') + # Visit the recorded instruction in forward order. + logger.info('Stepping forward') for addr in steps: - self.check_pc(g, addr) - self.gdb_step(g) - logger.info('found position %x' % addr) + self.check_pc(addr) + self.gdb_step() + logger.info('Found position %x' % addr) =20 - # set breakpoints for the instructions just stepped over - logger.info('setting breakpoints') + # Set breakpoints for the instructions just stepped over. + logger.info('Setting breakpoints') for addr in steps: # hardware breakpoint at addr with len=3D1 - g.cmd(b'Z1,%x,1' % addr, b'OK') + gdb.execute(f"break *{hex(addr)}") =20 - # this may hit a breakpoint if first instructions are executed - # again - logger.info('continuing execution') + # This may hit a breakpoint if first instructions are executed aga= in. + logger.info('Continuing execution') vm.qmp('replay-break', icount=3Dlast_icount - 1) - # continue - will return after pausing + # continue - will return after pausing. # This could stop at the end and get a T02 return, or by # re-executing one of the breakpoints and get a T05 return. - g.cmd(b'c') + gdb.execute("continue") if self.vm_get_icount(vm) =3D=3D last_icount - 1: - logger.info('reached the end (icount %s)' % (last_icount - 1)) + logger.info('Reached the end (icount %s)' % (last_icount - 1)) else: - logger.info('hit a breakpoint again at %x (icount %s)' % + logger.info('Hit a breakpoint again at %x (icount %s)' % (self.get_pc(g), self.vm_get_icount(vm))) =20 - logger.info('running reverse continue to reach %x' % steps[-1]) - # reverse continue - will return after stopping at the breakpoint - g.cmd(b'bc', b'T05thread:01;') + logger.info('Running reverse continue to reach %x' % steps[-1]) + # reverse continue - will return after stopping at the breakpoint. + gdb.execute("reverse-continue") + + # Assume that none of the first instructions is executed again + # breaking the order of the breakpoints. + # steps[-1] is the first saved $pc in reverse order. + self.check_pc(steps[-1]) + logger.info('Successfully reached %x' % steps[-1]) =20 - # assume that none of the first instructions is executed again - # breaking the order of the breakpoints - self.check_pc(g, steps[-1]) - logger.info('successfully reached %x' % steps[-1]) + logger.info('Exiting GDB and QEMU') =20 - logger.info('exiting gdb and qemu') vm.shutdown() + + self.assertTrue(True, "Test passed") diff --git a/tests/functional/test_aarch64_reverse_debug.py b/tests/functio= nal/test_aarch64_reverse_debug.py index 58d4532835..8b6f82c227 100755 --- a/tests/functional/test_aarch64_reverse_debug.py +++ b/tests/functional/test_aarch64_reverse_debug.py @@ -1,27 +1,26 @@ -#!/usr/bin/env python3 -# # SPDX-License-Identifier: GPL-2.0-or-later # -# Reverse debugging test +# Reverse debugging test for aarch64 # # Copyright (c) 2020 ISP RAS +# Copyright (c) 2025 Linaro Limited # # Author: # Pavel Dovgalyuk +# Gustavo Romero (Run without Avocado) # # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. =20 -from qemu_test import Asset, skipIfMissingImports, skipFlakyTest +# ReverseDebugging must be imported always first because of the check +# in it for not running this test without the GDB runner. from reverse_debugging import ReverseDebugging +from qemu_test import Asset, skipFlakyTest =20 =20 -@skipIfMissingImports('avocado.utils') class ReverseDebugging_AArch64(ReverseDebugging): =20 - REG_PC =3D 32 - - KERNEL_ASSET =3D Asset( + ASSET_KERNEL =3D Asset( ('https://archives.fedoraproject.org/pub/archive/fedora/linux/' 'releases/29/Everything/aarch64/os/images/pxeboot/vmlinuz'), '7e1430b81c26bdd0da025eeb8fbd77b5dc961da4364af26e771bd39f379cbbf7') @@ -30,9 +29,9 @@ class ReverseDebugging_AArch64(ReverseDebugging): def test_aarch64_virt(self): self.set_machine('virt') self.cpu =3D 'cortex-a53' - kernel_path =3D self.KERNEL_ASSET.fetch() + kernel_path =3D self.ASSET_KERNEL.fetch() self.reverse_debugging(args=3D('-kernel', kernel_path)) =20 =20 if __name__ =3D=3D '__main__': - ReverseDebugging.main() + ReverseDebugging_AArch64.main() diff --git a/tests/functional/test_ppc64_reverse_debug.py b/tests/functiona= l/test_ppc64_reverse_debug.py index 5931adef5a..e70ca85d0a 100755 --- a/tests/functional/test_ppc64_reverse_debug.py +++ b/tests/functional/test_ppc64_reverse_debug.py @@ -1,41 +1,38 @@ -#!/usr/bin/env python3 -# # SPDX-License-Identifier: GPL-2.0-or-later # -# Reverse debugging test +# Reverse debugging test for ppc64 # # Copyright (c) 2020 ISP RAS +# Copyright (c) 2025 Linaro Limited # # Author: # Pavel Dovgalyuk +# Gustavo Romero (Run without Avocado) # # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. =20 -from qemu_test import skipIfMissingImports, skipFlakyTest +# ReverseDebugging must be imported always first because of the check +# in it for not running this test without the GDB runner. from reverse_debugging import ReverseDebugging +from qemu_test import skipFlakyTest =20 =20 -@skipIfMissingImports('avocado.utils') class ReverseDebugging_ppc64(ReverseDebugging): =20 - REG_PC =3D 0x40 - @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/issues/1992") def test_ppc64_pseries(self): self.set_machine('pseries') # SLOF branches back to its entry point, which causes this test # to take the 'hit a breakpoint again' path. That's not a problem, # just slightly different than the other machines. - self.endian_is_le =3D False self.reverse_debugging() =20 @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/issues/1992") def test_ppc64_powernv(self): self.set_machine('powernv') - self.endian_is_le =3D False self.reverse_debugging() =20 =20 if __name__ =3D=3D '__main__': - ReverseDebugging.main() + ReverseDebugging_ppc64.main() diff --git a/tests/functional/test_x86_64_reverse_debug.py b/tests/function= al/test_x86_64_reverse_debug.py index d713e91e14..465f7e0abb 100755 --- a/tests/functional/test_x86_64_reverse_debug.py +++ b/tests/functional/test_x86_64_reverse_debug.py @@ -1,36 +1,31 @@ -#!/usr/bin/env python3 -# # SPDX-License-Identifier: GPL-2.0-or-later # -# Reverse debugging test +# Reverse debugging test for x86_64 # # Copyright (c) 2020 ISP RAS +# Copyright (c) 2025 Linaro Limited # # Author: # Pavel Dovgalyuk +# Gustavo Romero (Run without Avocado) # # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. =20 -from qemu_test import skipIfMissingImports, skipFlakyTest +# ReverseDebugging must be imported always first because of the check +# in it for not running this test without the GDB runner. from reverse_debugging import ReverseDebugging +from qemu_test import skipFlakyTest =20 =20 -@skipIfMissingImports('avocado.utils') class ReverseDebugging_X86_64(ReverseDebugging): =20 - REG_PC =3D 0x10 - REG_CS =3D 0x12 - def get_pc(self, g): - return self.get_reg_le(g, self.REG_PC) \ - + self.get_reg_le(g, self.REG_CS) * 0x10 - @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/issues/2922") def test_x86_64_pc(self): self.set_machine('pc') - # start with BIOS only + # Start with BIOS only self.reverse_debugging() =20 =20 if __name__ =3D=3D '__main__': - ReverseDebugging.main() + ReverseDebugging_X86_64.main() --=20 2.34.1