From nobody Wed May 15 10:50:18 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645465386595305.62704107771367; Mon, 21 Feb 2022 09:43:06 -0800 (PST) Received: from localhost ([::1]:56884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMCiH-0007VN-BN for importer@patchew.org; Mon, 21 Feb 2022 12:43:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMCV4-0008Ny-P1 for qemu-devel@nongnu.org; Mon, 21 Feb 2022 12:29:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMCUz-00005j-JW for qemu-devel@nongnu.org; Mon, 21 Feb 2022 12:29:24 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-PPB-vlDTPy6MpjwXSoJv7A-1; Mon, 21 Feb 2022 12:29:13 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79785801B0D; Mon, 21 Feb 2022 17:29:12 +0000 (UTC) Received: from localhost (unknown [10.39.193.15]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA0C384D02; Mon, 21 Feb 2022 17:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645464556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ImtiBC428P+YNahHgp+Ds6qw1HVV6KtD6d5QKJ/8+T0=; b=g4HS2SzzrIs4FlJsNuxRxWA+8PdF0fmARqVbny6PnjZx6Yos3gHmWdNICQXb933u18Uhmv 8g/Khd6y1nRRcOvIh/7/+Szp+AzUBjGi72X3FUgEiwVpKdahr1AmvqvnyI5Iy/2lpDw1ah ze306xxTiZq6PxyuHyF6gEP7K764NwE= X-MC-Unique: PPB-vlDTPy6MpjwXSoJv7A-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PATCH v2] iotests: Write test output to TEST_DIR Date: Mon, 21 Feb 2022 18:29:09 +0100 Message-Id: <20220221172909.762858-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Cc: Thomas Huth , Kevin Wolf , Hanna Reitz , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1645465389017100001 Content-Type: text/plain; charset="utf-8" Drop the use of OUTPUT_DIR (test/qemu-iotests under the build directory), and instead write test output files (.out.bad, .notrun, and .casenotrun) to TEST_DIR. With this, the same test can be run concurrently without the separate instances interfering, because they will need separate TEST_DIRs anyway. Running the same test separately is useful when running the iotests with various format/protocol combinations in parallel, or when you just want to aggressively exercise a single test (e.g. when it fails only sporadically). Putting this output into TEST_DIR means that it will stick around for inspection after the test run is done (though running the same test in the same TEST_DIR will overwrite it, just as it used to be); but given that TEST_DIR is a scratch directory, it should be clear that users can delete all of its content at any point. (And if TEST_DIR is on tmpfs, it will just disappear on shutdown.) Contrarily, alternative approaches that would put these output files into OUTPUT_DIR with some prefix to differentiate between separate test runs might easily lead to cluttering OUTPUT_DIR. (This change means OUTPUT_DIR is no longer written to by the iotests, so we can drop its usage altogether.) Signed-off-by: Hanna Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy --- v1: https://lists.nongnu.org/archive/html/qemu-block/2022-02/msg00675.html v2: - Delete .casenotrun before running a test: Writes to this file only append data, so if we do not delete it before a test run, it may still contain stale data from a previous run - While at it, we might as well delete .notrun, because before this patch, all of .out.bad, .notrun, and .casenotrun are deleted. (Really no need to delete .out.bad, though, given it is immediately overwritten after where we delete .notrun and .casenotrun.) --- tests/qemu-iotests/common.rc | 6 +++--- tests/qemu-iotests/iotests.py | 5 ++--- tests/qemu-iotests/testenv.py | 5 +---- tests/qemu-iotests/testrunner.py | 15 +++++++++------ 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 9885030b43..5bde2415dc 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -726,7 +726,7 @@ _img_info() # _notrun() { - echo "$*" >"$OUTPUT_DIR/$seq.notrun" + echo "$*" >"$TEST_DIR/$seq.notrun" echo "$seq not run: $*" status=3D0 exit @@ -738,14 +738,14 @@ _notrun() # _casenotrun() { - echo " [case not run] $*" >>"$OUTPUT_DIR/$seq.casenotrun" + echo " [case not run] $*" >>"$TEST_DIR/$seq.casenotrun" } =20 # just plain bail out # _fail() { - echo "$*" | tee -a "$OUTPUT_DIR/$seq.full" + echo "$*" | tee -a "$TEST_DIR/$seq.full" echo "(see $seq.full for details)" status=3D1 exit 1 diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 6ba65eb1ff..1d157d1325 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -84,7 +84,6 @@ =20 imgfmt =3D os.environ.get('IMGFMT', 'raw') imgproto =3D os.environ.get('IMGPROTO', 'file') -output_dir =3D os.environ.get('OUTPUT_DIR', '.') =20 try: test_dir =3D os.environ['TEST_DIR'] @@ -1209,7 +1208,7 @@ def notrun(reason): # Each test in qemu-iotests has a number ("seq") seq =3D os.path.basename(sys.argv[0]) =20 - with open('%s/%s.notrun' % (output_dir, seq), 'w', encoding=3D'utf-8')= \ + with open('%s/%s.notrun' % (test_dir, seq), 'w', encoding=3D'utf-8') \ as outfile: outfile.write(reason + '\n') logger.warning("%s not run: %s", seq, reason) @@ -1224,7 +1223,7 @@ def case_notrun(reason): # Each test in qemu-iotests has a number ("seq") seq =3D os.path.basename(sys.argv[0]) =20 - with open('%s/%s.casenotrun' % (output_dir, seq), 'a', encoding=3D'utf= -8') \ + with open('%s/%s.casenotrun' % (test_dir, seq), 'a', encoding=3D'utf-8= ') \ as outfile: outfile.write(' [case not run] ' + reason + '\n') =20 diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py index 0f32897fe8..b11e943c8a 100644 --- a/tests/qemu-iotests/testenv.py +++ b/tests/qemu-iotests/testenv.py @@ -66,7 +66,7 @@ class TestEnv(ContextManager['TestEnv']): # pylint: disable=3Dtoo-many-instance-attributes =20 env_variables =3D ['PYTHONPATH', 'TEST_DIR', 'SOCK_DIR', 'SAMPLE_IMG_D= IR', - 'OUTPUT_DIR', 'PYTHON', 'QEMU_PROG', 'QEMU_IMG_PROG', + 'PYTHON', 'QEMU_PROG', 'QEMU_IMG_PROG', 'QEMU_IO_PROG', 'QEMU_NBD_PROG', 'QSD_PROG', 'QEMU_OPTIONS', 'QEMU_IMG_OPTIONS', 'QEMU_IO_OPTIONS', 'QEMU_IO_OPTIONS_NO_FMT', @@ -106,7 +106,6 @@ def init_directories(self) -> None: TEST_DIR SOCK_DIR SAMPLE_IMG_DIR - OUTPUT_DIR """ =20 # Path where qemu goodies live in this source tree. @@ -134,8 +133,6 @@ def init_directories(self) -> None: os.path.join(self.source_iotests, 'sample_images')) =20 - self.output_dir =3D os.getcwd() # OUTPUT_DIR - def init_binaries(self) -> None: """Init binary path variables: PYTHON (for bash tests) diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunn= er.py index 0eace147b8..262b13004d 100644 --- a/tests/qemu-iotests/testrunner.py +++ b/tests/qemu-iotests/testrunner.py @@ -259,9 +259,6 @@ def do_run_test(self, test: str, mp: bool) -> TestResul= t: """ =20 f_test =3D Path(test) - f_bad =3D Path(f_test.name + '.out.bad') - f_notrun =3D Path(f_test.name + '.notrun') - f_casenotrun =3D Path(f_test.name + '.casenotrun') f_reference =3D Path(self.find_reference(test)) =20 if not f_test.exists(): @@ -276,9 +273,6 @@ def do_run_test(self, test: str, mp: bool) -> TestResul= t: description=3D'No qualified output ' f'(expected {f_reference})') =20 - for p in (f_bad, f_notrun, f_casenotrun): - silent_unlink(p) - args =3D [str(f_test.resolve())] env =3D self.env.prepare_subprocess(args) if mp: @@ -288,6 +282,15 @@ def do_run_test(self, test: str, mp: bool) -> TestResu= lt: env[d] =3D os.path.join(env[d], f_test.name) Path(env[d]).mkdir(parents=3DTrue, exist_ok=3DTrue) =20 + test_dir =3D env['TEST_DIR'] + f_bad =3D Path(os.path.join(test_dir, f_test.name + '.out.bad')) + f_notrun =3D Path(os.path.join(test_dir, f_test.name + '.notrun')) + f_casenotrun =3D Path(os.path.join(test_dir, + f_test.name + '.casenotrun')) + + for p in (f_notrun, f_casenotrun): + silent_unlink(p) + t0 =3D time.time() with f_bad.open('w', encoding=3D"utf-8") as f: with subprocess.Popen(args, cwd=3Dstr(f_test.parent), env=3Den= v, --=20 2.34.1