From patchwork Wed Sep 11 06:46:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 827358 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp657303wrc; Tue, 10 Sep 2024 23:48:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVEP0pMO7rruYvT+H388AZi4LYTwJ38hVaFgvJXYn0XWKv9YA0NvBkrBtWXgvr/ke9cGRG9wQ==@linaro.org X-Google-Smtp-Source: AGHT+IH3nsCsL91NwFBr2DCJA42BxBQJe1a++F1ppSO38i37UjoxV1XTJGglrcMFGJbWegCfcPpM X-Received: by 2002:ac8:5f8b:0:b0:44f:f118:d875 with SMTP id d75a77b69052e-4584e92536bmr32024611cf.36.1726037297209; Tue, 10 Sep 2024 23:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726037297; cv=none; d=google.com; s=arc-20240605; b=JytGrN4RIOQT1QXeva3uvjvpMDEKlZv7MMsxDklB/YOMEX2q/B6DU1/2+qjWKkqdnU jL+/iWLMwp+wWk5N3cYCuUqjLsXOT/vG0ybaLLixual1+CcPHvlTPR8N5PgVCizCEqV1 36XSGL9vQcou5FUr+naXI7rKUx88lxyRu4aTz+5OHUxLl0b7lbAkEVGqs188rJ/cClwY F+i0V+5fSeCwI17q/QpbqZ92Lr8wGoNC7PewGj3fdoJrGQRn6z3gzgYIvn+HWm3EeyCm sQMSl364YtGccC+YQnty5sBM9gTag6m2ciaJtaMmr9DHNgJSnGLm8HwciA+flw+NnikQ dqkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gzjhDYaJi6Bnx+rLU77Ms8m0/GdXNL2aorzkrS+8+qs=; fh=oS3g6+xHBBmjHOUc1b0A8TeelnMjnJltA+GbZRI/YAM=; b=DFKsQGiZs7ETgNNoPIXuycsoboz2QqEgveaqlSTZLpG0xVyYW9DvrBVtTpGIc1Cieq BM88UNRw/5I1/LmIKe8Vk5PLfAwKFW3jdzCZW4QHCMlx0cv2LTcjT8hMstZmGmn1r9HO 2OMMpsqNL5c4e7wuUEDS4+XtDf+lbz7HnDViW0fE/yW+RTTgnjJRmfR/tv9TzMmS3Fvn pLpgHTiA4TuJzFXbLN/qeSyvzjbtu3inT9oV5QmkNxBaSmBomnnFKrzY3NSTi5ZgOWrf 7bKHyM/3voTUMcPF9/DiJkX6oNnUT7blxwOzVVuiqp6AKSjcrkQbFAHjRfyKSKaOqynQ aTxw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ggWc88S4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45822f8116esi94574121cf.491.2024.09.10.23.48.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Sep 2024 23:48:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ggWc88S4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soH80-0000rf-KA; Wed, 11 Sep 2024 02:47:00 -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 1soH7x-0000fq-NA for qemu-devel@nongnu.org; Wed, 11 Sep 2024 02:46:57 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1soH7t-0004Pq-Cu for qemu-devel@nongnu.org; Wed, 11 Sep 2024 02:46:56 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5c275491c61so7935239a12.0 for ; Tue, 10 Sep 2024 23:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726037212; x=1726642012; 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=gzjhDYaJi6Bnx+rLU77Ms8m0/GdXNL2aorzkrS+8+qs=; b=ggWc88S4TLgPMssw31kRcBbi7/yzQvlSEEVGHMv+qL9TB8jyxDwbVQtmQUPwExvjwi h/Zhcyd2fJnSftkEpH6aFUdlCRofcLP311RsvA/cSK/VQjBCfIDLpBch4FY+xPTc0T15 zXDlK5affWYyEr6n0F3s5WIdo5IrhZJxbVj1BT/40dOPITrmnFBt21ceCGixzzG2Shld AGeg0XM3kbu6tngNl0TRFoA62mFPqCxR9y6TfXIVudAeKM09etAMiS0NN+Y5FfgZqRaQ uDhF6q2lkZ7yq3Y1jNe1fgGp2Sj2lyvvahqhdsuYZcpUIg9xgBpCPa+8oj+stiuhujMi IiRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726037212; x=1726642012; 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=gzjhDYaJi6Bnx+rLU77Ms8m0/GdXNL2aorzkrS+8+qs=; b=Jhk1EpiqF3KJUfDqZDUiNQSEX1lCexL4ohHdFT5tuujWFgxNEunW3NesOijWJlgYNz 5lnE+/evm13CHlK+fpe3EjSX1YRdRDaBuN8D7TDJ8yuLCy8OyCQUTOBd/cuJ1ExWE6Xx kqa0g4LNklsOq+l13MBpeWZJqAzluI6xj78aeINTayJIqptZQE8AOzsNZiiDq80ynIjp V0Ohmk0XGVDNbLy0F4rAGdavFGG/psMR40Ig+eFzwPktq/3GKdyB/aLzWI3dwsUS0FWx 3HfHk3xpBDisVtYYMe2X20WxBt/+9mGfSGBRs24IM6VTe46FQ6SjJavppVHrTifqXgSo UUSA== X-Gm-Message-State: AOJu0Yx1ZRqER7bi0nHRTMqGyvSvv0L9C92UlfvfKIf1g+s6btPvVLYw GzJjwldYE9i0tYHp9DAb55Xhq1LF8XQaP5P9l4KU3ijTPp2jQJOG/fnLUumkIlA= X-Received: by 2002:a05:6402:4312:b0:5c2:5c77:3321 with SMTP id 4fb4d7f45d1cf-5c3e9533529mr14238861a12.3.1726037211614; Tue, 10 Sep 2024 23:46:51 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd8adaasm5350300a12.80.2024.09.10.23.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 23:46:48 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C39665FA18; Wed, 11 Sep 2024 07:46:46 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Gustavo Romero , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 08/10] tests/guest-debug: Support passing arguments to the GDB test script Date: Wed, 11 Sep 2024 07:46:43 +0100 Message-Id: <20240911064645.357592-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240911064645.357592-1-alex.bennee@linaro.org> References: <20240911064645.357592-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Gustavo Romero This commit adds support for passing arguments to the GDB test scripts so it's possible to parse the args in an "argparse way" in the test scripts launched by the runner. The arguments should be preceded by -- when passed to the runner. For example, passing "--help" arg to the GDB_TEST_SCRIPT: run-test.py [...] --test -- --help The test script should not use the argparse module directly but import arg_parser from test_gdbstub module. arg_parser then can be used just like the argparse.ArgumentParser class: from test_gdbstub import arg_parser p = arg_parser(prog="test-mytest.py", description="My test.") p.add_argument("--vowel", help="Select vowel", required=True, choices=['a','e','i','o','u']) [...] The arg_parser allows a smooth and informative exit if, for instance, the caller of the runner script passes an invalid argument or misses a required argument by the test script. Signed-off-by: Gustavo Romero Reviewed-by: Alex Bennée Message-Id: <20240906143316.657436-4-gustavo.romero@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20240910173900.4154726-9-alex.bennee@linaro.org> diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index 368ff8a890..5a091db8be 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -27,6 +27,10 @@ def get_args(): parser.add_argument("--binary", help="Binary to debug", required=True) parser.add_argument("--test", help="GDB test script") + parser.add_argument('test_args', nargs='*', + help="Additional args for GDB test script. " + "The args should be preceded by -- to avoid confusion " + "with flags for runner script") parser.add_argument("--gdb", help="The gdb binary to use", default=None) parser.add_argument("--gdb-args", help="Additional gdb arguments") @@ -91,6 +95,8 @@ def log(output, msg): gdb_cmd += " -ex 'target remote %s'" % (socket_name) # finally the test script itself if args.test: + if args.test_args: + gdb_cmd += f" -ex \"py sys.argv={args.test_args}\"" gdb_cmd += " -x %s" % (args.test) diff --git a/tests/guest-debug/test_gdbstub.py b/tests/guest-debug/test_gdbstub.py index 46fbf98f0c..a715c0e3f5 100644 --- a/tests/guest-debug/test_gdbstub.py +++ b/tests/guest-debug/test_gdbstub.py @@ -2,6 +2,7 @@ """ from __future__ import print_function +import argparse import gdb import os import sys @@ -9,6 +10,10 @@ fail_count = 0 +class arg_parser(argparse.ArgumentParser): + def exit(self, status=None, message=""): + print("Wrong GDB script test argument! " + message) + gdb.execute("exit 1") def report(cond, msg): """Report success/fail of a test"""