mirror of https://github.com/xemu-project/xemu.git
iotests: Filter child node information
Before we let qemu-img info print child node information, have common.filter, common.rc, and iotests.py filter it from the test output so we get as few reference output changes as possible. Signed-off-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220620162704.80987-10-hreitz@redhat.com> Tested-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
76c9e9750d
commit
bcc6777ad6
|
@ -223,6 +223,7 @@ _filter_img_info()
|
||||||
|
|
||||||
discard=0
|
discard=0
|
||||||
regex_json_spec_start='^ *"format-specific": \{'
|
regex_json_spec_start='^ *"format-specific": \{'
|
||||||
|
regex_json_child_start='^ *"children": \['
|
||||||
gsed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
|
gsed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
|
||||||
-e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
|
-e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
|
||||||
-e "s#$TEST_DIR#TEST_DIR#g" \
|
-e "s#$TEST_DIR#TEST_DIR#g" \
|
||||||
|
@ -251,20 +252,25 @@ _filter_img_info()
|
||||||
-e 's/\(compression type: \)\(zlib\|zstd\)/\1COMPRESSION_TYPE/' \
|
-e 's/\(compression type: \)\(zlib\|zstd\)/\1COMPRESSION_TYPE/' \
|
||||||
-e "s/uuid: [-a-f0-9]\\+/uuid: 00000000-0000-0000-0000-000000000000/" | \
|
-e "s/uuid: [-a-f0-9]\\+/uuid: 00000000-0000-0000-0000-000000000000/" | \
|
||||||
while IFS='' read -r line; do
|
while IFS='' read -r line; do
|
||||||
if [[ $format_specific == 1 ]]; then
|
if [[ $discard == 0 ]]; then
|
||||||
discard=0
|
if [[ $format_specific == 0 && $line == "Format specific information:" ]]; then
|
||||||
elif [[ $line == "Format specific information:" ]]; then
|
discard=1
|
||||||
discard=1
|
elif [[ $line =~ "Child node '/" ]]; then
|
||||||
elif [[ $line =~ $regex_json_spec_start ]]; then
|
discard=1
|
||||||
discard=2
|
elif [[ $line =~ $regex_json_spec_start ]]; then
|
||||||
regex_json_spec_end="^${line%%[^ ]*}\\},? *$"
|
discard=2
|
||||||
|
regex_json_end="^${line%%[^ ]*}\\},? *$"
|
||||||
|
elif [[ $line =~ $regex_json_child_start ]]; then
|
||||||
|
discard=2
|
||||||
|
regex_json_end="^${line%%[^ ]*}\\],? *$"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ $discard == 0 ]]; then
|
if [[ $discard == 0 ]]; then
|
||||||
echo "$line"
|
echo "$line"
|
||||||
elif [[ $discard == 1 && ! $line ]]; then
|
elif [[ $discard == 1 && ! $line ]]; then
|
||||||
echo
|
echo
|
||||||
discard=0
|
discard=0
|
||||||
elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then
|
elif [[ $discard == 2 && $line =~ $regex_json_end ]]; then
|
||||||
discard=0
|
discard=0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -711,6 +711,7 @@ _img_info()
|
||||||
|
|
||||||
discard=0
|
discard=0
|
||||||
regex_json_spec_start='^ *"format-specific": \{'
|
regex_json_spec_start='^ *"format-specific": \{'
|
||||||
|
regex_json_child_start='^ *"children": \['
|
||||||
$QEMU_IMG info $QEMU_IMG_EXTRA_ARGS "$@" "$TEST_IMG" 2>&1 | \
|
$QEMU_IMG info $QEMU_IMG_EXTRA_ARGS "$@" "$TEST_IMG" 2>&1 | \
|
||||||
sed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
|
sed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
|
||||||
-e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
|
-e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
|
||||||
|
@ -721,20 +722,25 @@ _img_info()
|
||||||
-e "/^disk size:/ D" \
|
-e "/^disk size:/ D" \
|
||||||
-e "/actual-size/ D" | \
|
-e "/actual-size/ D" | \
|
||||||
while IFS='' read -r line; do
|
while IFS='' read -r line; do
|
||||||
if [[ $format_specific == 1 ]]; then
|
if [[ $discard == 0 ]]; then
|
||||||
discard=0
|
if [[ $format_specific == 0 && $line == "Format specific information:" ]]; then
|
||||||
elif [[ $line == "Format specific information:" ]]; then
|
discard=1
|
||||||
discard=1
|
elif [[ $line =~ "Child node '/" ]]; then
|
||||||
elif [[ $line =~ $regex_json_spec_start ]]; then
|
discard=1
|
||||||
discard=2
|
elif [[ $format_specific == 0 && $line =~ $regex_json_spec_start ]]; then
|
||||||
regex_json_spec_end="^${line%%[^ ]*}\\},? *$"
|
discard=2
|
||||||
|
regex_json_end="^${line%%[^ ]*}\\},? *$"
|
||||||
|
elif [[ $line =~ $regex_json_child_start ]]; then
|
||||||
|
discard=2
|
||||||
|
regex_json_end="^${line%%[^ ]*}\\],? *$"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ $discard == 0 ]]; then
|
if [[ $discard == 0 ]]; then
|
||||||
echo "$line"
|
echo "$line"
|
||||||
elif [[ $discard == 1 && ! $line ]]; then
|
elif [[ $discard == 1 && ! $line ]]; then
|
||||||
echo
|
echo
|
||||||
discard=0
|
discard=0
|
||||||
elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then
|
elif [[ $discard == 2 && $line =~ $regex_json_end ]]; then
|
||||||
discard=0
|
discard=0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -329,7 +329,7 @@ def qemu_img_log(*args: str, check: bool = True
|
||||||
|
|
||||||
def img_info_log(filename: str, filter_path: Optional[str] = None,
|
def img_info_log(filename: str, filter_path: Optional[str] = None,
|
||||||
use_image_opts: bool = False, extra_args: Sequence[str] = (),
|
use_image_opts: bool = False, extra_args: Sequence[str] = (),
|
||||||
check: bool = True,
|
check: bool = True, drop_child_info: bool = True,
|
||||||
) -> None:
|
) -> None:
|
||||||
args = ['info']
|
args = ['info']
|
||||||
if use_image_opts:
|
if use_image_opts:
|
||||||
|
@ -342,7 +342,7 @@ def img_info_log(filename: str, filter_path: Optional[str] = None,
|
||||||
output = qemu_img(*args, check=check).stdout
|
output = qemu_img(*args, check=check).stdout
|
||||||
if not filter_path:
|
if not filter_path:
|
||||||
filter_path = filename
|
filter_path = filename
|
||||||
log(filter_img_info(output, filter_path))
|
log(filter_img_info(output, filter_path, drop_child_info))
|
||||||
|
|
||||||
def qemu_io_wrap_args(args: Sequence[str]) -> List[str]:
|
def qemu_io_wrap_args(args: Sequence[str]) -> List[str]:
|
||||||
if '-f' in args or '--image-opts' in args:
|
if '-f' in args or '--image-opts' in args:
|
||||||
|
@ -642,11 +642,23 @@ def filter_qmp_virtio_scsi(qmsg):
|
||||||
def filter_generated_node_ids(msg):
|
def filter_generated_node_ids(msg):
|
||||||
return re.sub("#block[0-9]+", "NODE_NAME", msg)
|
return re.sub("#block[0-9]+", "NODE_NAME", msg)
|
||||||
|
|
||||||
def filter_img_info(output, filename):
|
def filter_img_info(output: str, filename: str,
|
||||||
|
drop_child_info: bool = True) -> str:
|
||||||
lines = []
|
lines = []
|
||||||
|
drop_indented = False
|
||||||
for line in output.split('\n'):
|
for line in output.split('\n'):
|
||||||
if 'disk size' in line or 'actual-size' in line:
|
if 'disk size' in line or 'actual-size' in line:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Drop child node info
|
||||||
|
if drop_indented:
|
||||||
|
if line.startswith(' '):
|
||||||
|
continue
|
||||||
|
drop_indented = False
|
||||||
|
if drop_child_info and "Child node '/" in line:
|
||||||
|
drop_indented = True
|
||||||
|
continue
|
||||||
|
|
||||||
line = line.replace(filename, 'TEST_IMG')
|
line = line.replace(filename, 'TEST_IMG')
|
||||||
line = filter_testfiles(line)
|
line = filter_testfiles(line)
|
||||||
line = line.replace(imgfmt, 'IMGFMT')
|
line = line.replace(imgfmt, 'IMGFMT')
|
||||||
|
|
Loading…
Reference in New Issue