1*a1cb48a3SMax Reitz#!/bin/bash 2*a1cb48a3SMax Reitz# 3*a1cb48a3SMax Reitz# Test case for qcow2 metadata cache size specification 4*a1cb48a3SMax Reitz# 5*a1cb48a3SMax Reitz# Copyright (C) 2014 Red Hat, Inc. 6*a1cb48a3SMax Reitz# 7*a1cb48a3SMax Reitz# This program is free software; you can redistribute it and/or modify 8*a1cb48a3SMax Reitz# it under the terms of the GNU General Public License as published by 9*a1cb48a3SMax Reitz# the Free Software Foundation; either version 2 of the License, or 10*a1cb48a3SMax Reitz# (at your option) any later version. 11*a1cb48a3SMax Reitz# 12*a1cb48a3SMax Reitz# This program is distributed in the hope that it will be useful, 13*a1cb48a3SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*a1cb48a3SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*a1cb48a3SMax Reitz# GNU General Public License for more details. 16*a1cb48a3SMax Reitz# 17*a1cb48a3SMax Reitz# You should have received a copy of the GNU General Public License 18*a1cb48a3SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*a1cb48a3SMax Reitz# 20*a1cb48a3SMax Reitz 21*a1cb48a3SMax Reitz# creator 22*a1cb48a3SMax Reitzowner=mreitz@redhat.com 23*a1cb48a3SMax Reitz 24*a1cb48a3SMax Reitzseq=$(basename $0) 25*a1cb48a3SMax Reitzecho "QA output created by $seq" 26*a1cb48a3SMax Reitz 27*a1cb48a3SMax Reitzhere=$PWD 28*a1cb48a3SMax Reitztmp=/tmp/$$ 29*a1cb48a3SMax Reitzstatus=1 # failure is the default! 30*a1cb48a3SMax Reitz 31*a1cb48a3SMax Reitz_cleanup() 32*a1cb48a3SMax Reitz{ 33*a1cb48a3SMax Reitz _cleanup_test_img 34*a1cb48a3SMax Reitz} 35*a1cb48a3SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 36*a1cb48a3SMax Reitz 37*a1cb48a3SMax Reitz# get standard environment, filters and checks 38*a1cb48a3SMax Reitz. ./common.rc 39*a1cb48a3SMax Reitz. ./common.filter 40*a1cb48a3SMax Reitz 41*a1cb48a3SMax Reitz_supported_fmt qcow2 42*a1cb48a3SMax Reitz_supported_proto file 43*a1cb48a3SMax Reitz_supported_os Linux 44*a1cb48a3SMax Reitz 45*a1cb48a3SMax ReitzIMG_SIZE=64K 46*a1cb48a3SMax Reitz 47*a1cb48a3SMax Reitz_make_test_img $IMG_SIZE 48*a1cb48a3SMax Reitz$QEMU_IO -c 'write -P 42 0 64k' "$TEST_IMG" | _filter_qemu_io 49*a1cb48a3SMax Reitz 50*a1cb48a3SMax Reitzecho 51*a1cb48a3SMax Reitzecho '=== Testing invalid option combinations ===' 52*a1cb48a3SMax Reitzecho 53*a1cb48a3SMax Reitz 54*a1cb48a3SMax Reitz# all sizes set at the same time 55*a1cb48a3SMax Reitz$QEMU_IO -c "open -o cache-size=1.25M,l2-cache-size=1M,refcount-cache-size=0.25M $TEST_IMG" \ 56*a1cb48a3SMax Reitz 2>&1 | _filter_testdir | _filter_imgfmt 57*a1cb48a3SMax Reitz# l2-cache-size may not exceed cache-size 58*a1cb48a3SMax Reitz$QEMU_IO -c "open -o cache-size=1M,l2-cache-size=2M $TEST_IMG" 2>&1 \ 59*a1cb48a3SMax Reitz | _filter_testdir | _filter_imgfmt 60*a1cb48a3SMax Reitz# refcount-cache-size may not exceed cache-size 61*a1cb48a3SMax Reitz$QEMU_IO -c "open -o cache-size=1M,refcount-cache-size=2M $TEST_IMG" 2>&1 \ 62*a1cb48a3SMax Reitz | _filter_testdir | _filter_imgfmt 63*a1cb48a3SMax Reitz# 0 should be a valid size (e.g. for enforcing the minimum), so this should not 64*a1cb48a3SMax Reitz# work 65*a1cb48a3SMax Reitz$QEMU_IO -c "open -o cache-size=0,l2-cache-size=0,refcount-cache-size=0 $TEST_IMG" \ 66*a1cb48a3SMax Reitz 2>&1 | _filter_testdir | _filter_imgfmt 67*a1cb48a3SMax Reitz 68*a1cb48a3SMax Reitzecho 69*a1cb48a3SMax Reitzecho '=== Testing valid option combinations ===' 70*a1cb48a3SMax Reitzecho 71*a1cb48a3SMax Reitz 72*a1cb48a3SMax Reitz# There should be a reasonable and working minimum 73*a1cb48a3SMax Reitz$QEMU_IO -c "open -o cache-size=0 $TEST_IMG" -c 'read -P 42 0 64k' \ 74*a1cb48a3SMax Reitz | _filter_qemu_io 75*a1cb48a3SMax Reitz$QEMU_IO -c "open -o l2-cache-size=0 $TEST_IMG" -c 'read -P 42 0 64k' \ 76*a1cb48a3SMax Reitz | _filter_qemu_io 77*a1cb48a3SMax Reitz$QEMU_IO -c "open -o refcount-cache-size=0 $TEST_IMG" -c 'read -P 42 0 64k' \ 78*a1cb48a3SMax Reitz | _filter_qemu_io 79*a1cb48a3SMax Reitz 80*a1cb48a3SMax Reitz# Derive cache sizes from combined size (with a reasonable ratio, but we cannot 81*a1cb48a3SMax Reitz# test that) 82*a1cb48a3SMax Reitz$QEMU_IO -c "open -o cache-size=2M $TEST_IMG" -c 'read -P 42 0 64k' \ 83*a1cb48a3SMax Reitz | _filter_qemu_io 84*a1cb48a3SMax Reitz# Fix one cache, derive the other 85*a1cb48a3SMax Reitz$QEMU_IO -c "open -o cache-size=2M,l2-cache-size=1M $TEST_IMG" \ 86*a1cb48a3SMax Reitz -c 'read -P 42 0 64k' \ 87*a1cb48a3SMax Reitz | _filter_qemu_io 88*a1cb48a3SMax Reitz$QEMU_IO -c "open -o cache-size=2M,refcount-cache-size=1M $TEST_IMG" \ 89*a1cb48a3SMax Reitz -c 'read -P 42 0 64k' \ 90*a1cb48a3SMax Reitz | _filter_qemu_io 91*a1cb48a3SMax Reitz# Directly set both caches 92*a1cb48a3SMax Reitz$QEMU_IO -c "open -o l2-cache-size=1M,refcount-cache-size=0.25M $TEST_IMG" \ 93*a1cb48a3SMax Reitz -c 'read -P 42 0 64k' \ 94*a1cb48a3SMax Reitz | _filter_qemu_io 95*a1cb48a3SMax Reitz 96*a1cb48a3SMax Reitz# success, all done 97*a1cb48a3SMax Reitzecho '*** done' 98*a1cb48a3SMax Reitzrm -f $seq.full 99*a1cb48a3SMax Reitzstatus=0 100