From patchwork Tue Jan 31 13:57:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nir Soffer X-Patchwork-Id: 9547351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 516B06016C for ; Tue, 31 Jan 2017 14:04:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 439B3282E8 for ; Tue, 31 Jan 2017 14:04:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36CEB28329; Tue, 31 Jan 2017 14:04:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 993FB282E8 for ; Tue, 31 Jan 2017 14:04:32 +0000 (UTC) Received: from localhost ([::1]:38365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYZ2t-00077o-NU for patchwork-qemu-devel@patchwork.kernel.org; Tue, 31 Jan 2017 09:04:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYYwP-00017a-7i for qemu-devel@nongnu.org; Tue, 31 Jan 2017 08:57:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYYwO-00029U-B3 for qemu-devel@nongnu.org; Tue, 31 Jan 2017 08:57:49 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34521) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cYYwO-00029H-5d; Tue, 31 Jan 2017 08:57:48 -0500 Received: by mail-wm0-x242.google.com with SMTP id c85so84094697wmi.1; Tue, 31 Jan 2017 05:57:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cCHi4jDjj52mQgWBbXXwCS44ZvKskR9CivwJXr78q68=; b=R2msNV63WNa+PxvdOwIMSpzAG20MWt4J9/+V9v1+3dZzjBxs5y0Wh7G+AdqJiJC4mp /5b7ib/ok8nxG2qXHf8g1cG6aZWHe7HWnEXsKbzu6zl8YH5/iyPgxA9RiTOABjbySnGm WR9avj1ICsnePEPs8q4A3kuLheIDarUYWCp73PcmxzDYNR5w9gaZiD3Kh60+AgTrE5X3 +lIudAlr1OvdB9fYe+LaUNjPLnKCwJ6JeupVWFGdN+iX37NmgbI/OZSHU21z0Ih7rC/w JSDQ96KHyrafYI+Uzrw0rDDhb4F/rVSDWGW8d13Jaq0Qrzb62acPI/aFF/dhw4XiCUFw XUWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cCHi4jDjj52mQgWBbXXwCS44ZvKskR9CivwJXr78q68=; b=LvyrPTy5wyz7aLLb2equgamKe1VVWUvAXlffG3eZuNUATSfxa4Hb0BjBHMS20pW95Y MEn2B0SFNJJUB2dXFbAHgA4CeSl/3jV0+/HX0+Pnztj4k9mucM6nyOpDVvG7VkUBywQE wtZAYSbXsc6oD5MoeMNkGorI2wH4wWqzCq1wgDTz2fYX7Advt6Y4LdnRrTIAq2XRFVP8 2cHB+PEE9/XALuYwpkc0wBtunSod1cod2XeZ9TkwtGsk3GNGNd0rgdd51t6Rx8m0mjS4 2Fme26LMBOmQ7GJzRwzt6BC0k3hlifO8SBo0xk2fFWTzrme875CpSKXngXeTzZsABddx V8rg== X-Gm-Message-State: AIkVDXK1V4EyLfyWdm+dLq/Xf/ziO6llV3UZiVFYgodMt+yEsPELSzdYFvweIEw9wmV45w== X-Received: by 10.28.232.90 with SMTP id f87mr17726215wmh.35.1485871066800; Tue, 31 Jan 2017 05:57:46 -0800 (PST) Received: from lean.com (bzq-82-81-161-50.red.bezeqint.net. [82.81.161.50]) by smtp.gmail.com with ESMTPSA id y127sm23965868wmg.12.2017.01.31.05.57.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jan 2017 05:57:46 -0800 (PST) From: Nir Soffer To: qemu-devel@nongnu.org Date: Tue, 31 Jan 2017 15:57:03 +0200 Message-Id: <20170131135703.5638-3-nirsof@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170131135703.5638-1-nirsof@gmail.com> References: <20170131135703.5638-1-nirsof@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH v4 2/2] qemu-io: Add regression tests 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: kwolf@redhat.com, Nir Soffer , Nir Soffer , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Nir Soffer Add regression tests checking that qemu-io fail with non-zero exit code when reading non-existing file or using the wrong format. Signed-off-by: Nir Soffer --- tests/qemu-iotests/173 | 59 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/173.out | 9 +++++++ tests/qemu-iotests/group | 1 + 3 files changed, 69 insertions(+) create mode 100755 tests/qemu-iotests/173 create mode 100644 tests/qemu-iotests/173.out diff --git a/tests/qemu-iotests/173 b/tests/qemu-iotests/173 new file mode 100755 index 0000000..1d1fd6d --- /dev/null +++ b/tests/qemu-iotests/173 @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Test that qemu-io fail with non-zero exit code +# +# Copyright (C) 2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=nirsof@gmail.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt raw + + +size=256K +_make_test_img $size + +echo +echo "== reading wrong format should fail ==" +$QEMU_IO -f qcow2 -c "read 0 $size" "$TEST_IMG" 2>&1 | _filter_testdir +test "${PIPESTATUS[0]}" -eq 1 || _fail "did not fail" + +echo +echo "== reading missing file should fail ==" +$QEMU_IO -c "read 0 $size" "$TEST_DIR/missing" 2>&1 | _filter_testdir +test "${PIPESTATUS[0]}" -eq 1 || _fail "did not fail" + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/173.out b/tests/qemu-iotests/173.out new file mode 100644 index 0000000..47012a3 --- /dev/null +++ b/tests/qemu-iotests/173.out @@ -0,0 +1,9 @@ +QA output created by 173 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=262144 + +== reading wrong format should fail == +can't open device TEST_DIR/t.raw: Image is not in qcow2 format + +== reading missing file should fail == +can't open device TEST_DIR/missing: Could not open 'TEST_DIR/missing': No such file or directory +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 866c1a0..069a5f3 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -165,3 +165,4 @@ 170 rw auto quick 171 rw auto quick 172 auto +173 auto