1*c7fc5bc2SBenoît Canet#!/bin/bash 2*c7fc5bc2SBenoît Canet# 3*c7fc5bc2SBenoît Canet# Test Quorum block driver 4*c7fc5bc2SBenoît Canet# 5*c7fc5bc2SBenoît Canet# Copyright (C) 2013 Nodalink, SARL. 6*c7fc5bc2SBenoît Canet# 7*c7fc5bc2SBenoît Canet# This program is free software; you can redistribute it and/or modify 8*c7fc5bc2SBenoît Canet# it under the terms of the GNU General Public License as published by 9*c7fc5bc2SBenoît Canet# the Free Software Foundation; either version 2 of the License, or 10*c7fc5bc2SBenoît Canet# (at your option) any later version. 11*c7fc5bc2SBenoît Canet# 12*c7fc5bc2SBenoît Canet# This program is distributed in the hope that it will be useful, 13*c7fc5bc2SBenoît Canet# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*c7fc5bc2SBenoît Canet# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*c7fc5bc2SBenoît Canet# GNU General Public License for more details. 16*c7fc5bc2SBenoît Canet# 17*c7fc5bc2SBenoît Canet# You should have received a copy of the GNU General Public License 18*c7fc5bc2SBenoît Canet# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*c7fc5bc2SBenoît Canet# 20*c7fc5bc2SBenoît Canet 21*c7fc5bc2SBenoît Canet# creator 22*c7fc5bc2SBenoît Canetowner=benoit@irqsave.net 23*c7fc5bc2SBenoît Canet 24*c7fc5bc2SBenoît Canetseq=`basename $0` 25*c7fc5bc2SBenoît Canetecho "QA output created by $seq" 26*c7fc5bc2SBenoît Canet 27*c7fc5bc2SBenoît Canethere=`pwd` 28*c7fc5bc2SBenoît Canettmp=/tmp/$$ 29*c7fc5bc2SBenoît Canetstatus=1 # failure is the default! 30*c7fc5bc2SBenoît Canet 31*c7fc5bc2SBenoît Canet_cleanup() 32*c7fc5bc2SBenoît Canet{ 33*c7fc5bc2SBenoît Canet rm -rf $TEST_DIR/1.raw 34*c7fc5bc2SBenoît Canet rm -rf $TEST_DIR/2.raw 35*c7fc5bc2SBenoît Canet rm -rf $TEST_DIR/3.raw 36*c7fc5bc2SBenoît Canet} 37*c7fc5bc2SBenoît Canettrap "_cleanup; exit \$status" 0 1 2 3 15 38*c7fc5bc2SBenoît Canet 39*c7fc5bc2SBenoît Canet# get standard environment, filters and checks 40*c7fc5bc2SBenoît Canet. ./common.rc 41*c7fc5bc2SBenoît Canet. ./common.filter 42*c7fc5bc2SBenoît Canet 43*c7fc5bc2SBenoît Canet_supported_fmt raw 44*c7fc5bc2SBenoît Canet_supported_proto generic 45*c7fc5bc2SBenoît Canet_supported_os Linux 46*c7fc5bc2SBenoît Canet 47*c7fc5bc2SBenoît Canetquorum="file.driver=quorum,file.children.0.file.filename=$TEST_DIR/1.raw" 48*c7fc5bc2SBenoît Canetquorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" 49*c7fc5bc2SBenoît Canetquorum="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw,file.vote-threshold=2" 50*c7fc5bc2SBenoît Canet 51*c7fc5bc2SBenoît Canetecho 52*c7fc5bc2SBenoît Canetecho "== creating quorum files ==" 53*c7fc5bc2SBenoît Canet 54*c7fc5bc2SBenoît Canetsize=10M 55*c7fc5bc2SBenoît Canet 56*c7fc5bc2SBenoît CanetTEST_IMG="$TEST_DIR/1.raw" _make_test_img $size 57*c7fc5bc2SBenoît CanetTEST_IMG="$TEST_DIR/2.raw" _make_test_img $size 58*c7fc5bc2SBenoît CanetTEST_IMG="$TEST_DIR/3.raw" _make_test_img $size 59*c7fc5bc2SBenoît Canet 60*c7fc5bc2SBenoît Canetecho 61*c7fc5bc2SBenoît Canetecho "== writing images ==" 62*c7fc5bc2SBenoît Canet 63*c7fc5bc2SBenoît Canet$QEMU_IO -c "open -o $quorum" -c "write -P 0x32 0 $size" | _filter_qemu_io 64*c7fc5bc2SBenoît Canet 65*c7fc5bc2SBenoît Canetecho 66*c7fc5bc2SBenoît Canetecho "== checking quorum write ==" 67*c7fc5bc2SBenoît Canet 68*c7fc5bc2SBenoît Canet$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io 69*c7fc5bc2SBenoît Canet$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io 70*c7fc5bc2SBenoît Canet$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/3.raw" | _filter_qemu_io 71*c7fc5bc2SBenoît Canet 72*c7fc5bc2SBenoît Canetecho 73*c7fc5bc2SBenoît Canetecho "== corrupting image ==" 74*c7fc5bc2SBenoît Canet 75*c7fc5bc2SBenoît Canet$QEMU_IO -c "write -P 0x42 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io 76*c7fc5bc2SBenoît Canet 77*c7fc5bc2SBenoît Canetecho 78*c7fc5bc2SBenoît Canetecho "== checking quorum correction ==" 79*c7fc5bc2SBenoît Canet 80*c7fc5bc2SBenoît Canet$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io 81*c7fc5bc2SBenoît Canet 82*c7fc5bc2SBenoît Canetecho 83*c7fc5bc2SBenoît Canetecho "== breaking quorum ==" 84*c7fc5bc2SBenoît Canet 85*c7fc5bc2SBenoît Canet$QEMU_IO -c "write -P 0x41 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io 86*c7fc5bc2SBenoît Canetecho 87*c7fc5bc2SBenoît Canetecho "== checking that quorum is broken ==" 88*c7fc5bc2SBenoît Canet 89*c7fc5bc2SBenoît Canet$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io 90*c7fc5bc2SBenoît Canet 91*c7fc5bc2SBenoît Canet 92*c7fc5bc2SBenoît Canet# success, all done 93*c7fc5bc2SBenoît Canetecho "*** done" 94*c7fc5bc2SBenoît Canetrm -f $seq.full 95*c7fc5bc2SBenoît Canetstatus=0 96