From patchwork Wed May 31 23:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 687326 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp53338wru; Wed, 31 May 2023 16:25:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6mQzwSbmmYJucfkKYfg4ZnvyLDqi7s8Par05n7J3eUKgXCWMl9lIGUkrGPbXTsVXxQysNh X-Received: by 2002:a05:620a:a52:b0:75b:23a1:3610 with SMTP id j18-20020a05620a0a5200b0075b23a13610mr6923106qka.33.1685575541018; Wed, 31 May 2023 16:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685575541; cv=none; d=google.com; s=arc-20160816; b=Cthfv7jvp0V6KHuaNGk/X97L3S5dgEG0Rjm9EugoU/O5lfCmZc21RnThkQKq9aiQhD wzgEDCjoZQEthZH3FtH4xEw1pc0VeTFhCdj5c/fsDb5G2sTyNBYCfFut2aYVFrUmJ9PL 0VCe2MMAXOwJUczJHx6atEX2aV/O8hVkovoVTslfqWHOFLaFG+yoA7dAoCV/0dzLHF1o p1EKU6+g3vCqXrPGEXiFVVsfAL1LcTxK2k6wOiJ5g78Fhct3t/MvlwPJQBPDT+Uk/cGv 4ScijfgOvWgujlpCxFXI3y4RB3No9inje9LYn6M4BQOAz1BFsL/rsAS1Ko7QBWucQauM KSlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=HK9K9jzzWlfIFdB7uwHlISI/daPJAK4dkCrRI+Fx+Fo=; b=o5p7Dc+8RA55nvRCcwU/fl/ovFvJT8EiV1UPSGOrISmA1sg5zXmozGyT4pMvIADtvi Ht+B0oeENt38SCqx9HEOPYKK6kOMsfyLnw/D1UhzF6PWOa9M5xc8EuuwCVWO0d4kDJkd WNzzU0yWBtiuO2sgu48vHyAv203amQnsWPcXU2HmRpwEzZxADuJeMOAD7BY1AvmutPze zTyV696Rfcn59sVgFf7O9v/Jvij/auPc/ITnoJtwqu1lBI9x+NQ27G8Xpl5RhnpvyDzI Xwo3gsbGyKhhiN1yvthe20DFbkeSwcasjyy/6HHjYydRRDopeeWCsqURKezFFwAwuB3u 1gKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RH1b012f; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c18-20020a05620a165200b0075b053ab653si9012936qko.686.2023.05.31.16.25.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 May 2023 16:25:41 -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=RH1b012f; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4VBt-0005or-L1; Wed, 31 May 2023 19:25:17 -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 1q4VBr-0005ob-8y for qemu-devel@nongnu.org; Wed, 31 May 2023 19:25:15 -0400 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q4VBp-0008QN-4h for qemu-devel@nongnu.org; Wed, 31 May 2023 19:25:15 -0400 Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-626149fbc8eso3535356d6.3 for ; Wed, 31 May 2023 16:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685575512; x=1688167512; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HK9K9jzzWlfIFdB7uwHlISI/daPJAK4dkCrRI+Fx+Fo=; b=RH1b012fi3japYXU+BEbGrFtloSDD+Ou5sib3p/v1MKgNuH2Hr5E8AFU3s1irRwRcY RwfC7ARbAiWHkXfzoOQLi2x3V6sNGYDES8BIwi8zKNp68Hpi5bNjS9WotnZnafulyNgm KQaOzZhHGpvp98YoVDkPlLP0EXeLBAI6rKUh3Y7b1Urn2F9zH1ELGdVZ5iKXvb028Mbo 0VM9Yrx0BwBAxrBBpzwnvuvdCSE4yAlXTLO00R6LhBXKjrvhAvFXavfYYYYhPoSvb4rR kfu18xWVepmkHWE7WHQ4lxAvygMxqBSwK0sAFEXhgy4qwB9D2g4gkMwzgAd0QkRUl0h5 ZomA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685575512; x=1688167512; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HK9K9jzzWlfIFdB7uwHlISI/daPJAK4dkCrRI+Fx+Fo=; b=Yeg6Z5s4I1yuz7cGdpShSEDT5HrffZattFKJqQeqt4mCUaibS3X52pY4MZiya7DZJT Hx8uWDgD0FB2MiKvw3DGdQmNQ4NwFwNF4+S+JRk+KTEIxOQXsWXyldtdElM1wCMN3ZOm dxeMytHXaWM6nyVHiSO8TsJTKegx6Y9Ovy7kQRToRzritlJnYKTcZRbbtGDHAFUF7i6C ecmSiL1Ftj45nTgoBUU+jYPoTEVB4Xe9Mh2metMPfT22DI2Fp8Kf/lIdToq3mUlnI5x2 Dxv9iRoW6a9a98tcnK7rJ66nZ62l3flxgmAxCZX973zVo1UuVdQB8yZcfqBK2+GpBZcI CbOQ== X-Gm-Message-State: AC+VfDwin3oxOzSdkGSAbXSxPpZJp3TCOFrJ31xz6AUzrZPy9KKELrcl BK13yuODg0N3Vuta/w6OGNoHfDJZsqgyjoj9Nuk= X-Received: by 2002:a05:6214:21a6:b0:625:aa49:9ab5 with SMTP id t6-20020a05621421a600b00625aa499ab5mr8135862qvc.57.1685575511760; Wed, 31 May 2023 16:25:11 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:3019:d9fa:8bb1:50d7]) by smtp.gmail.com with ESMTPSA id x19-20020aa784d3000000b0063b6451cd01sm3788360pfn.121.2023.05.31.16.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 16:25:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Thomas Huth Subject: [PATCH] decodetree: Add --output-null for meson testing Date: Wed, 31 May 2023 16:25:10 -0700 Message-Id: <20230531232510.66985-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf32.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, T_SCC_BODY_TEXT_LINE=-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Using "-o /dev/null" fails on Windows. Rather that working around this in meson, add a separate command-line option so that we can use python's os.devnull. Reported-by: Thomas Huth Fixes: 656666dc7d1b ("tests/decode: Convert tests to meson") Signed-off-by: Richard Henderson Reviewed-by: Thomas Huth --- scripts/decodetree.py | 18 ++++++++++-------- tests/decode/meson.build | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 13db585d04..a8a6cb69cd 100644 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -42,6 +42,7 @@ input_file = '' output_file = None output_fd = None +output_null = False insntype = 'uint32_t' decode_function = 'decode' @@ -145,12 +146,7 @@ def error_with_file(file, lineno, *args): if output_file and output_fd: output_fd.close() - # Do not try to remove e.g. -o /dev/null - if not output_file.startswith("/dev"): - try: - os.remove(output_file) - except PermissionError: - pass + os.remove(output_file) exit(0 if testforerror else 1) # end error_with_file @@ -1501,6 +1497,7 @@ def main(): global translate_prefix global output_fd global output_file + global output_null global input_file global insnwidth global insntype @@ -1514,7 +1511,8 @@ def main(): decode_scope = 'static ' long_opts = ['decode=', 'translate=', 'output=', 'insnwidth=', - 'static-decode=', 'varinsnwidth=', 'test-for-error'] + 'static-decode=', 'varinsnwidth=', 'test-for-error', + 'output-null'] try: (opts, args) = getopt.gnu_getopt(sys.argv[1:], 'o:vw:', long_opts) except getopt.GetoptError as err: @@ -1545,6 +1543,8 @@ def main(): error(0, 'cannot handle insns of width', insnwidth) elif o == '--test-for-error': testforerror = True + elif o == '--output-null': + output_null = True else: assert False, 'unhandled option' @@ -1574,7 +1574,9 @@ def main(): stree = build_size_tree(toppat.pats, 8, 0, 0) prop_size(stree) - if output_file: + if output_null: + output_fd = open(os.devnull, 'wt', encoding='utf-8', errors="ignore") + elif output_file: output_fd = open(output_file, 'wt', encoding='utf-8') else: output_fd = io.TextIOWrapper(sys.stdout.buffer, diff --git a/tests/decode/meson.build b/tests/decode/meson.build index 38a0629d67..b13fada980 100644 --- a/tests/decode/meson.build +++ b/tests/decode/meson.build @@ -53,12 +53,12 @@ decodetree = find_program(meson.project_source_root() / 'scripts/decodetree.py') foreach t: err_tests test(fs.replace_suffix(t, ''), - decodetree, args: ['-o', '/dev/null', '--test-for-error', files(t)], + decodetree, args: ['--output-null', '--test-for-error', files(t)], suite: suite) endforeach foreach t: succ_tests test(fs.replace_suffix(t, ''), - decodetree, args: ['-o', '/dev/null', files(t)], + decodetree, args: ['--output-null', files(t)], suite: suite) endforeach