111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 26f55dfa4SMax Reitz# 36f55dfa4SMax Reitz# Tests handling of colons in filenames (which may be confused with protocol 46f55dfa4SMax Reitz# prefixes) 56f55dfa4SMax Reitz# 66f55dfa4SMax Reitz# Copyright (C) 2017 Red Hat, Inc. 76f55dfa4SMax Reitz# 86f55dfa4SMax Reitz# This program is free software; you can redistribute it and/or modify 96f55dfa4SMax Reitz# it under the terms of the GNU General Public License as published by 106f55dfa4SMax Reitz# the Free Software Foundation; either version 2 of the License, or 116f55dfa4SMax Reitz# (at your option) any later version. 126f55dfa4SMax Reitz# 136f55dfa4SMax Reitz# This program is distributed in the hope that it will be useful, 146f55dfa4SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 156f55dfa4SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 166f55dfa4SMax Reitz# GNU General Public License for more details. 176f55dfa4SMax Reitz# 186f55dfa4SMax Reitz# You should have received a copy of the GNU General Public License 196f55dfa4SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 206f55dfa4SMax Reitz# 216f55dfa4SMax Reitz 226f55dfa4SMax Reitz# creator 236f55dfa4SMax Reitzowner=mreitz@redhat.com 246f55dfa4SMax Reitz 256f55dfa4SMax Reitzseq="$(basename $0)" 266f55dfa4SMax Reitzecho "QA output created by $seq" 276f55dfa4SMax Reitz 286f55dfa4SMax Reitzstatus=1 # failure is the default! 296f55dfa4SMax Reitz 306f55dfa4SMax Reitz# get standard environment, filters and checks 316f55dfa4SMax Reitz. ./common.rc 326f55dfa4SMax Reitz. ./common.filter 336f55dfa4SMax Reitz 346f55dfa4SMax Reitz# Needs backing file support 356f55dfa4SMax Reitz_supported_fmt qcow qcow2 qed vmdk 36*39af39c4SMax Reitz_unsupported_imgopts "subformat=monolithicFlat" \ 37*39af39c4SMax Reitz "subformat=twoGbMaxExtentFlat" 386f55dfa4SMax Reitz# This is the default protocol (and we want to test the difference between 396f55dfa4SMax Reitz# colons which separate a protocol prefix from the rest and colons which are 406f55dfa4SMax Reitz# just part of the filename, so we cannot test protocols which require a prefix) 416f55dfa4SMax Reitz_supported_proto file 426f55dfa4SMax Reitz 436f55dfa4SMax Reitzecho 446f55dfa4SMax Reitzecho '=== Testing plain files ===' 456f55dfa4SMax Reitzecho 466f55dfa4SMax Reitz 476f55dfa4SMax Reitz# A colon after a slash is not a protocol prefix separator 486f55dfa4SMax ReitzTEST_IMG="$TEST_DIR/a:b.$IMGFMT" _make_test_img 64M 496f55dfa4SMax Reitz_rm_test_img "$TEST_DIR/a:b.$IMGFMT" 506f55dfa4SMax Reitz 516f55dfa4SMax Reitz# But if you want to be really sure, you can do this 526f55dfa4SMax ReitzTEST_IMG="file:$TEST_DIR/a:b.$IMGFMT" _make_test_img 64M 536f55dfa4SMax Reitz_rm_test_img "$TEST_DIR/a:b.$IMGFMT" 546f55dfa4SMax Reitz 556f55dfa4SMax Reitz 566f55dfa4SMax Reitzecho 576f55dfa4SMax Reitzecho '=== Testing relative backing filename resolution ===' 586f55dfa4SMax Reitzecho 596f55dfa4SMax Reitz 606f55dfa4SMax ReitzBASE_IMG="$TEST_DIR/image:base.$IMGFMT" 616f55dfa4SMax ReitzTOP_IMG="$TEST_DIR/image:top.$IMGFMT" 626f55dfa4SMax Reitz 636f55dfa4SMax ReitzTEST_IMG=$BASE_IMG _make_test_img 64M 646f55dfa4SMax ReitzTEST_IMG=$TOP_IMG _make_test_img -b ./image:base.$IMGFMT 656f55dfa4SMax Reitz 661278dce7SMax Reitz# (1) The default cluster size depends on the image format 671278dce7SMax Reitz# (2) vmdk only supports vmdk backing files, so it always reports the 681278dce7SMax Reitz# format of its backing file as such (but neither it nor qcow 691278dce7SMax Reitz# support the backing_fmt creation option, so we cannot use that to 701278dce7SMax Reitz# harmonize the output across all image formats this test supports) 711278dce7SMax ReitzTEST_IMG=$TOP_IMG _img_info | grep -ve 'cluster_size' -e 'backing file format' 726f55dfa4SMax Reitz 736f55dfa4SMax Reitz_rm_test_img "$BASE_IMG" 746f55dfa4SMax Reitz_rm_test_img "$TOP_IMG" 756f55dfa4SMax Reitz 766f55dfa4SMax Reitz 776f55dfa4SMax Reitz# Do another test where we access both top and base without any slash in them 786f55dfa4SMax Reitzecho 796f55dfa4SMax Reitzpushd "$TEST_DIR" >/dev/null 806f55dfa4SMax Reitz 816f55dfa4SMax ReitzBASE_IMG="base.$IMGFMT" 826f55dfa4SMax ReitzTOP_IMG="file:image:top.$IMGFMT" 836f55dfa4SMax Reitz 846f55dfa4SMax ReitzTEST_IMG=$BASE_IMG _make_test_img 64M 856f55dfa4SMax ReitzTEST_IMG=$TOP_IMG _make_test_img -b "$BASE_IMG" 866f55dfa4SMax Reitz 871278dce7SMax ReitzTEST_IMG=$TOP_IMG _img_info | grep -ve 'cluster_size' -e 'backing file format' 886f55dfa4SMax Reitz 896f55dfa4SMax Reitz_rm_test_img "$BASE_IMG" 906f55dfa4SMax Reitz_rm_test_img "image:top.$IMGFMT" 916f55dfa4SMax Reitz 926f55dfa4SMax Reitzpopd >/dev/null 936f55dfa4SMax Reitz 946f55dfa4SMax Reitz# Note that we could also do the same test with BASE_IMG=file:image:base.$IMGFMT 956f55dfa4SMax Reitz# -- but behavior for that case is a bit strange. Protocol-prefixed paths are 966f55dfa4SMax Reitz# in a sense always absolute paths, so such paths will never be combined with 976f55dfa4SMax Reitz# the path of the overlay. But since "image:base.$IMGFMT" is actually a 986f55dfa4SMax Reitz# relative path, it will always be evaluated relative to qemu's CWD (but not 996f55dfa4SMax Reitz# relative to the overlay!). While this is more or less intended, it is still 1006f55dfa4SMax Reitz# pretty strange and thus not something that is tested here. 1016f55dfa4SMax Reitz# (The root of the issue is the use of a relative path with a protocol prefix. 1026f55dfa4SMax Reitz# This may always give you weird results because in one sense, qemu considers 1036f55dfa4SMax Reitz# such paths absolute, whereas in another, they are still relative.) 1046f55dfa4SMax Reitz 1056f55dfa4SMax Reitz 1066f55dfa4SMax Reitz# success, all done 1076f55dfa4SMax Reitzecho '*** done' 1086f55dfa4SMax Reitzrm -f $seq.full 1096f55dfa4SMax Reitzstatus=0 110