111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2ea22b7a2SKevin Wolf# 3ea22b7a2SKevin Wolf# Test switching between read-only and read-write 4ea22b7a2SKevin Wolf# 5ea22b7a2SKevin Wolf# Copyright (C) 2017 Red Hat, Inc. 6ea22b7a2SKevin Wolf# 7ea22b7a2SKevin Wolf# This program is free software; you can redistribute it and/or modify 8ea22b7a2SKevin Wolf# it under the terms of the GNU General Public License as published by 9ea22b7a2SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10ea22b7a2SKevin Wolf# (at your option) any later version. 11ea22b7a2SKevin Wolf# 12ea22b7a2SKevin Wolf# This program is distributed in the hope that it will be useful, 13ea22b7a2SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14ea22b7a2SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15ea22b7a2SKevin Wolf# GNU General Public License for more details. 16ea22b7a2SKevin Wolf# 17ea22b7a2SKevin Wolf# You should have received a copy of the GNU General Public License 18ea22b7a2SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19ea22b7a2SKevin Wolf# 20ea22b7a2SKevin Wolf 21ea22b7a2SKevin Wolf# creator 22ea22b7a2SKevin Wolfowner=kwolf@redhat.com 23ea22b7a2SKevin Wolf 24ea22b7a2SKevin Wolfseq=`basename $0` 25ea22b7a2SKevin Wolfecho "QA output created by $seq" 26ea22b7a2SKevin Wolf 27ea22b7a2SKevin Wolfstatus=1 # failure is the default! 28ea22b7a2SKevin Wolf 29ea22b7a2SKevin Wolf_cleanup() 30ea22b7a2SKevin Wolf{ 31ea22b7a2SKevin Wolf _cleanup_test_img 32f91ecbd7SMax Reitz _rm_test_img "$TEST_IMG.2" 33f91ecbd7SMax Reitz _rm_test_img "$TEST_IMG.3" 34ea22b7a2SKevin Wolf} 35ea22b7a2SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 36ea22b7a2SKevin Wolf 37ea22b7a2SKevin Wolf# get standard environment, filters and checks 38ea22b7a2SKevin Wolf. ./common.rc 39ea22b7a2SKevin Wolf. ./common.filter 40ea22b7a2SKevin Wolf 41ea22b7a2SKevin Wolf_supported_fmt qcow2 42*57284d2aSMax Reitz_supported_proto file fuse 43ea22b7a2SKevin Wolf 44ea22b7a2SKevin Wolfsize=64M 45ea22b7a2SKevin Wolf_make_test_img $size 46ea22b7a2SKevin Wolf 47ea22b7a2SKevin Wolfecho 48ea22b7a2SKevin Wolfecho "Start from read-only" 49ea22b7a2SKevin Wolfecho 50ea22b7a2SKevin Wolf 51ea22b7a2SKevin Wolf$QEMU_IO -r -c 'write 0 64k' $TEST_IMG | _filter_qemu_io 52ea22b7a2SKevin Wolf$QEMU_IO -r -c 'reopen -w' -c 'write 0 64k' $TEST_IMG | _filter_qemu_io 53ea22b7a2SKevin Wolf$QEMU_IO -r -c 'reopen -w' -c 'reopen -r' -c 'write 0 64k' $TEST_IMG | _filter_qemu_io 54ea22b7a2SKevin Wolf 55ea22b7a2SKevin Wolfecho 56ea22b7a2SKevin Wolfecho "Start from read-write" 57ea22b7a2SKevin Wolfecho 58ea22b7a2SKevin Wolf 59ea22b7a2SKevin Wolf$QEMU_IO -c 'write 0 64k' $TEST_IMG | _filter_qemu_io 60ea22b7a2SKevin Wolf$QEMU_IO -c 'reopen -r' -c 'write 0 64k' $TEST_IMG | _filter_qemu_io 61ea22b7a2SKevin Wolf$QEMU_IO -c 'reopen -r' -c 'reopen -w' -c 'write 0 64k' $TEST_IMG | _filter_qemu_io 62ea22b7a2SKevin Wolf 63ea22b7a2SKevin Wolf 64ea22b7a2SKevin Wolf# success, all done 65ea22b7a2SKevin Wolfecho "*** done" 66ea22b7a2SKevin Wolfrm -f $seq.full 67ea22b7a2SKevin Wolfstatus=0 68