From patchwork Mon Jan 30 11:55:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nir Soffer X-Patchwork-Id: 9545001 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 B51C760417 for ; Mon, 30 Jan 2017 12:02:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A21B26E47 for ; Mon, 30 Jan 2017 12:02:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E53B26E73; Mon, 30 Jan 2017 12:02:20 +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 DF69326E47 for ; Mon, 30 Jan 2017 12:02:19 +0000 (UTC) Received: from localhost ([::1]:59823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYAf5-00085Z-24 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 30 Jan 2017 07:02:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYAef-00084a-HQ for qemu-devel@nongnu.org; Mon, 30 Jan 2017 07:01:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYAed-00056T-Kt for qemu-devel@nongnu.org; Mon, 30 Jan 2017 07:01:53 -0500 Received: from mail-wj0-x243.google.com ([2a00:1450:400c:c01::243]:34208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cYAed-00055n-En; Mon, 30 Jan 2017 07:01:51 -0500 Received: by mail-wj0-x243.google.com with SMTP id ip10so7460098wjb.1; Mon, 30 Jan 2017 04:01:51 -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=Y7Oakci9eWxBsfi3GzVWr7mJ/LIwF7j8S3PVZCZ653OlYBDcZMffQHeszbO6hfxzRh wgfnVL0/kzJW/V2BrEXuNc6ZdEn/ORbEplTPQak9TrHx1q2ANagcQFwTzudecrpHKkOQ CsKeymheRegXasVZynI++5LvZhei/sU3tpneVWeI7i+aFIJiQIrUb2T6JPGSPf0c9cry yo72Bedhry54IQZCBYkuNoiCVS8BahwT9Hz2NY1hUDOcDZ89C1NfRh6ql7ULvE0QGSJf i1ns/aS1TSdxnYCGeVFgABlhRXwTT4mbSE15UdQJrBAUeEDPjtPAnyAvFV8HKI8p2/kS Quiw== 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=C0ZReoJu8v8vd7E2BEul20kmrSG5XtA2KBZDGoFDj5yJSRih8y8ol2zBvocGNYy6Z5 iSZg6mp4aURKPIyCjPyL+BNKp4bL+dt1o35CMpj1sgZUdgdxbjSAzVNPIJmq61uEB3hG 4GGVjPwWDWpNe6r8jL0/Axykjb6DEINAmWbq+B+TUc3UEA3ltD5rjSIdWJttlW8krXmQ Ue0eA4KAotWQkHs6ahqxb1AgjS2L4Aw56CA/OuK7hDY4VKQkvKG7P8cebT6+4KFC3mQ0 D95QPpX+oh/nPK6JdM5vr/Cgu9kKgUqZJ5m1yeYVXmMXdsqJNRwU1wCwBmtH2Ztj4gVA XL/Q== X-Gm-Message-State: AIkVDXKiQugNFDuBUWJf2k7F0qyMeMzFYpB6u2h3RdVfaG+vMsaKaBOILZrXqohD2l73jg== X-Received: by 10.223.136.155 with SMTP id f27mr17556006wrf.98.1485777710207; Mon, 30 Jan 2017 04:01:50 -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 w70sm22352738wrc.47.2017.01.30.04.01.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jan 2017 04:01:49 -0800 (PST) From: Nir Soffer To: qemu-devel@nongnu.org Date: Mon, 30 Jan 2017 13:55:50 +0200 Message-Id: <20170130115551.27254-2-nirsof@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170130115551.27254-1-nirsof@gmail.com> References: <20170130115551.27254-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:c01::243 Subject: [Qemu-devel] [PATCH v3 2/3] 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