From nobody Sat Sep 6 14:41:53 2025 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=1757000956; cv=none; d=zohomail.com; s=zohoarc; b=JxdSk9WX1Yxtkwhpt1nUfJY1PQq4e6CNsBBDaZh8bUpEj2+NBJ8k5neDX2h/dKu72Y62Pvoj5udHFKvoTOAyc2HDFTXOFnhm0BuF2OcKszMLS3Ztvr9Rzw8lyqk74BwtyTNUoe5ALyYywP/f1WVlp2983uGTxTy7EEk6X8cx8yo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757000956; 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=w7W8AMCroqwaeXqVpYPQbxXgScT+t9hdJtgqiSQ+G30=; b=XQy/wW9Fw4s0+X+f9Pp0rDGY4Y4pO7cu+smxI+oYF8OuopFjpnVEttNC6/ewdRiVq0d95VIvri4gWZzIcKqJtTc5Gl9mpU7PocycSWFDn8Bw05ZW6eFn5pG2gGoPqFpIDSArIDmdy78ryjuA/AsEjsAYlIXLuyGWCuKwEigfPDY= 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 1757000956157944.3328426274787; Thu, 4 Sep 2025 08:49:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuCBd-0004so-FN; Thu, 04 Sep 2025 11:47:45 -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 1uuCBE-0004kU-P5 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:24 -0400 Received: from mail-vk1-xa2f.google.com ([2607:f8b0:4864:20::a2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uuCB6-0008Hl-Ao for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:20 -0400 Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-544a2339775so449060e0c.0 for ; Thu, 04 Sep 2025 08:47:08 -0700 (PDT) Received: from gromero0.. ([186.215.58.133]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-544a666da0csm6497022e0c.28.2025.09.04.08.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 08:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757000824; x=1757605624; 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=w7W8AMCroqwaeXqVpYPQbxXgScT+t9hdJtgqiSQ+G30=; b=u+jEFJ9k551FDTzvO4nrpQgSiZrnF2GzxRqdkkG0IvmgK8Y2IXzXGVgi243a2DfaNg onaBSr5aJtzaY9ogo0gqMYGZL6TtoetWvB4ABdrGZzwEcahgA2hRHuYn3sPJn2i3Ey7A GMobxBz2cKxavpxUlVnwxMSwS1vUR2Xbz7e9Z7JNR3WNSkHN5wfRZzpttIbFgZOTUVTG /q4LfwIsVRpM2N+jwkO/Ebhru4h9o5Hc9coGCxoOWACwfsqW0vsHvHr0sZ5XokA54Tdb GBQ31rNsr+oPXpVrpMNIOeJ7JYgqA5FoPd8htkzfujh6kgWYmQ2kP5wzPkLq9Qzask7V qJww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757000824; x=1757605624; 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=w7W8AMCroqwaeXqVpYPQbxXgScT+t9hdJtgqiSQ+G30=; b=IXUL0PSCt8UO0L11Qf5NWUW7MjbaEpXmhxRhy4s7QlQmdZUQ5+REuRujj88kjeTP3D lWyY9NHF5+u/CGCNCT98zFxm+V4EWePOCyIEIPGJpsHklmt/LE2ypfHzke9WLEF1er1a zFpXlrul1wyoWrplTj1wLoRP3xK4ZWSSNnujLD+XUBSEgZV6VJQP2R0xnyY6L4utbygK tW2Uw/iFFt9OiF2iCM1zvFjy52J6AQwUZvCU7l5Kw4BN9o6sQtTmJy3qvHCbkpBrA9Yt jxHuY9FNMpTfh1HgHOsv7WXU4QbE+iO5aAnOVpWKzF3cHpL1FJdoyBLeUmtIA9dg3Ouf RJjg== X-Gm-Message-State: AOJu0YzQfoNFaDXiYuRWJjF3aeOID4lAqE2LFXSJDJDK3UfYtbgNwCS8 +XZ31f2GMXAgH1uajxZiYLvMpzPDIZt/2Cx8ztIxAH1zMPmyvVFSrU6XNGnTtFLad0MWd2nWHJ7 HCRz+mTZDfw== X-Gm-Gg: ASbGncudTHq6mmymptTNArXWCAICuHJR/3J3x6PLqOPsj/eYwVG2pOprlAlkB3DPXoK AVR30l8L5ZAkfXWEE/XBzd+7N2OaWLWd1CuS6Qh7U1+UTW6sKl97qgJHDINScMs5hGWmG77Gd/0 vSNBfJLlOjkcZJNnzolRaX02JekWvwN10RDSpwcUp0w043Jghj8c+KkZqvdehK4+gnRTnqjK9iM UZ2O+u3VyfKuwUtbDnYIhZ8QYdJw+RAwVSv435VqUf80oZkf6ZPwUuKOYQHTeZW4CQu6tCPutn2 qEFevIkYNiBm1xBIjLAKSTRGcvCSdiJBIKjpucdt3YNOPsJyYbVYN5ylf/TzZYfRW2nkZT4eHpr Nd9PI7+e4gmAmXfYpkbF8h46aA1vC X-Google-Smtp-Source: AGHT+IF1INOgEwi5XuzYYf8xmg/ZUfMMO6YYhiWR+h5YxK7FFBUBbVtiSECAhjpN0ymfBkDR36+qwA== X-Received: by 2002:a05:6122:2022:b0:543:cd49:ce78 with SMTP id 71dfb90a1353d-544a02889edmr7340174e0c.14.1757000823807; Thu, 04 Sep 2025 08:47:03 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com, berrange@redhat.com Cc: qemu-arm@nongnu.org, 1844144@gmail.com, gustavo.romero@linaro.org Subject: [PATCH v2 1/5] tests/guest-debug: Make QEMU optional in run-test.py Date: Thu, 4 Sep 2025 15:46:36 +0000 Message-Id: <20250904154640.52687-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250904154640.52687-1-gustavo.romero@linaro.org> References: <20250904154640.52687-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::a2f; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa2f.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: 1757000957519124100 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. sys.argv passed via -ex now includes the full path to the test script in addition to the script=E2=80=99s arguments, which allows unittest introspec= tion to work properly in case it is used in the test script. The --binary option continues to be required when --qemu is passed. Signed-off-by: Gustavo Romero Reviewed-by: Alex Benn=C3=A9e --- tests/guest-debug/run-test.py | 60 +++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index 75e9c92e03..d21a5dda77 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -15,6 +15,7 @@ import subprocess import shutil import shlex +import sys import os from time import sleep from tempfile import TemporaryDirectory @@ -22,10 +23,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=3D'--qemu' in sys.argv) parser.add_argument("--test", help=3D"GDB test script") parser.add_argument('test_args', nargs=3D'*', help=3D"Additional args for GDB test script. " @@ -73,27 +74,30 @@ 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 '' + 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: - 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}' + 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}' =20 - log(output, "QEMU CMD: %s" % (cmd)) - inferior =3D subprocess.Popen(shlex.split(cmd)) + log(output, "QEMU CMD: %s" % (cmd)) + inferior =3D subprocess.Popen(shlex.split(cmd)) =20 # Now launch gdb with our test and collect the result - gdb_cmd =3D "%s %s" % (args.gdb, args.binary) + 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 @@ -103,11 +107,12 @@ def log(output, msg): # 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) + 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 +134,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 Sat Sep 6 14:41:53 2025 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=1757000971; cv=none; d=zohomail.com; s=zohoarc; b=TWC5YOEUCFdkRuHv+0g0t1cF6cvH2gS4NM6f/SSRiUCKVhWOif2V4b0DXehrsi3Ycf8D455u4ZdMW/TD8Ay3DT5oNg3FJhQ7evQXL+UC/esVFCUO19i8WLwj0HjM3JhKJ9Xv7j8PqUyonUs66CbmSUHisr1gqR3PQpU10Nheb8w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757000971; 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=hJUU2u1tzC1eXmbzNgouEyqDdukQnt6LnrP8qMtdLmo=; b=hgV63syGW4agrVKLzDm27HGSpHwHDIku32wJ+ldMWklzCs5ry6KWXgLHdL9iu3l6cSjxYornnMYkY+Ym3Q4g9FuW5w3H5aLduOAlDUkufHuCdIjm4CnFvhhHlt54FILQG4eB/0yn8TxMbo7z9x6gEtBekRow+NOaXNVJbIvrurg= 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 1757000971085998.6093086679065; Thu, 4 Sep 2025 08:49:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuCBX-0004pa-6Q; Thu, 04 Sep 2025 11:47:39 -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 1uuCBE-0004k9-Aj for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:22 -0400 Received: from mail-vk1-xa2b.google.com ([2607:f8b0:4864:20::a2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uuCB6-0008IP-B8 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:18 -0400 Received: by mail-vk1-xa2b.google.com with SMTP id 71dfb90a1353d-544af5b745cso788538e0c.0 for ; Thu, 04 Sep 2025 08:47:09 -0700 (PDT) Received: from gromero0.. ([186.215.58.133]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-544a666da0csm6497022e0c.28.2025.09.04.08.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 08:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757000827; x=1757605627; 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=hJUU2u1tzC1eXmbzNgouEyqDdukQnt6LnrP8qMtdLmo=; b=Dy1lhViLudkXBhvcAKfRz/usZITdTfbfODnoOoDSSBhZhoCS7JisgdrfW+T20py/2t 9ScTvgM+e6l2uP1g7RipTYwCWdLnOPyITgwwwP/QuPZYntxayMD8HHujHMebneFwfJIS kc3MWXSd4j73aj0SjBOw0RyiteluWcfKf7fj44ReSsAKgfjoTcDHF2/8qfpnFCmh0J/h P1LVm7O4+ar08Mo1IdxF7Izi/YrgISJ2OW9ojGosNLnbU3DBJGxWrypxOW3CQfm4vc09 0EmvRwee2ZWnuDgL5RJmhrQieETAfCBz+uI41I4K3mCuoYziiaHuQ2b/JyUxBbZYPbqR TssA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757000827; x=1757605627; 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=hJUU2u1tzC1eXmbzNgouEyqDdukQnt6LnrP8qMtdLmo=; b=fQ/J/Fz8NUFxIhEK7KbiM9gsq4qdLVb7qF+kG4uir/gqyhoU2d0SPx1iVWKniOnqto XIRbpFz9dzPmuS3LGcTAPVpCOTd7hzVJXErklK0fbAzeRyKky1iVrrQHpWRq/yovF6pg M2RJAuDPOFNN+/Rf2F6R4Ta6/MPyGAGPdxKkkj3M3ULsEQc7KUtvqvnvxhtTIj5RtFSj 64ilbjOl44TX5LWj0u8w1EajkKzN34d6XstZqFRO21EKzmaX+yqHEd2gYHp6h0+ey+Mn GbYdCbsR89K2D15kj2CQUy/K0Y0gKrX3jYg+QONNuejlyA4GSx9JP+MboLr2QpF9m0X9 vmvw== X-Gm-Message-State: AOJu0Yz32CQzsOVLImtE8EdK5zdxOnh8MvpNGJFwKyWcS6Qdg91EC+L1 yy7t58c9ooroi3FrCFpds/1A0qdX//iPKq04kx9X0laZem3tgzF5alFo8Tb1BGta0AZJUj3jkYA eKaClsO60Ig== X-Gm-Gg: ASbGncvtNdF+2/E+qUwQ15wnXD7btdnCTUKdhZba0aXetX8S0VTJyD+PQaKsXxMoBqd zu3WxRvn3RSQUBBQbeXIVI8W+2GoJNcIkCNmXx9A7VxTsMKa0W6zgYxWQKGVqzeL3anco9X84NR Pij7tb6MwaR6K9Q1CoN6EhS0j36IKOwWCIMXdcbkF3OBeSYHvNQ/BW6czzeL9oCTce4xNU8f4nn kb07vQ0Dp4OlVodVEfn0u3i8LEPvM5bHia8Ftmbppv22JQaRjAIenigffCwbu0DYmaDXIizYeHd GmKD5C125OynurOVfHfYN4j6IdhCQjh96aNW+Iwza8uDQPZh6uHI0qw3lgZIUta9oW9fw97iV2H 0c/SZD1PFUOPQhNR3VoxTEFSkQ5opVVi4xzsOLOQ= X-Google-Smtp-Source: AGHT+IESD09FhaRWqFv/jDR5+zmzGS0I7CeSClFxHhefAuOcy70hbViiiCCMNb2+oYX6IZDbKF01/g== X-Received: by 2002:a05:6122:3d08:b0:545:eca2:1c7e with SMTP id 71dfb90a1353d-545eca22169mr688729e0c.0.1757000826773; Thu, 04 Sep 2025 08:47:06 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com, berrange@redhat.com Cc: qemu-arm@nongnu.org, 1844144@gmail.com, gustavo.romero@linaro.org Subject: [PATCH v2 2/5] tests/guest-debug: Format comments Date: Thu, 4 Sep 2025 15:46:37 +0000 Message-Id: <20250904154640.52687-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250904154640.52687-1-gustavo.romero@linaro.org> References: <20250904154640.52687-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::a2b; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa2b.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, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: 1757000971874124100 Content-Type: text/plain; charset="utf-8" Capitalize and add periods to comments. Signed-off-by: Gustavo Romero Reviewed-by: Alex Benn=C3=A9e --- tests/guest-debug/run-test.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index d21a5dda77..e051e8947c 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -54,7 +54,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: @@ -94,22 +94,22 @@ def log(output, msg): log(output, "QEMU CMD: %s" % (cmd)) inferior =3D subprocess.Popen(shlex.split(cmd)) =20 - # Now launch gdb with our test and collect the result + # 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 + # 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 + # Finally the test script itself. if args.test: argv =3D [args.test] + args.test_args gdb_cmd +=3D f" -ex \"py sys.argv=3D{argv}\"" --=20 2.34.1 From nobody Sat Sep 6 14:41:53 2025 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=1757001004; cv=none; d=zohomail.com; s=zohoarc; b=V0b3x/j3c0pmanSePVKUh2GuIXsnsN2EGiDVhwZKb6Ry75PdeAKj60xeth52gvtyGTWw9Pq93JG0y0uL7Rw/uTHPpY3m6vdZIFDCMdVHfNENMh5Zhh+LamI4HI702QUquwgkQE1nP7bf4dKCI7Zk8mw2a/PDuLccqNqsstLHHw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757001004; 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=vYDFXmXqCAGa3H4P42CKPPrpxXB7rIYCvJObU3+Iajg=; b=JilKbpDwFiCMJ/nQWbwwSq4g2M7RM2aQOYVOtKR0bBTBCMfBa1l+lR2ZOPCOzTWZKprLUxpDpRiT3OGbPg/yaNI/qEfKSpKVq6EcjnzPXYQHs1MTFFxPcO/0KVhM0sIBibrEUHdVKNKKZYdlAWZjlKihPenWC5lNjsuyBefXQZs= 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 1757001004771799.5095538968038; Thu, 4 Sep 2025 08:50:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuCBm-00050c-Q9; Thu, 04 Sep 2025 11:47: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 1uuCBQ-0004nO-CZ for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:35 -0400 Received: from mail-vk1-xa2b.google.com ([2607:f8b0:4864:20::a2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uuCBF-0008QZ-Gn for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:31 -0400 Received: by mail-vk1-xa2b.google.com with SMTP id 71dfb90a1353d-544a55b84d8so461445e0c.2 for ; Thu, 04 Sep 2025 08:47:12 -0700 (PDT) Received: from gromero0.. ([186.215.58.133]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-544a666da0csm6497022e0c.28.2025.09.04.08.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 08:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757000831; x=1757605631; 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=vYDFXmXqCAGa3H4P42CKPPrpxXB7rIYCvJObU3+Iajg=; b=r18vM5WKsi7cX9Tw91VlYUKwN37l5yqMGA9eAJQawp0yIPFoMwKY+ndzx2RBgpOY4N IRJcZDlamXiR+wo2RhE5BKFKLWUl9u55jRaXh6ZHoNEUKCw5Tjni1FCPMAJRv5UzoFHs WzsxmBywhHYPgSZtgqhvDTvgtTUK2COc6KmpvUlLtQpq6eNtIM+H9bAnIj6xfsKZAkV9 UB9OROYp1nO1jcGIX0rJ/awMayYndxGzvg0me4qsZaSsdOV+7XyTcUWEfY6olt5VRLcu Ag7tVhxq8hQ/MoAGQ0Rap5IzFCh6LLBS9TOYZBQURFcQXEh37pA/6YOEB6H7Qm2oY0fk sdWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757000831; x=1757605631; 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=vYDFXmXqCAGa3H4P42CKPPrpxXB7rIYCvJObU3+Iajg=; b=YKkryFdKRN+13CGdLldEKobT7TOQrqqJlTWafE46CgOjLuRkd2XMRq3ELgfMp493sn ia19USripvNxQgcGspoILsYQ1rICKsVnxqtFKq62PUhithefeWmNHAZuFYgbVf4JCKd4 37A2FjSZ+a221KcbWq4hMD1SLB8RdQlZUBhrjukQC7u+nhVNyoC6NUWoHuMv0HAosdof KHEBL3ewU1NTY3pNDi1rKcGT8F/zc78C3c90nNbmq8Q8oaeJCPd4QSHoZQhxDbfckLeH dSFbgqOCizJi31tSpTznvUzQ3TkOdq44sa4Nmu/uv9dsHHrGO1aVvOTLATROROY85BjD WMHg== X-Gm-Message-State: AOJu0YwLxpHF/j1OSFceJFf1Ly9q9t4068gEEt8H+09TDaE7y3RIuQMi 9ezYR5foJOLqtHPYlOTJPmu5fDztt8zgMQmnPP/UzWbFLaCwXnNyaMOLHURAU3+68zkIuuX5hB/ VmUKwkO3AJg== X-Gm-Gg: ASbGncv0lYuF3Qoqd23s6OL+wE2wiEkgt5je4biE8v5anbB+im8dB6Pl0AkP5wAEt5/ Kc7SdYiPFotmZEwfub4EpWl8msk1q7Aydv49T3Q8IMS6Z1x2gNB933ssmA1FYt1y/D/k7aFWjRl eMJdWrVJQ3u6aPQlTuUyLbMV1gN/wUDRsMuPzBGLPhwGIZxPj4KXnmnYWvfenNNbiFKJuSYdS7X t1T6fQLwb2ViHv1Qk9rAaOcIpdpRbAK7UA/n3JZQJc9brDpEzBENMJhOR9iQp77Bub52Tf4u+Na FRuzJKcrNUai7wlmk0mcBSJZIlWbYdb0jYtYBX5GL6I9pY7ibMBb6kHpGc0sh8rZaGgx6CJyMnB SZxIYyiURR0nyglTuAaYz6FHtFV0x7oNH8DtK8LA= X-Google-Smtp-Source: AGHT+IEfdF/8MTudAgTz1GKf4FI7P0iY9BfPuKxefZGnKr/uKjEuglZ8oN5EPxrYTIZ4IfY4cxLhSw== X-Received: by 2002:a05:6122:1d8f:b0:531:2afc:4628 with SMTP id 71dfb90a1353d-544a0190d7amr6131606e0c.2.1757000829781; Thu, 04 Sep 2025 08:47:09 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com, berrange@redhat.com Cc: qemu-arm@nongnu.org, 1844144@gmail.com, gustavo.romero@linaro.org Subject: [PATCH v2 3/5] tests/guest-debug: Add quiet option to run-tests.py Date: Thu, 4 Sep 2025 15:46:38 +0000 Message-Id: <20250904154640.52687-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250904154640.52687-1-gustavo.romero@linaro.org> References: <20250904154640.52687-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::a2b; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa2b.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, T_SPF_TEMPERROR=0.01 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: 1757001005570116600 Content-Type: text/plain; charset="utf-8" Add a --quiet option to run-tests.py so it can run without printing any messages to the stdout. Signed-off-by: Gustavo Romero Reviewed-by: Alex Benn=C3=A9e --- tests/guest-debug/run-test.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index e051e8947c..cf8b37b8b8 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -39,15 +39,17 @@ def get_args(): parser.add_argument("--stderr", help=3D"A file to redirect stderr to") parser.add_argument("--no-suspend", action=3D"store_true", help=3D"Ask the binary to not wait for GDB connect= ion") + parser.add_argument("--quiet", action=3D"store_true", default=3DFalse, + help=3D"Don't print any messages to stdout") =20 return parser.parse_args() =20 =20 -def log(output, msg): +def log(output, msg, quiet): if output: output.write(msg + "\n") output.flush() - else: + elif not quiet: print(msg) =20 =20 @@ -91,7 +93,7 @@ def log(output, msg): cmd =3D f'{args.qemu} {args.qargs} -g {socket_name}{suspend}' \ f' {args.binary}' =20 - log(output, "QEMU CMD: %s" % (cmd)) + log(output, "QEMU CMD: %s" % (cmd), args.quiet) inferior =3D subprocess.Popen(shlex.split(cmd)) =20 # Now launch gdb with our test and collect the result. @@ -117,7 +119,7 @@ def log(output, msg): =20 =20 sleep(1) - log(output, "GDB CMD: %s" % (gdb_cmd)) + log(output, "GDB CMD: %s" % (gdb_cmd), args.quiet) =20 gdb_env =3D dict(os.environ) gdb_pythonpath =3D gdb_env.get("PYTHONPATH", "").split(os.pathsep) --=20 2.34.1 From nobody Sat Sep 6 14:41:53 2025 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=1757001003; cv=none; d=zohomail.com; s=zohoarc; b=TSU/CrbYAu1IiNcEJH5OcgFW5/ZsskCm6uo9nztaUPqbV3bc4PvC7AabRS7o3nYr9LeCid/1DEQ+6m8jHePj4k58PXbywGaje3WhLowwGo0xcYu2tk9eV6z1eOnVzEffZuVC82ZUxk9iz3j97PE0IVPrhq4b6bTjqzFTr7gzaNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757001003; 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=Ly0Uw2HSTv1mCwT12MXqsgrBCGp5zOffCN0UNp08lAs=; b=OfZggZYiQRpHlny9GgxvORu62qroWABIQ2Pmvhuldsnqa/9jqPYDXg884y/YeUSUk+AP1D4x8aj+1tK4MErOfqG3qPnMZ5CWHwImQB4dAp6BHAkBNy1feIosDEMuWRyu5SHoPajtfW+O0jv0Zzr48laH04rS5VzelFzEgbTfrwU= 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 1757001003144765.6551297853142; Thu, 4 Sep 2025 08:50:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuCBq-00050w-Kf; Thu, 04 Sep 2025 11:47:59 -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 1uuCBM-0004mN-8G for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:30 -0400 Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uuCBA-0008Qy-I9 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:25 -0400 Received: by mail-vk1-xa2a.google.com with SMTP id 71dfb90a1353d-545e265e2d0so1010431e0c.1 for ; Thu, 04 Sep 2025 08:47:14 -0700 (PDT) Received: from gromero0.. ([186.215.58.133]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-544a666da0csm6497022e0c.28.2025.09.04.08.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 08:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757000833; x=1757605633; 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=Ly0Uw2HSTv1mCwT12MXqsgrBCGp5zOffCN0UNp08lAs=; b=doUvwRRFbiP/9f6zGeOpZkfxYnDqumJGx/fRxmbXe1QB8jWyecURAmFy/hVlleZJdU 0nQXwRs2yolSp8JFnV631nP6HsSIMNAATXqPnlG0kS3XGFPERKDWpmqwpfqbW3EVB382 ju3MSxDXmk3Pdi37WhQiyqrdNjRFa38eQzEBTopXpkElUPodf5M0lnabQV13+Q9tef4C fg7d93u/sYKSCAAY7xmdPH+w7ZH6J9NBHlqNN7qDluSY8HUXxyG44Dw8v+3UMiKbVP/G ITJN2AfKqSUV6gE+mQkK7tRTRi5VxrBekVt9hCxnlDKruU11L6OFBOItGVRS79XaGbuP zjBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757000833; x=1757605633; 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=Ly0Uw2HSTv1mCwT12MXqsgrBCGp5zOffCN0UNp08lAs=; b=sFSpKEbM60L4vrLmP63tuTrqHjXHonBRkYG1/IZzXvOJMgZeA73vbmOy3WSReCfh21 cXYWLgiA2fSaWFWnbMJXZigkUK5Sq//PZcAj6MP85lHgtqpwx8JWKBVs37ytn+u7Jb66 hlKe725w221kHB1IbTrMAsDKBFdRf9hkiPBPNnAwtwde5m8uhfFRNdUbov2AV9ru9m0h J+LclDrRQwOiSasCS/uCTiBZxhnk9LP6j1GI4WRrRvAtjRSGXx/W/kAMlP7yGOm9bKWs AhH4KTUSwSJYBmTnafb0WHESPYF40v2b/A9uoMmf8p8+s+cHfBL9kBWh+XZtake06zIv VpOw== X-Gm-Message-State: AOJu0YzZj8FUZf9WVFRWR72D+fRNOYwQzf0mCSOFCISDuZExoPI6foLJ sOvqIV6e1oOGfOuejM+8yIZGyyV2ZibTpYEBxkv5RNVyb7wOsBClYtQNCaNbiG7/ctB2MJMD78K FWTzfmtKHPQ== X-Gm-Gg: ASbGncvXp5Sa4fjamdEztOUHfFKedsjxQQX69Bia36vCBwR1Sj6pg+Qs3NxApKTqytB 3zYqrKM2x7maOyO+PfHl2xjMMlfmZGsxORG4AUKpbGuulVTceUtI/tLZ7rxMT4ju/JCj69L2MtH eIPpi/GACiPDiN/gmaCOz8iVn0MTuD+C/6ECIPry32jxRkK1v/N88r+ntov13ocjWHoKLrV7o93 uXE0Zbu4bXYCL0skzUOZ6NmaaSOY6Xq01CF03S4o+Hai4fDe3nfPHYam+4V9datSc4ekKcOAen7 LIiOYM3WSJCnZTrF8NM3rYKTWbfYmApoPtXSPz0P2V3Px3UOe/N3Cj+rkdJIevd7Yp3ZM6hExj7 Siw1md7Mx0sMkb+ke5ug97/85qKA5 X-Google-Smtp-Source: AGHT+IHFjcODdw0kEcwKl4L5wi+0ipardMLyHLfTEl29Z2W0X38mLEXrv+P1oEoTZZCCFwtg/vsT2Q== X-Received: by 2002:a05:6122:2022:b0:544:9414:105d with SMTP id 71dfb90a1353d-5449ff8d510mr7461027e0c.0.1757000832746; Thu, 04 Sep 2025 08:47:12 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com, berrange@redhat.com Cc: qemu-arm@nongnu.org, 1844144@gmail.com, gustavo.romero@linaro.org Subject: [PATCH v2 4/5] tests/functional: Support tests that require a runner Date: Thu, 4 Sep 2025 15:46:39 +0000 Message-Id: <20250904154640.52687-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250904154640.52687-1-gustavo.romero@linaro.org> References: <20250904154640.52687-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::a2a; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa2a.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: 1757001005784116600 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. The GDB runner is only defined if GDB is detected. The probe is done in 'configure' and the full path is passed to meson.build via the -Dgdb=3D option. Signed-off-by: Gustavo Romero --- configure | 2 ++ meson.build | 4 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 2 ++ tests/functional/meson.build | 65 +++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+) diff --git a/configure b/configure index 274a778764..8e2e2cd562 100755 --- a/configure +++ b/configure @@ -1978,6 +1978,8 @@ if test "$skip_meson" =3D no; then test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engin= e=3D$LIB_FUZZING_ENGINE" test "$plugins" =3D yes && meson_option_add "-Dplugins=3Dtrue" test "$tcg" !=3D enabled && meson_option_add "-Dtcg=3D$tcg" + test -n "$gdb_bin" && meson_option_add "-Dgdb=3D$gdb_bin" + run_meson() { NINJA=3D$ninja $meson setup "$@" "$PWD" "$source_path" } diff --git a/meson.build b/meson.build index 0d42de61ae..7e0afe8288 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/meson_options.txt b/meson_options.txt index fff1521e58..5bb41bcbc4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -36,6 +36,8 @@ option('trace_file', type: 'string', value: 'trace', option('coroutine_backend', type: 'combo', choices: ['ucontext', 'sigaltstack', 'windows', 'wasm', 'auto'], value: 'auto', description: 'coroutine backend to use') +option('gdb', type: 'string', value: '', + description: 'Path to GDB') =20 # Everything else can be set via --enable/--disable-* option # on the configure script command line. After adding an option diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 0ebe6bc52a..f4bd21220e 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -58,6 +58,7 @@ meson_options_help() { printf "%s\n" ' --enable-ubsan enable undefined behaviour san= itizer' printf "%s\n" ' --firmwarepath=3DVALUES search PATH for firmware fil= es [share/qemu-' printf "%s\n" ' firmware]' + printf "%s\n" ' --gdb=3DVALUE Path to GDB' printf "%s\n" ' --iasl=3DVALUE Path to ACPI disassembler' printf "%s\n" ' --includedir=3DVALUE Header file directory [inclu= de]' printf "%s\n" ' --interp-prefix=3DVALUE where to find shared librari= es etc., use %M for' @@ -323,6 +324,7 @@ _meson_option_parse() { --disable-fuzzing) printf "%s" -Dfuzzing=3Dfalse ;; --enable-gcrypt) printf "%s" -Dgcrypt=3Denabled ;; --disable-gcrypt) printf "%s" -Dgcrypt=3Ddisabled ;; + --gdb=3D*) quote_sh "-Dgdb=3D$2" ;; --enable-gettext) printf "%s" -Dgettext=3Denabled ;; --disable-gettext) printf "%s" -Dgettext=3Ddisabled ;; --enable-gio) printf "%s" -Dgio=3Denabled ;; diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 2a0c5aa141..febd31a263 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -9,6 +9,25 @@ if get_option('tcg_interpreter') subdir_done() endif =20 +# Define the GDB runner if GDB is available. +gdb =3D get_option('gdb') +if gdb !=3D '' + gdb_runner_script =3D meson.project_source_root() + '/tests/guest-deb= ug/run-test.py' + gdb_runner =3D [gdb_runner_script, '--quiet', '--gdb', gdb, '--test'] + + message('GDB runner defined based on GDB found at: ', gdb) + + # 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 not found, skipping functional tests that rely on it.') +endif + subdir('aarch64') subdir('alpha') subdir('arm') @@ -61,9 +80,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] @@ -121,6 +142,50 @@ foreach speed : ['quick', 'thorough'] priority: time_out, 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 target_base / 'test_' + test[0] + '.py' + testpath =3D meson.current_source_dir() / testfile + teststamp =3D testname + '.tstamp' + testrunner =3D test[1] + testproto =3D test[2] + + # 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_r_precache_env =3D test_precache_env + test_r_precache_env.append('PYTHONPATH', python_site_packages) + # For similar reasons, PYTHONPATH must also include the path to the = test + # scripts, otherwise unittest's introspection will failed. + test_r_precache_env.append('PYTHONPATH', meson.current_source_dir() = / target_base) + + precache =3D custom_target('func-precache-' + testname, + output: teststamp, + command: [testrunner, testpath], + depend_files: files(testpath), + build_by_default: false, + env: test_r_precache_env) + precache_all +=3D precache + + # See comments above about PYTHONPATH in test_r_precache_env. + test_r_env =3D test_env + test_r_env.append('PYTHONPATH', python_site_packages) + test_r_env.append('PYTHONPATH', meson.current_source_dir() / target_= base) + + test('func-' + testname, + python, + depends: [test_deps, test_emulator, emulator_modules, plugin_mo= dules], + env: test_r_env, + args: [testrunner, testpath], + protocol: testproto, + timeout: time_out, + priority: time_out, + suite: suites) + endforeach endforeach endforeach =20 --=20 2.34.1 From nobody Sat Sep 6 14:41:53 2025 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=1757000927; cv=none; d=zohomail.com; s=zohoarc; b=R00nFlnMjI7vk6R5fHCEhGqk+aR10sVOVhkuXzwaVGy5j76LjwBHIl8VrcvdcVjM//fWc+rWuR3HdbSPFRpk3GjZix31JIkxbZ5XGNpJ6tzlqdM4C0fHfSWi5NZbpH+Zv1B67fmXeq6DYDkdgjemoBE0gZiNe6EW/X8nBVgYhTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757000927; 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=JzPi6AAJjNLSF/pZx0QvPsk9TOqjtDlLVQ/0eg1jp74=; b=NcJU8jdplq9KpHmqs8TLVnc7zJ61+LYASj8x0g8kZJcpxSM22Jiy/M4MknrxyMAq1hKXRAYjX4E/092eRNKKl8KsBPlDddtDnhgx2kTHwHBB5r+3Yjvhi+pruWira7QUgQaBERced+y4fqZKM9GK4MEkN3VaHdWAf49Y2BV//fs= 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 1757000927262511.71627082940347; Thu, 4 Sep 2025 08:48:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuCBf-0004uW-Us; Thu, 04 Sep 2025 11:47:48 -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 1uuCBO-0004my-Ai for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:35 -0400 Received: from mail-vk1-xa2e.google.com ([2607:f8b0:4864:20::a2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uuCBF-0000B9-G7 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 11:47:30 -0400 Received: by mail-vk1-xa2e.google.com with SMTP id 71dfb90a1353d-544b17b85d0so497544e0c.0 for ; Thu, 04 Sep 2025 08:47:18 -0700 (PDT) Received: from gromero0.. ([186.215.58.133]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-544a666da0csm6497022e0c.28.2025.09.04.08.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 08:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757000836; x=1757605636; 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=JzPi6AAJjNLSF/pZx0QvPsk9TOqjtDlLVQ/0eg1jp74=; b=ibYgSAGiYPW9pqMK1YnlOjoNFhLARbnX59sGH4HnrMkJ+p4PN7F5tQOjWVi7gU9jQT 2hlUGhNCUgOsnRoM/cVVxNbVC8uPxrR2fCWJCTAHG1dlex3fv3UETR4eno1rFZ16t7gk 5WFuLbscR2J6eCCv8JYPEZtLtOz1D3uH3bc73rXBo13ZB6h1azmUeM9qjC7QBnbWksws QkLmm31v60C24QVGedpnjEf7jjS+VQCjG43dQXi3t5hjVhd/ioJU6fepj4WcqBx6POol 5DoP7q2XguSb1heL0bgfGMx8Wzm72MGf7+zG0SqpAo0vIDCrm3HZrmAFofxMzwn7YK64 JsHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757000836; x=1757605636; 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=JzPi6AAJjNLSF/pZx0QvPsk9TOqjtDlLVQ/0eg1jp74=; b=Q/T9Igo/bFpgxirAhFPaqVgA4fWkCandoHY00qwzmHM+Z7SGLDPQZJaJD+b2asnHwM 5hsVQvQ0+9xrqCDVu+jpydrD4v/CELZQT4x4waIs/9VwzhzXie/FngwiOWkdQ0X8kX6c cAZ0wqPAglaSccDrzOH9JsUNfNR3dos80d+AlzsM/VfK82CygE/kobtelcYUUMu6Pohz s70HQCNZlFHbrH+USTEFm76XmHRtUQL101VLTRpCZbf5qFE/4jj9dkRVmoMCzBUQTo9E gjx4KZURueBRBOwghvbBfsFHebb1WoHQ4Pocbta2GwfIatIlJPKEGfTe4NQ6NsMmdqbC h74A== X-Gm-Message-State: AOJu0YyRQykjEnJB4haWZ3zDGe/SZQgtkv8Zzq65XmfbZFnIB0uGlM4h t29gHh85uiz6MU0Zd+VwIkkuO2Zm7Ly//K4DCMOpFODSXovaC/I3yeSUiABCRI4aoou0VcJDJSl aKqdlO2QZOw== X-Gm-Gg: ASbGnctY5qOCVWabNdXzyPexEiJsbBbS7GuOgm7PsrsadF1ikSiqpL2CBvK635A3kCK lYDmhRcUgoLQ99Wy48DiW2Wsm8zO5fvs4+PBm7FL46E/8EBsLP+Ulei9VUAkaLUgmnofFalUbaG JwoWv2a//Ea1dIdt4BfKJwpFe/wJDahw39ZrxFFpQvCqYnj7/ojAIJ/GXnfp0hgiEfDEZjbfhNi CstsQPnN1odPswrJMQfamlrOI648ESee2gPw3Ifpe8y5+dGfHfUzfK8hC2BlHTw84gv/XY6RlMs IZ60jTUWjxGOqVjHRs2F/6/cLOjBPTtCRFNMQ4RMKRgNf6P7Wc7pC7rOWFk63BOIJdkhWr1brni g6PpvZS1p2iyInqWF7jeOgP91oM6g X-Google-Smtp-Source: AGHT+IFDh1roZkToHC0TsV+nW+ooeZiJGwJkGjVByot9FbfjcQYyYBvQEHYyGKq5XnN6Pv/l7jfC0g== X-Received: by 2002:a05:6122:45a8:b0:545:ef3e:2f94 with SMTP id 71dfb90a1353d-545ef3e36d1mr364183e0c.1.1757000835703; Thu, 04 Sep 2025 08:47:15 -0700 (PDT) From: Gustavo Romero To: qemu-devel@nongnu.org, alex.bennee@linaro.org, thuth@redhat.com, berrange@redhat.com Cc: qemu-arm@nongnu.org, 1844144@gmail.com, gustavo.romero@linaro.org Subject: [PATCH v2 5/5] tests/functional: Adapt reverse_debugging to run w/o Avocado Date: Thu, 4 Sep 2025 15:46:40 +0000 Message-Id: <20250904154640.52687-6-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250904154640.52687-1-gustavo.romero@linaro.org> References: <20250904154640.52687-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::a2e; envelope-from=gustavo.romero@linaro.org; helo=mail-vk1-xa2e.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: 1757000929198116600 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 Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e --- tests/functional/aarch64/meson.build | 7 +- .../functional/aarch64/test_reverse_debug.py | 15 +- tests/functional/ppc64/meson.build | 7 +- tests/functional/ppc64/test_reverse_debug.py | 17 +- tests/functional/reverse_debugging.py | 175 +++++++++--------- tests/functional/x86_64/meson.build | 7 +- tests/functional/x86_64/test_reverse_debug.py | 21 +-- 7 files changed, 131 insertions(+), 118 deletions(-) diff --git a/tests/functional/aarch64/meson.build b/tests/functional/aarch6= 4/meson.build index 04846c6eb1..4f3168dd55 100644 --- a/tests/functional/aarch64/meson.build +++ b/tests/functional/aarch64/meson.build @@ -32,7 +32,6 @@ tests_aarch64_system_thorough =3D [ 'raspi3', 'raspi4', 'replay', - 'reverse_debug', 'rme_virt', 'rme_sbsaref', 'sbsaref', @@ -46,3 +45,9 @@ tests_aarch64_system_thorough =3D [ 'xen', 'xlnx_versal', ] + +if is_variable('gdb_runner') +tests_aarch64_system_thorough_with_runner =3D [ + ['reverse_debug', gdb_runner, 'exitcode'], +] +endif diff --git a/tests/functional/aarch64/test_reverse_debug.py b/tests/functio= nal/aarch64/test_reverse_debug.py index 8bc91ccfde..8b6f82c227 100755 --- a/tests/functional/aarch64/test_reverse_debug.py +++ b/tests/functional/aarch64/test_reverse_debug.py @@ -1,26 +1,25 @@ -#!/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 - ASSET_KERNEL =3D Asset( ('https://archives.fedoraproject.org/pub/archive/fedora/linux/' 'releases/29/Everything/aarch64/os/images/pxeboot/vmlinuz'), @@ -35,4 +34,4 @@ def test_aarch64_virt(self): =20 =20 if __name__ =3D=3D '__main__': - ReverseDebugging.main() + ReverseDebugging_AArch64.main() diff --git a/tests/functional/ppc64/meson.build b/tests/functional/ppc64/me= son.build index 842fe0fc71..e81f8b0003 100644 --- a/tests/functional/ppc64/meson.build +++ b/tests/functional/ppc64/meson.build @@ -20,6 +20,11 @@ tests_ppc64_system_thorough =3D [ 'powernv', 'pseries', 'replay', - 'reverse_debug', 'tuxrun', ] + +if is_variable('gdb_runner') +tests_ppc64_system_thorough_with_runner =3D [ + ['reverse_debug', gdb_runner, 'exitcode'], +] +endif diff --git a/tests/functional/ppc64/test_reverse_debug.py b/tests/functiona= l/ppc64/test_reverse_debug.py index 5931adef5a..e70ca85d0a 100755 --- a/tests/functional/ppc64/test_reverse_debug.py +++ b/tests/functional/ppc64/test_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/reverse_debugging.py b/tests/functional/rever= se_debugging.py index f9a1d395f1..bb0b176579 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,48 @@ 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): + logger =3D logging.getLogger('reply') + pc =3D self.get_pc() if pc !=3D addr: - self.fail('Invalid PC (read %x instead of %x)' % (pc, addr)) + logger.info('Invalid PC (read %x instead of %x)' % (pc, addr)) + gdb.execute("exit 1") =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 +107,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 +120,84 @@ 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") =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]) + # 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 - logger.info('exiting gdb and qemu') + logger.info('Exiting GDB and QEMU...') + # Disconnect from the VM. + gdb.execute("disconnect") + # Guarantee VM is shutdown. vm.shutdown() + # Gently exit from GDB. + gdb.execute("exit 0") + + def main(): + try: + LinuxKernelTest.main() + except SystemExit: + # If the test is marked with @skipFlakyTest, then it will be e= xited + # via sys.exit() before we have the chance to exit from GDB ge= ntly. + # Because recent versions of GDB will return a failure value i= f this + # happens, we catch the SystemExit and exit from GDB gently wi= th 77, + # which meson interprets correctly as a skipped test. + gdb.execute("exit 77") diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/= meson.build index d0b4667bb8..b5e0c9a0d7 100644 --- a/tests/functional/x86_64/meson.build +++ b/tests/functional/x86_64/meson.build @@ -29,8 +29,13 @@ tests_x86_64_system_thorough =3D [ 'multiprocess', 'netdev_ethtool', 'replay', - 'reverse_debug', 'tuxrun', 'virtio_balloon', 'virtio_gpu', ] + +if is_variable('gdb_runner') + tests_x86_64_system_thorough_with_runner =3D [ + ['reverse_debug', gdb_runner, 'exitcode'], + ] +endif diff --git a/tests/functional/x86_64/test_reverse_debug.py b/tests/function= al/x86_64/test_reverse_debug.py index d713e91e14..465f7e0abb 100755 --- a/tests/functional/x86_64/test_reverse_debug.py +++ b/tests/functional/x86_64/test_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