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