26ba25
From 07df50ffab364f9b24a903c56b9fabce2e60f65f Mon Sep 17 00:00:00 2001
26ba25
From: Kevin Wolf <kwolf@redhat.com>
26ba25
Date: Fri, 13 Jul 2018 14:50:02 +0200
26ba25
Subject: [PATCH 218/268] iotests: add test 226 for file driver types
26ba25
26ba25
RH-Author: Kevin Wolf <kwolf@redhat.com>
26ba25
Message-id: <20180713145002.20953-3-kwolf@redhat.com>
26ba25
Patchwork-id: 81351
26ba25
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 2/2] iotests: add test 226 for file driver types
26ba25
Bugzilla: 1525829
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: Fam Zheng <famz@redhat.com>
26ba25
26ba25
From: John Snow <jsnow@redhat.com>
26ba25
26ba25
Test that we're rejecting what we ought to for file,
26ba25
host_driver and host_cdrom drivers. Test that we're
26ba25
seeing the deprecated message for block and chardevs
26ba25
on the file driver.
26ba25
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
(cherry picked from commit 2d4cb49ddaa219ed3f5a985ecf8b188aeb2b3d6b)
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 tests/qemu-iotests/226     | 66 ++++++++++++++++++++++++++++++++++++++++++++++
26ba25
 tests/qemu-iotests/226.out | 26 ++++++++++++++++++
26ba25
 tests/qemu-iotests/group   |  1 +
26ba25
 3 files changed, 93 insertions(+)
26ba25
 create mode 100755 tests/qemu-iotests/226
26ba25
 create mode 100644 tests/qemu-iotests/226.out
26ba25
26ba25
diff --git a/tests/qemu-iotests/226 b/tests/qemu-iotests/226
26ba25
new file mode 100755
26ba25
index 0000000..460aea2
26ba25
--- /dev/null
26ba25
+++ b/tests/qemu-iotests/226
26ba25
@@ -0,0 +1,66 @@
26ba25
+#!/bin/bash
26ba25
+#
26ba25
+# This test covers expected filetypes for the file, host_cdrom and
26ba25
+# host_device drivers.
26ba25
+#
26ba25
+# Copyright (C) 2018 Red Hat, Inc.
26ba25
+#
26ba25
+# This program is free software; you can redistribute it and/or modify
26ba25
+# it under the terms of the GNU General Public License as published by
26ba25
+# the Free Software Foundation; either version 2 of the License, or
26ba25
+# (at your option) any later version.
26ba25
+#
26ba25
+# This program is distributed in the hope that it will be useful,
26ba25
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26ba25
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26ba25
+# GNU General Public License for more details.
26ba25
+#
26ba25
+# You should have received a copy of the GNU General Public License
26ba25
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
26ba25
+#
26ba25
+
26ba25
+# creator
26ba25
+owner=jsnow@redhat.com
26ba25
+
26ba25
+seq=`basename $0`
26ba25
+echo "QA output created by $seq"
26ba25
+
26ba25
+here=`pwd`
26ba25
+status=1    # failure is the default!
26ba25
+
26ba25
+_cleanup()
26ba25
+{
26ba25
+    rmdir "$TEST_IMG"
26ba25
+}
26ba25
+trap "_cleanup; exit \$status" 0 1 2 3 15
26ba25
+
26ba25
+# get standard environment, filters and checks
26ba25
+. ./common.rc
26ba25
+. ./common.filter
26ba25
+. ./common.pattern
26ba25
+
26ba25
+# Generic format, but tests file-protocol specific error handling
26ba25
+_supported_fmt generic
26ba25
+_supported_proto file
26ba25
+_supported_os Linux
26ba25
+
26ba25
+# Create something decidedly not a file, blockdev or chardev...
26ba25
+mkdir "$TEST_IMG"
26ba25
+
26ba25
+for PROTO in "file" "host_device" "host_cdrom"; do
26ba25
+    echo
26ba25
+    echo "=== Testing with driver:$PROTO ==="
26ba25
+    echo
26ba25
+    echo "== Testing RO =="
26ba25
+    $QEMU_IO -c "open -r -o driver=$PROTO,filename=$TEST_IMG" 2>&1 | _filter_imgfmt | _filter_testdir
26ba25
+    $QEMU_IO -c "open -r -o driver=$PROTO,filename=/dev/null" 2>&1 | _filter_imgfmt
26ba25
+    echo "== Testing RW =="
26ba25
+    $QEMU_IO -c "open -o driver=$PROTO,filename=$TEST_IMG" 2>&1 | _filter_imgfmt | _filter_testdir
26ba25
+    $QEMU_IO -c "open -o driver=$PROTO,filename=/dev/null" 2>&1 | _filter_imgfmt
26ba25
+done
26ba25
+
26ba25
+# success, all done
26ba25
+echo
26ba25
+echo "*** done"
26ba25
+rm -f $seq.full
26ba25
+status=0
26ba25
diff --git a/tests/qemu-iotests/226.out b/tests/qemu-iotests/226.out
26ba25
new file mode 100644
26ba25
index 0000000..8c0d060
26ba25
--- /dev/null
26ba25
+++ b/tests/qemu-iotests/226.out
26ba25
@@ -0,0 +1,26 @@
26ba25
+QA output created by 226
26ba25
+
26ba25
+=== Testing with driver:file ===
26ba25
+
26ba25
+== Testing RO ==
26ba25
+can't open: A regular file was expected by the 'file' driver, but something else was given
26ba25
+warning: Opening a character device as a file using the 'file' driver is deprecated
26ba25
+== Testing RW ==
26ba25
+can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
26ba25
+warning: Opening a character device as a file using the 'file' driver is deprecated
26ba25
+
26ba25
+=== Testing with driver:host_device ===
26ba25
+
26ba25
+== Testing RO ==
26ba25
+can't open: 'host_device' driver expects either a character or block device
26ba25
+== Testing RW ==
26ba25
+can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
26ba25
+
26ba25
+=== Testing with driver:host_cdrom ===
26ba25
+
26ba25
+== Testing RO ==
26ba25
+can't open: 'host_cdrom' driver expects either a character or block device
26ba25
+== Testing RW ==
26ba25
+can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
26ba25
+
26ba25
+*** done
26ba25
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
26ba25
index 5c55adc..11498fd 100644
26ba25
--- a/tests/qemu-iotests/group
26ba25
+++ b/tests/qemu-iotests/group
26ba25
@@ -218,3 +218,4 @@
26ba25
 217 rw auto quick
26ba25
 218 rw auto quick
26ba25
 219 rw auto
26ba25
+226 auto quick
26ba25
-- 
26ba25
1.8.3.1
26ba25