From patchwork Thu Apr 14 11:32:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Silbe X-Patchwork-Id: 8834511 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B0F739F36E for ; Thu, 14 Apr 2016 11:33:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECB4C201F2 for ; Thu, 14 Apr 2016 11:33:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 322F5201B9 for ; Thu, 14 Apr 2016 11:33:04 +0000 (UTC) Received: from localhost ([::1]:37819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqfWB-000511-E9 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 14 Apr 2016 07:33:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqfVz-0004y5-8F for qemu-devel@nongnu.org; Thu, 14 Apr 2016 07:32:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aqfVv-0004Fv-RW for qemu-devel@nongnu.org; Thu, 14 Apr 2016 07:32:51 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:48722) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqfVv-0004Er-He for qemu-devel@nongnu.org; Thu, 14 Apr 2016 07:32:47 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Apr 2016 12:32:45 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 14 Apr 2016 12:32:42 +0100 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: silbe@linux.vnet.ibm.com X-IBM-RcptTo: qemu-block@nongnu.org;qemu-devel@nongnu.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id CD8FF17D8085; Thu, 14 Apr 2016 12:33:23 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u3EBWb7847055044; Thu, 14 Apr 2016 11:32:38 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u3EBWbYW022573; Thu, 14 Apr 2016 05:32:37 -0600 Received: from oc4731375738.boeblingen.de.ibm.com (dyn-9-152-222-69.boeblingen.de.ibm.com [9.152.222.69]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u3EBWbr5022554 (version=TLSv1/SSLv3 cipher=AES256-SHA256 bits=256 verify=NO); Thu, 14 Apr 2016 05:32:37 -0600 From: Sascha Silbe To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 14 Apr 2016 13:32:23 +0200 Message-Id: <1460633543-7366-1-git-send-email-silbe@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16041411-0009-0000-0000-0000123B2457 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.108 Subject: [Qemu-devel] [PATCH for-2.6?] qemu-iotests: iotests: fail hard if not run via "check" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Running an iotests-based Python test directly might appear to work, but may fail in subtle ways and is insecure: - It creates files with predictable file names in a world-writable location (/var/tmp). - Tests expect the environment to be set up by check. E.g. 041 and 055 may take the wrong code paths if QEMU_DEFAULT_MACHINE is not set. This can lead to false negatives. Instead fail hard and tell the user we want to be run via "check". Signed-off-by: Sascha Silbe Reviewed-by: Bo Tu --- It's possible to fix iotests.py to work even outside of check, but that requires reimplementing parts of what check currently does. I'd prefer not to do that this late in the cycle. It would be nice to have this in 2.6, just in case someone even tries running a Python-based test directly instead of using ./check like for the shell-based tests. But it's not crucial. --- tests/qemu-iotests/iotests.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 0c0b533..8c7138f 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -46,7 +46,7 @@ if os.environ.get('QEMU_OPTIONS'): imgfmt = os.environ.get('IMGFMT', 'raw') imgproto = os.environ.get('IMGPROTO', 'file') -test_dir = os.environ.get('TEST_DIR', '/var/tmp') +test_dir = os.environ.get('TEST_DIR') output_dir = os.environ.get('OUTPUT_DIR', '.') cachemode = os.environ.get('CACHEMODE') qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') @@ -441,6 +441,10 @@ def verify_quorum(): def main(supported_fmts=[], supported_oses=['linux']): '''Run tests''' + if test_dir is None or qemu_default_machine is None: + sys.stderr.write('Please run this test via ./check\n') + sys.exit(os.EX_USAGE) + debug = '-d' in sys.argv verbosity = 1 verify_image_format(supported_fmts)