From patchwork Sat Jan 28 02:33:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nir Soffer X-Patchwork-Id: 9542973 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 0284660429 for ; Sat, 28 Jan 2017 02:34:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7DCF26E91 for ; Sat, 28 Jan 2017 02:34:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC31627F9F; Sat, 28 Jan 2017 02:34:41 +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 2E0AA26E91 for ; Sat, 28 Jan 2017 02:34:41 +0000 (UTC) Received: from localhost ([::1]:49669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXIqe-0006eP-8S for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 Jan 2017 21:34:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXIqD-0006dX-0f for qemu-devel@nongnu.org; Fri, 27 Jan 2017 21:34:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cXIq9-0007Wv-TB for qemu-devel@nongnu.org; Fri, 27 Jan 2017 21:34:13 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33830) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cXIq9-0007Wn-N3 for qemu-devel@nongnu.org; Fri, 27 Jan 2017 21:34:09 -0500 Received: by mail-wm0-x241.google.com with SMTP id c85so62073607wmi.1 for ; Fri, 27 Jan 2017 18:34:09 -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; bh=EwJXUKrpDrTd8koWRs99bQpP0wCAmYTJKkuZC8gV/XU=; b=XuQ9rALny1WXQf/DpAdGdv7TYW5/7qfBlA0NZ0QCGUDtO5vd7+HUQfgXxIBbss37bq zGPdr40Cr6mll+eQjaxrIvvEOikMHFn8bzTbJ9s96AD63lk5M5ILMW0A66/c9H1KwyE7 lb8cYMGk5Ho6mJQRzkBiat9P6m+M/QYpEbcr+zGxMCEomt7ChC9q2ss8tHxHBp1TvVni BJIOOrR3M9ENt3hA5GIeK8m/tkxevrz4ys5dzVPlhVue2lSmeQBLEtBbbTSbSBg4jzB0 vi6V2v6bMj/HdwU2EYq0HGMXT2nEXFxQHFtNG6aAUYqnLd4hnKcLy6d40voJb/M+cZEg yHPQ== 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; bh=EwJXUKrpDrTd8koWRs99bQpP0wCAmYTJKkuZC8gV/XU=; b=Mru8IleoAspGYGlS998GLLNbgkYex0aETzKJNSIftoagzOlXSWQGtDKhvwHryOTJ89 iW6R02Zlif9QRoAKJKXyHz94ox24gmdOE/Otv6exam4gUcjjtssBdU655RHI67mycW6C RDTIpr7u3/e4Pwi5Ns1rdB4//nRtxhbCuYimtNtIscZfyB4eJ6JK3RLOysdFJa0YpPRL GsrRKioQq18mLzGy0VMJu0fbWIHZDSCkHbTYAyksEw4EWiO9hQoyb8gfjqJzL+5xw5zj L5JRKUqngadwwCEzQ9RC1+66tp4T66Iikz0GwzmnGH9R6eVdEyTRGwmbT56UvNMt51KH 516A== X-Gm-Message-State: AIkVDXIgLuQ9F/FrmZ/poK3mtAnaTtN+jf+YNcFm2ZM4mG6u57ozuGcHpAyWKyqCh0yeLg== X-Received: by 10.28.31.84 with SMTP id f81mr5621423wmf.94.1485570848650; Fri, 27 Jan 2017 18:34:08 -0800 (PST) Received: from lean.local (bzq-79-181-80-51.red.bezeqint.net. [79.181.80.51]) by smtp.gmail.com with ESMTPSA id y65sm6627626wmb.5.2017.01.27.18.34.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jan 2017 18:34:08 -0800 (PST) From: Nir Soffer To: qemu-devel@nongnu.org Date: Sat, 28 Jan 2017 04:33:06 +0200 Message-Id: <20170128023306.22011-2-nirsof@gmail.com> X-Mailer: git-send-email 2.9.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH v2 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: Kevin Wolf , Nir Soffer 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-exising file or using the wrong format. --- 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