From nobody Thu May 2 20:20:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616504849; cv=none; d=zohomail.com; s=zohoarc; b=RKPUXv8peMt1mhrWeTHwDEx3x0ldOQnPQ3VzrNDVdMTYx2AUtjxUSWu0zvAMT95JoXvob4r0YvEdjAhqUCZBKRU1PJk3Aao5BTMM5wLEF5z04N98dJyX3IygUecK9fEU1LVmDJCs825JCtNoSaPwPI471yYbpZWQJTNL7gYAZPY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616504849; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+5eTiuWmbhLWopCKunYthhDZ4oxHC2qbNf0hg72RLtg=; b=EvhXH2vxAXdElGi0L7Ttgd0ZmUGxVoNvXIEAs/jZtDCf3oGhIE4PWwBuap2Tbo9x+s5xcq2RN3+p9ufL1ehzgG4zOtvOjZBDjy2BzSxOpBrCYgZCnlqO0weMEVCoLQrBRkWIc4Bm/CfmKYEat7waY1nzGgr3Porg57iRcpFkmZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616504849144513.9432810239814; Tue, 23 Mar 2021 06:07:29 -0700 (PDT) Received: from localhost ([::1]:40738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOgkq-0006r1-1D for importer@patchew.org; Tue, 23 Mar 2021 09:07:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOgjm-0005SP-0j; Tue, 23 Mar 2021 09:06:22 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:35375) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOgjj-0002Ju-Hw; Tue, 23 Mar 2021 09:06:21 -0400 Received: by mail-wr1-x42d.google.com with SMTP id j18so20697983wra.2; Tue, 23 Mar 2021 06:06:18 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id i8sm2507590wmi.6.2021.03.23.06.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 06:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+5eTiuWmbhLWopCKunYthhDZ4oxHC2qbNf0hg72RLtg=; b=B15ZanwA4mvb9+jXChDt5jjez64M2u9yEkNGtWd35Uo1xnEUsy+4F7HbkrqNOo3HL+ 76xhqpyeYfIZy3DYhA1gvDwMJupsS2aj2U4iV0VONYPVkPlk5WJjNvRiYcLVV7RcSwKI BzN8hLSNVpKsnTAYStQXpEzhfikZI3xbO7kv5Wf/0H/jUXr8AFghqMOGAhp0rO89FDQH Zj5bLXr3iWQPIFrnHiC96SF4Z6VMFDXip2i7GL7MbAauLUnC/Wj9K2g0m4CAqfiL1lsJ PQMlWOSCMdwoqvkhSvNtfcPdJMJVllbhaq0A5FjFEuytpfVyf1t66hjv6S9iziqaw69Y LNRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+5eTiuWmbhLWopCKunYthhDZ4oxHC2qbNf0hg72RLtg=; b=JEQEyoxm/l4uuXleLadfKQ7XpKkqLQ6Q3/gOOorOpFjip+NIaupXL7t2o/dxlyfKUw 6JIH3cCqxGZhfImpPrZRVmo380mVD8ZGF7lfwNIgmhkrHmU0Bdu3Dx5xNOAKo3ToiGm3 CT4FQGSUFlJFMOeUAmhGH+mi/sSBPGYTb+9H3cIERzJP8R7sIl5j8Yab+Wc5umfX12/J tMCx7gEYqe6N3G5J0ERtg+9J2rQvRU92x+ec3kfA564tOcm90ZWKNY/fWZ5Sr+rTv1TH XtxlUQuMb+e0/0//al3/DbJK0D2ls2sgdRJljQ21jbvkRX+5Ql94edv17tCHeNpEeJ2d EeSw== X-Gm-Message-State: AOAM5336gciPEZYNFQ7Yb73ox2HlOfVLnMJmin3MHSgkLQIhmNkKw2mc +uTbLmzJv+kNwKXGvN59hCOckmlZP7U= X-Google-Smtp-Source: ABdhPJyLSkcGIfaEfweScPqbqQ0qyKvA7weTCpC2XPEHSOclyrl/pVSjaxOQgO0cU95xXylXaUKv3Q== X-Received: by 2002:a05:6000:1789:: with SMTP id e9mr3951363wrg.237.1616504777519; Tue, 23 Mar 2021 06:06:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 1/4] qemu-iotests: allow passing unittest.main arguments to the test scripts Date: Tue, 23 Mar 2021 14:06:11 +0100 Message-Id: <20210323130614.146399-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210323130614.146399-1-pbonzini@redhat.com> References: <20210323130614.146399-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::42d; envelope-from=paolo.bonzini@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eesposit@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Python test scripts that use unittest consist of multiple tests. unittest.main allows selecting which tests to run, but currently this is not possible because the iotests wrapper ignores sys.argv. unittest.main command line options also allow the user to pick the desired options for verbosity, failfast mode, etc. While "-d" is currently translated to "-v", it also enables extra debug output, and also there are no other options available. Unfortunately, these command line options only work if the unittest.main testRunner argument is a type, rather than a TestRunner instance, and right now iotests.py is using a TextTestRunner instance in order to pass the output stream. By moving the machinery to obtain reproducible unittest output into a TextTestRunner subclass, we can just pass the class name to unittest.main. Signed-off-by: Paolo Bonzini --- tests/qemu-iotests/iotests.py | 60 ++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 90d0b62523..b9f4edfc42 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1271,38 +1271,49 @@ def func_wrapper(*args, **kwargs): return func(*args, **kwargs) return func_wrapper =20 -def execute_unittest(debug=3DFalse): - """Executes unittests within the calling module.""" - - verbosity =3D 2 if debug else 1 - - if debug: - output =3D sys.stdout - else: - # We need to filter out the time taken from the output so that - # qemu-iotest can reliably diff the results against master output. - output =3D io.StringIO() - - runner =3D unittest.TextTestRunner(stream=3Doutput, descriptions=3DTru= e, - verbosity=3Dverbosity) - try: - # unittest.main() will use sys.exit(); so expect a SystemExit - # exception - unittest.main(testRunner=3Drunner) - finally: - # We need to filter out the time taken from the output so that - # qemu-iotest can reliably diff the results against master output. - if not debug: - out =3D output.getvalue() +# We need to filter out the time taken from the output so that +# qemu-iotest can reliably diff the results against master output. +class ReproducibleTextTestRunner(unittest.TextTestRunner): + __output =3D None + + @classmethod + @property + def output(cls): + if cls.__output is not None: + return cls.__output + + cls.__output =3D io.StringIO() + def print_output(): + out =3D cls.__output.getvalue() out =3D re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests'= , out) =20 # Hide skipped tests from the reference output out =3D re.sub(r'OK \(skipped=3D\d+\)', 'OK', out) out_first_line, out_rest =3D out.split('\n', 1) out =3D out_first_line.replace('s', '.') + '\n' + out_rest - sys.stderr.write(out) =20 + atexit.register(print_output) + return cls.__output + + def __init__(self, *args, **kwargs): + super().__init__(stream=3DReproducibleTextTestRunner.output, *args= , **kwargs) + +def execute_unittest(argv, debug=3DFalse): + """Executes unittests within the calling module.""" + + # If we see non-empty argv we must not be invoked as a test script, + # so do not bother making constant output; debuggability is more + # important. + if debug or len(argv) > 1: + argv +=3D ['-v'] + runner =3D unittest.TextTestRunner + else: + runner =3D ReproducibleTextTestRunner + + unittest.main(argv=3Dargv, testRunner=3Drunner, + warnings=3DNone if sys.warnoptions else 'ignore') + def execute_setup_common(supported_fmts: Sequence[str] =3D (), supported_platforms: Sequence[str] =3D (), supported_cache_modes: Sequence[str] =3D (), @@ -1338,7 +1348,7 @@ def execute_test(*args, test_function=3DNone, **kwarg= s): =20 debug =3D execute_setup_common(*args, **kwargs) if not test_function: - execute_unittest(debug) + execute_unittest(sys.argv, debug) else: test_function() =20 --=20 2.30.1 From nobody Thu May 2 20:20:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616505006; cv=none; d=zohomail.com; s=zohoarc; b=VfFSoi+9+KDtkcMqAsfeyRRYH6AJU7Td6FWlHE1uvp1CH8lCBNkGBLxcsMDJDEluBCsLfHo7dsdWoOVWl1Hio/2ksX81Pb9Mhz4arKXf1+4RJJtp2YKVruvxxLiQcQvj664FiJSJYspBY1sMujWiCXK3NI5GnrXK+UYa/Tyrg6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616505006; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W+8/8i8/ON0iKou8EKicmYr0pIq5n+4GmS672dCRAOc=; b=WaZ/ECXd2jWZD1R4Df6YkfikgKi9uCRKmC/188o57D2KoojEoto9Bk0/UH+YK+2FNo1kXaUqiW8dSNe/3CrUDiRhnLbMt4b7eP58vGITrIapVzQ3DmQT64zwq/b76iIuUYGflPNjtvK8sTvJUi2LEfSz0k0+Omu9Mp5a9FZSFiI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616505006676206.60127508642688; Tue, 23 Mar 2021 06:10:06 -0700 (PDT) Received: from localhost ([::1]:47150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOgnN-0001Cn-JH for importer@patchew.org; Tue, 23 Mar 2021 09:10:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOgjm-0005Sl-5Q; Tue, 23 Mar 2021 09:06:22 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:39471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOgjk-0002Ki-6B; Tue, 23 Mar 2021 09:06:21 -0400 Received: by mail-wr1-x436.google.com with SMTP id e18so20711232wrt.6; Tue, 23 Mar 2021 06:06:19 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id i8sm2507590wmi.6.2021.03.23.06.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 06:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W+8/8i8/ON0iKou8EKicmYr0pIq5n+4GmS672dCRAOc=; b=jGsniELh5/pnM5wFtWIjba2gfvLj8kruZL/AzqA81H1w8v5YNFV6YiMB8bVK4uuqLc rhgY8MsB0vfLYtDMQtSS5JLQBGxdwq1RbaxD4iZ5xCjtC+4kdK2m29TlrEkMRPh5W5D9 /1fKEV90Ty2DsMAyAAcB10Wp0VHK7VULcEAFDTyL4XcnQTkllIv/4NfxC20Zy+Rs76qo 8DGvpdDpz1gT8oumjVSQm8vmKpfX+0mXSywLJhTfYTZUCrVINy8qI5i4itXpmN5EewiY E5vH90KaWuw1OLQUbV/QlH8i5WYk2q97ZmFmI7PWRuWqAy069DSuedtgdcirwP8QCQm5 8+Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=W+8/8i8/ON0iKou8EKicmYr0pIq5n+4GmS672dCRAOc=; b=eRJgINztapkZ0BgNPXcFiMvaRxcC5m9O611SFqye0GIRJAHu3bmzm1fbMYN4PmmBed YpTWhcEcwBqD0fW/+XFJyaGBVNTSxziBO0cAntETdkAVXSG31BnUdhuggo6u+q0w9ZGj QtnPkikY9n7IHIJ6kpJjZVAOT6+MNlSEcsSBAK4vEjQYUmJg0ixDu8QZI8GaUUZXUJ7g +S72GSBZbzFC69Ajud6T12IaE+JYpeTjPexJ8WGYwdtX9LTZtzU3iSieT6EvKlKUguRF uWHmgg70nhhveHsQtOvGsnyzTX5z++PFKLFaKi4LUynubDUJO4AgQgR46wxsjvSjFN7S rmMA== X-Gm-Message-State: AOAM531l0M1Tkryas661WIF5z0MgZfp6EpCQP+GRCrxEQuXCUHBE13N7 3uVVH+b6ZWSqqZnABEhrYIHUkdqDPsY= X-Google-Smtp-Source: ABdhPJw7HMM6a+YDH1Vphci5Iw5w5F3X/AQSe3/f0c9KTp8scuFSxuJYh6JqolQ4Bg6yxENaEd+yFg== X-Received: by 2002:a5d:534e:: with SMTP id t14mr3834502wrv.202.1616504778407; Tue, 23 Mar 2021 06:06:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 2/4] qemu-iotests: move command line and environment handling from TestRunner to TestEnv Date: Tue, 23 Mar 2021 14:06:12 +0100 Message-Id: <20210323130614.146399-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210323130614.146399-1-pbonzini@redhat.com> References: <20210323130614.146399-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::436; envelope-from=paolo.bonzini@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eesposit@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In the next patch, "check" will learn how to execute a test script without going through TestRunner. To enable this, keep only the text output and subprocess handling in the TestRunner; move into TestEnv the logic to prepare for running a subprocess. Signed-off-by: Paolo Bonzini Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/testenv.py | 20 ++++++++++++++++++-- tests/qemu-iotests/testrunner.py | 15 +-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py index 1fbec854c1..6767eeeb25 100644 --- a/tests/qemu-iotests/testenv.py +++ b/tests/qemu-iotests/testenv.py @@ -25,7 +25,7 @@ import random import subprocess import glob -from typing import Dict, Any, Optional, ContextManager +from typing import List, Dict, Any, Optional, ContextManager =20 =20 def isxfile(path: str) -> bool: @@ -74,6 +74,21 @@ class TestEnv(ContextManager['TestEnv']): 'CACHEMODE_IS_DEFAULT', 'IMGFMT_GENERIC', 'IMGOPTSSYN= TAX', 'IMGKEYSECRET', 'QEMU_DEFAULT_MACHINE', 'MALLOC_PERTU= RB_'] =20 + def prepare_subprocess(self, args: List[str]) -> Dict[str, str]: + if self.debug: + args.append('-d') + + with open(args[0], encoding=3D"utf-8") as f: + try: + if f.readline().rstrip() =3D=3D '#!/usr/bin/env python3': + args.insert(0, self.python) + except UnicodeDecodeError: # binary test? for future. + pass + + os_env =3D os.environ.copy() + os_env.update(self.get_env()) + return os_env + def get_env(self) -> Dict[str, str]: env =3D {} for v in self.env_variables: @@ -268,7 +283,8 @@ def print_env(self) -> None: PLATFORM -- {platform} TEST_DIR -- {TEST_DIR} SOCK_DIR -- {SOCK_DIR} -SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER}""" +SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER} +""" =20 args =3D collections.defaultdict(str, self.get_env()) =20 diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunn= er.py index 1fc61fcaa3..2f56ac545d 100644 --- a/tests/qemu-iotests/testrunner.py +++ b/tests/qemu-iotests/testrunner.py @@ -129,7 +129,6 @@ class TestRunner(ContextManager['TestRunner']): def __init__(self, env: TestEnv, makecheck: bool =3D False, color: str =3D 'auto') -> None: self.env =3D env - self.test_run_env =3D self.env.get_env() self.makecheck =3D makecheck self.last_elapsed =3D LastElapsedTime('.last-elapsed-cache', env) =20 @@ -243,18 +242,7 @@ def do_run_test(self, test: str) -> TestResult: silent_unlink(p) =20 args =3D [str(f_test.resolve())] - if self.env.debug: - args.append('-d') - - with f_test.open(encoding=3D"utf-8") as f: - try: - if f.readline().rstrip() =3D=3D '#!/usr/bin/env python3': - args.insert(0, self.env.python) - except UnicodeDecodeError: # binary test? for future. - pass - - env =3D os.environ.copy() - env.update(self.test_run_env) + env =3D self.env.prepare_subprocess(args) =20 t0 =3D time.time() with f_bad.open('w', encoding=3D"utf-8") as f: @@ -328,7 +316,6 @@ def run_tests(self, tests: List[str]) -> bool: =20 if not self.makecheck: self.env.print_env() - print() =20 test_field_width =3D max(len(os.path.basename(t)) for t in tests) = + 2 =20 --=20 2.30.1 From nobody Thu May 2 20:20:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616505002; cv=none; d=zohomail.com; s=zohoarc; b=mdlsL58OA+wsUHPdZnANYDsHaMAIlJXSSRVMCijDJnuLBa3oncfmtcbPZaQkam6eL42uXqDrcy8pYuhvkYn9wjb2KtRstzZ7PfOa/MgqaHRIhlLRqfK8vnzCuRCb/gqndAoRIU4zhrHgVZjNM1krsW5UfiPEPpnzQxurlSMaN48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616505002; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0M8wW87BuDH+rmu9cePgKen5O5CaaJxYZ5OM4Z4+XQc=; b=YgmxpIpnfr+LKXf2QOwiGNu5NtTpO467UzZnG2CApYCvLrtOeDJ77sor1Wb48eHWBCjQoTNQPupMYepthgBhJ0NJtfE8cZhceL5fPIIuAjDLdYSxwhCSkXL0keYhra4quEymUtipXVvuDQcpsD4m6el6Snb265MIxmfVXMwl+94= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616505002168501.2617407701482; Tue, 23 Mar 2021 06:10:02 -0700 (PDT) Received: from localhost ([::1]:46846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOgnI-000138-TB for importer@patchew.org; Tue, 23 Mar 2021 09:10:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOgjm-0005TW-IW; Tue, 23 Mar 2021 09:06:22 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:41949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOgjk-0002LE-Sh; Tue, 23 Mar 2021 09:06:22 -0400 Received: by mail-wr1-x435.google.com with SMTP id b9so20702749wrt.8; Tue, 23 Mar 2021 06:06:20 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id i8sm2507590wmi.6.2021.03.23.06.06.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 06:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0M8wW87BuDH+rmu9cePgKen5O5CaaJxYZ5OM4Z4+XQc=; b=EcBFcbtOSqvotXUwc8ZCZVIWS2nNdlxHeKDbQxruMsrHZvxlchZXXxKRARK8ZtXsMC ZTPUwJ55ZnRaSRJiSRKBVARDwE4c6njR2YZSlWZtIHiQjuRq4K29OzzkwyTmMYc6E4QG ZAHSXfL8O5h9kDfXplmduNhiIGefA/hwmhaxA4Bt18OR2Z8vOfvxE3xcU9g0F76fw0h+ hcKOwdKqWLwXbCWHiD8oXnLQYQs5rcARRcuDGuU37TxStayOnT4iTLHZFd3H3FUj5ZJd 6XggpD6anDH8E62L86ytcfy+ee5Vyphq0WBcZ6F1bso0HLNRkq+PUx4Kh3bl6th00NQV t0NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=0M8wW87BuDH+rmu9cePgKen5O5CaaJxYZ5OM4Z4+XQc=; b=KdZWO+OS2g3UN8xjLnDqs0ch5R8yx/P2rerqaSRDpNb72tXynzQ+u4xZ1uKbump1OU qSfAeIrZGbxM+FeNdT+09IlvA/eOro7hwhLpk44sVQfim8f2VoAIzAIVkslxSE7/b/nM hXN20eLHK6zmf0CP66+uT+x4/rUda73rPCVljn9MxSRXOwzLJZgvXNTD/jlcrt8U+APp +mGK2er2iR6ghVw/zqCywoIly+swjYvTeIWAmnO8a8Cjwe72cqewIXyVGlK0tlvbcs4G 1Vz+X2BTuEMXC9JPCdk/O1Rkbi9Y9QUzfUfiC+4KHLDZAa9sv5e5tXuJygnz4QxsGQnC ySJA== X-Gm-Message-State: AOAM532tFasPvU55/oxeqQ7U3v+UE0TbIga4ZII2C2s6Pq1ApVOH/ivD TlY/Gwnnl4ZeA59AtadYXa8TXCQMtuM= X-Google-Smtp-Source: ABdhPJxKY6wx3tDNPnlFbxzT9zb2/sxe8Ug7kX0dy5Pr7yLX+HS2Ke/D4Z3z6cLqxnFsCqdt2HFp0A== X-Received: by 2002:a5d:42d2:: with SMTP id t18mr3935711wrr.258.1616504779187; Tue, 23 Mar 2021 06:06:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 3/4] qemu-iotests: let "check" spawn an arbitrary test command Date: Tue, 23 Mar 2021 14:06:13 +0100 Message-Id: <20210323130614.146399-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210323130614.146399-1-pbonzini@redhat.com> References: <20210323130614.146399-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::435; envelope-from=paolo.bonzini@gmail.com; helo=mail-wr1-x435.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eesposit@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Right now there is no easy way for "check" to print a reproducer command. Because such a reproducer command line would be huge, we can instead teach check to start a command of our choice. This can be for example a Python unit test with arguments to only run a specific subtest. Signed-off-by: Paolo Bonzini Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/check | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index d1c87ceaf1..aab25dac6a 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -19,6 +19,7 @@ import os import sys import argparse +import shutil from findtests import TestFinder from testenv import TestEnv from testrunner import TestRunner @@ -100,8 +101,8 @@ def make_argparser() -> argparse.ArgumentParser: 'one to TEST (not inclusive). This may be used to ' 'rerun failed ./check command, starting from the ' 'middle of the process.') - g_sel.add_argument('tests', metavar=3D'TEST_FILES', nargs=3D'*', - help=3D'tests to run') + g_sel.add_argument('tests', nargs=3Dargparse.REMAINDER, + help=3D'tests to run, or "--" followed by a command= ') =20 return p =20 @@ -114,6 +115,17 @@ if __name__ =3D=3D '__main__': imgopts=3Dargs.imgopts, misalign=3Dargs.misalign, debug=3Dargs.debug, valgrind=3Dargs.valgrind) =20 + if args.tests[0] =3D=3D '--': + del args.tests[0] + cmd =3D args.tests + env.print_env() + exec_path =3D shutil.which(cmd[0]) + if exec_path is None: + sys.exit('command not found: ' + cmd[0]) + cmd[0] =3D exec_path + full_env =3D env.prepare_subprocess(cmd) + os.execve(cmd[0], cmd, full_env) + testfinder =3D TestFinder(test_dir=3Denv.source_iotests) =20 groups =3D args.groups.split(',') if args.groups else None --=20 2.30.1 From nobody Thu May 2 20:20:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616504912; cv=none; d=zohomail.com; s=zohoarc; b=edbanC5SrYibe8CNSN9SyezHrqZVb2JE4PPSmoD95C+Gl4SegMZsn9DpNxyMgIEDV+RjR47yMLmAzKOuWpzqp6vPkDmYhB+cZNB91AN1qkY4HAYx1eXoUttkW7TU3+fyiKHBQjwhYg9ZeChcug9iB+7/Bv8Jub6sGk+9L2zxYyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616504912; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FIiDl70VzJ29OzobWO6rnz2BouytBDFb+3CY1MtwOxA=; b=UlbkGacmF2/ZNxIFoZVVScyXacU2dMMhvHJvysFtYk3Vt9Mbb89uMAKB16pkITLN7s6aFfmK6QHvbuhd25BSOkjSWVLHzPttaEW6M0QZQFjP5AL5h82JqULCv3MqbhLwcxlNM2OpA2JVGFw5eycf7jPUNbQc6FSpjpNLPYw6JCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616504912876468.42969669938157; Tue, 23 Mar 2021 06:08:32 -0700 (PDT) Received: from localhost ([::1]:43080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOglr-0007qy-BI for importer@patchew.org; Tue, 23 Mar 2021 09:08:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOgjr-0005dV-GY; Tue, 23 Mar 2021 09:06:27 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:51959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOgjm-0002Mb-4k; Tue, 23 Mar 2021 09:06:27 -0400 Received: by mail-wm1-x333.google.com with SMTP id p19so11019643wmq.1; Tue, 23 Mar 2021 06:06:21 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id i8sm2507590wmi.6.2021.03.23.06.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 06:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FIiDl70VzJ29OzobWO6rnz2BouytBDFb+3CY1MtwOxA=; b=Xhwy6rUg3XoFKRIT+ew8RVk5NKrr+ptwWgdxPT3IAAMJbgNB+D+pZLIPRf/peFXHYT VJyyIIQiT2x9EAKD5fnREwhjIjFUUkALvcLAUSmOzYive/4DaqA98/uQZ+ofDFdcjjQV hjvyAElrpvilCFqNmuGjaOwtdzgDEUbhlWzTH9464tCrDE9OfVkwPzZKVY9THZyGH47A 56O7Bo1gtkwBDiselMTQvWSlB58RmzMZ+bwTl1eTX9ydQoyY/5WRNxpzdPbHqQTnqEq6 6GZym9jfR3xXQ3d4ZaVkbp9BQ2L42Wra9Kx49J7CHwlulQuawVbornXK68uXLIHIhWXL mNaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=FIiDl70VzJ29OzobWO6rnz2BouytBDFb+3CY1MtwOxA=; b=eOnq+ujrUy1HdF3w9N/3GTMDiMs5qQzJgya7b1GnsZq4c3paGjbUNmJJ6mXEEq8pHj xQ9w+5pTx0GSSWcjLv2wouRyjv2Avip4zQTqrczYNY92zLYgtJMo0TrGHj4zlvGPT1H/ GO4E+RjcLxT7MzJ+IKcQvX69evQLnAqSZqmZE7fS9p/y4t8pMv+g5M2Rvbdyg4CYmlW3 Ol9PF6Mmi1DJGeS2wwVeoL8HAmUGBO5ZxZwjuXy6CvEMBW7u7Zs2/xFQU6shwvzR2ibI RrrR40BgPDAuwGRQR7NJ7oz6XmKP0cpXVo40641Dehdc1onMUxTvFuPdidZl3UByz9je p+qA== X-Gm-Message-State: AOAM530F38h/ffvBhu+9DVENv8sXLl3Mqd6kT8UG/M5KOo0sK8HqLRqb vDEhedg1Ce02iSOvUZv+MGOnbSMwIbQ= X-Google-Smtp-Source: ABdhPJzcT4wKyt70ZwC9rUV+bB3Xg05QF+jCr7U1ogajAs2Y3Vnf6cM7H4shWelObZa0Ao24ZwT9hA== X-Received: by 2002:a05:600c:614:: with SMTP id o20mr3225924wmm.66.1616504780087; Tue, 23 Mar 2021 06:06:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 4/4] qemu-iotests: fix case of SOCK_DIR already in the environment Date: Tue, 23 Mar 2021 14:06:14 +0100 Message-Id: <20210323130614.146399-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210323130614.146399-1-pbonzini@redhat.com> References: <20210323130614.146399-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::333; envelope-from=paolo.bonzini@gmail.com; helo=mail-wm1-x333.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eesposit@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Due to a typo, in this case the SOCK_DIR was not being created. Signed-off-by: Paolo Bonzini Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/testenv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py index 6767eeeb25..169268f61a 100644 --- a/tests/qemu-iotests/testenv.py +++ b/tests/qemu-iotests/testenv.py @@ -120,7 +120,7 @@ def init_directories(self) -> None: try: self.sock_dir =3D os.environ['SOCK_DIR'] self.tmp_sock_dir =3D False - Path(self.test_dir).mkdir(parents=3DTrue, exist_ok=3DTrue) + Path(self.sock_dir).mkdir(parents=3DTrue, exist_ok=3DTrue) except KeyError: self.sock_dir =3D tempfile.mkdtemp() self.tmp_sock_dir =3D True --=20 2.30.1