1*6f55dfa4SMax Reitz#!/bin/bash 2*6f55dfa4SMax Reitz# 3*6f55dfa4SMax Reitz# Tests handling of colons in filenames (which may be confused with protocol 4*6f55dfa4SMax Reitz# prefixes) 5*6f55dfa4SMax Reitz# 6*6f55dfa4SMax Reitz# Copyright (C) 2017 Red Hat, Inc. 7*6f55dfa4SMax Reitz# 8*6f55dfa4SMax Reitz# This program is free software; you can redistribute it and/or modify 9*6f55dfa4SMax Reitz# it under the terms of the GNU General Public License as published by 10*6f55dfa4SMax Reitz# the Free Software Foundation; either version 2 of the License, or 11*6f55dfa4SMax Reitz# (at your option) any later version. 12*6f55dfa4SMax Reitz# 13*6f55dfa4SMax Reitz# This program is distributed in the hope that it will be useful, 14*6f55dfa4SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 15*6f55dfa4SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*6f55dfa4SMax Reitz# GNU General Public License for more details. 17*6f55dfa4SMax Reitz# 18*6f55dfa4SMax Reitz# You should have received a copy of the GNU General Public License 19*6f55dfa4SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 20*6f55dfa4SMax Reitz# 21*6f55dfa4SMax Reitz 22*6f55dfa4SMax Reitz# creator 23*6f55dfa4SMax Reitzowner=mreitz@redhat.com 24*6f55dfa4SMax Reitz 25*6f55dfa4SMax Reitzseq="$(basename $0)" 26*6f55dfa4SMax Reitzecho "QA output created by $seq" 27*6f55dfa4SMax Reitz 28*6f55dfa4SMax Reitzhere="$PWD" 29*6f55dfa4SMax Reitzstatus=1 # failure is the default! 30*6f55dfa4SMax Reitz 31*6f55dfa4SMax Reitz# get standard environment, filters and checks 32*6f55dfa4SMax Reitz. ./common.rc 33*6f55dfa4SMax Reitz. ./common.filter 34*6f55dfa4SMax Reitz 35*6f55dfa4SMax Reitz# Needs backing file support 36*6f55dfa4SMax Reitz_supported_fmt qcow qcow2 qed vmdk 37*6f55dfa4SMax Reitz# This is the default protocol (and we want to test the difference between 38*6f55dfa4SMax Reitz# colons which separate a protocol prefix from the rest and colons which are 39*6f55dfa4SMax Reitz# just part of the filename, so we cannot test protocols which require a prefix) 40*6f55dfa4SMax Reitz_supported_proto file 41*6f55dfa4SMax Reitz_supported_os Linux 42*6f55dfa4SMax Reitz 43*6f55dfa4SMax Reitzecho 44*6f55dfa4SMax Reitzecho '=== Testing plain files ===' 45*6f55dfa4SMax Reitzecho 46*6f55dfa4SMax Reitz 47*6f55dfa4SMax Reitz# A colon after a slash is not a protocol prefix separator 48*6f55dfa4SMax ReitzTEST_IMG="$TEST_DIR/a:b.$IMGFMT" _make_test_img 64M 49*6f55dfa4SMax Reitz_rm_test_img "$TEST_DIR/a:b.$IMGFMT" 50*6f55dfa4SMax Reitz 51*6f55dfa4SMax Reitz# But if you want to be really sure, you can do this 52*6f55dfa4SMax ReitzTEST_IMG="file:$TEST_DIR/a:b.$IMGFMT" _make_test_img 64M 53*6f55dfa4SMax Reitz_rm_test_img "$TEST_DIR/a:b.$IMGFMT" 54*6f55dfa4SMax Reitz 55*6f55dfa4SMax Reitz 56*6f55dfa4SMax Reitzecho 57*6f55dfa4SMax Reitzecho '=== Testing relative backing filename resolution ===' 58*6f55dfa4SMax Reitzecho 59*6f55dfa4SMax Reitz 60*6f55dfa4SMax ReitzBASE_IMG="$TEST_DIR/image:base.$IMGFMT" 61*6f55dfa4SMax ReitzTOP_IMG="$TEST_DIR/image:top.$IMGFMT" 62*6f55dfa4SMax Reitz 63*6f55dfa4SMax ReitzTEST_IMG=$BASE_IMG _make_test_img 64M 64*6f55dfa4SMax ReitzTEST_IMG=$TOP_IMG _make_test_img -b ./image:base.$IMGFMT 65*6f55dfa4SMax Reitz 66*6f55dfa4SMax Reitz# The default cluster size depends on the image format 67*6f55dfa4SMax ReitzTEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size' 68*6f55dfa4SMax Reitz 69*6f55dfa4SMax Reitz_rm_test_img "$BASE_IMG" 70*6f55dfa4SMax Reitz_rm_test_img "$TOP_IMG" 71*6f55dfa4SMax Reitz 72*6f55dfa4SMax Reitz 73*6f55dfa4SMax Reitz# Do another test where we access both top and base without any slash in them 74*6f55dfa4SMax Reitzecho 75*6f55dfa4SMax Reitzpushd "$TEST_DIR" >/dev/null 76*6f55dfa4SMax Reitz 77*6f55dfa4SMax ReitzBASE_IMG="base.$IMGFMT" 78*6f55dfa4SMax ReitzTOP_IMG="file:image:top.$IMGFMT" 79*6f55dfa4SMax Reitz 80*6f55dfa4SMax ReitzTEST_IMG=$BASE_IMG _make_test_img 64M 81*6f55dfa4SMax ReitzTEST_IMG=$TOP_IMG _make_test_img -b "$BASE_IMG" 82*6f55dfa4SMax Reitz 83*6f55dfa4SMax ReitzTEST_IMG=$TOP_IMG _img_info | grep -v 'cluster_size' 84*6f55dfa4SMax Reitz 85*6f55dfa4SMax Reitz_rm_test_img "$BASE_IMG" 86*6f55dfa4SMax Reitz_rm_test_img "image:top.$IMGFMT" 87*6f55dfa4SMax Reitz 88*6f55dfa4SMax Reitzpopd >/dev/null 89*6f55dfa4SMax Reitz 90*6f55dfa4SMax Reitz# Note that we could also do the same test with BASE_IMG=file:image:base.$IMGFMT 91*6f55dfa4SMax Reitz# -- but behavior for that case is a bit strange. Protocol-prefixed paths are 92*6f55dfa4SMax Reitz# in a sense always absolute paths, so such paths will never be combined with 93*6f55dfa4SMax Reitz# the path of the overlay. But since "image:base.$IMGFMT" is actually a 94*6f55dfa4SMax Reitz# relative path, it will always be evaluated relative to qemu's CWD (but not 95*6f55dfa4SMax Reitz# relative to the overlay!). While this is more or less intended, it is still 96*6f55dfa4SMax Reitz# pretty strange and thus not something that is tested here. 97*6f55dfa4SMax Reitz# (The root of the issue is the use of a relative path with a protocol prefix. 98*6f55dfa4SMax Reitz# This may always give you weird results because in one sense, qemu considers 99*6f55dfa4SMax Reitz# such paths absolute, whereas in another, they are still relative.) 100*6f55dfa4SMax Reitz 101*6f55dfa4SMax Reitz 102*6f55dfa4SMax Reitz# success, all done 103*6f55dfa4SMax Reitzecho '*** done' 104*6f55dfa4SMax Reitzrm -f $seq.full 105*6f55dfa4SMax Reitzstatus=0 106