2019-03-07 22:58:38 +08:00
|
|
|
#!/usr/bin/env bash
|
2009-06-23 00:29:05 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2009 Red Hat, Inc.
|
|
|
|
# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it would be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2009-07-17 01:26:54 +08:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-06-23 00:29:05 +08:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# standard filters
|
|
|
|
#
|
|
|
|
|
|
|
|
_filter_date()
|
|
|
|
{
|
2019-09-17 18:43:42 +08:00
|
|
|
$SED -re 's/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/yyyy-mm-dd hh:mm:ss/'
|
|
|
|
}
|
|
|
|
|
|
|
|
_filter_vmstate_size()
|
|
|
|
{
|
|
|
|
$SED -r -e 's/[0-9. ]{5} [KMGT]iB/ SIZE/' \
|
|
|
|
-e 's/[0-9. ]{5} B/ SIZE/'
|
2009-06-23 00:29:05 +08:00
|
|
|
}
|
|
|
|
|
2015-10-13 07:36:50 +08:00
|
|
|
_filter_generated_node_ids()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -re 's/\#block[0-9]{3,}/NODE_NAME/'
|
2015-10-13 07:36:50 +08:00
|
|
|
}
|
|
|
|
|
2018-03-22 22:45:51 +08:00
|
|
|
_filter_qom_path()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e 's#\(Attached to: *\) /.*#\1 PATH#'
|
2018-03-22 22:45:51 +08:00
|
|
|
}
|
|
|
|
|
2010-11-25 00:12:21 +08:00
|
|
|
# replace occurrences of the actual TEST_DIR value with TEST_DIR
|
2009-06-23 00:29:05 +08:00
|
|
|
_filter_testdir()
|
|
|
|
{
|
2019-10-17 21:31:36 +08:00
|
|
|
$SED -e "s#$TEST_DIR/#TEST_DIR/#g" \
|
|
|
|
-e "s#$SOCK_DIR/#SOCK_DIR/#g"
|
2009-06-23 00:29:05 +08:00
|
|
|
}
|
|
|
|
|
2010-11-25 00:12:21 +08:00
|
|
|
# replace occurrences of the actual IMGFMT value with IMGFMT
|
|
|
|
_filter_imgfmt()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e "s#$IMGFMT#IMGFMT#g"
|
2010-11-25 00:12:21 +08:00
|
|
|
}
|
|
|
|
|
2016-08-10 10:43:12 +08:00
|
|
|
# Replace error message when the format is not supported and delete
|
|
|
|
# the output lines after the first one
|
|
|
|
_filter_qemu_img_check()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e '/allocated.*fragmented.*compressed clusters/d' \
|
2016-08-10 10:43:12 +08:00
|
|
|
-e 's/qemu-img: This image format does not support checks/No errors were found on the image./' \
|
|
|
|
-e '/Image end offset: [0-9]\+/d'
|
|
|
|
}
|
|
|
|
|
2011-04-29 21:30:25 +08:00
|
|
|
# Removes \r from messages
|
|
|
|
_filter_win32()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e 's/\r//g'
|
2011-04-29 21:30:25 +08:00
|
|
|
}
|
|
|
|
|
2009-06-23 00:29:05 +08:00
|
|
|
# sanitize qemu-io output
|
|
|
|
_filter_qemu_io()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
_filter_win32 | $SED -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
|
2014-12-08 17:48:11 +08:00
|
|
|
-e "s/: line [0-9][0-9]*: *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
|
2013-11-18 15:13:01 +08:00
|
|
|
-e "s/qemu-io> //g"
|
2009-06-23 00:29:05 +08:00
|
|
|
}
|
|
|
|
|
2013-04-15 16:15:17 +08:00
|
|
|
# replace occurrences of QEMU_PROG with "qemu"
|
|
|
|
_filter_qemu()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
|
2013-11-14 22:24:58 +08:00
|
|
|
-e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' \
|
|
|
|
-e $'s#\r##' # QEMU monitor uses \r\n line endings
|
2013-04-15 16:15:17 +08:00
|
|
|
}
|
|
|
|
|
2013-09-18 22:47:41 +08:00
|
|
|
# replace problematic QMP output like timestamps
|
|
|
|
_filter_qmp()
|
|
|
|
{
|
|
|
|
_filter_win32 | \
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
|
2014-11-17 20:31:05 +08:00
|
|
|
-e 's#^{"QMP":.*}$#QMP_VERSION#' \
|
|
|
|
-e '/^ "QMP": {\s*$/, /^ }\s*$/ c\' \
|
|
|
|
-e ' QMP_VERSION'
|
2013-09-18 22:47:41 +08:00
|
|
|
}
|
|
|
|
|
2017-04-14 01:19:51 +08:00
|
|
|
# readline makes HMP command strings so long that git complains
|
|
|
|
_filter_hmp()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e $'s/^\\((qemu) \\)\\?.*\e\\[D/\\1/g' \
|
2017-04-14 01:19:51 +08:00
|
|
|
-e $'s/\e\\[K//g'
|
|
|
|
}
|
|
|
|
|
2016-08-03 20:56:45 +08:00
|
|
|
# replace block job offset
|
|
|
|
_filter_block_job_offset()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
|
2016-08-03 20:56:45 +08:00
|
|
|
}
|
|
|
|
|
2017-04-20 08:54:28 +08:00
|
|
|
# replace block job len
|
|
|
|
_filter_block_job_len()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
|
2017-04-20 08:54:28 +08:00
|
|
|
}
|
|
|
|
|
2017-10-10 00:34:55 +08:00
|
|
|
# replace actual image size (depends on the host filesystem)
|
|
|
|
_filter_actual_image_size()
|
|
|
|
{
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -s 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
|
2017-10-10 00:34:55 +08:00
|
|
|
}
|
|
|
|
|
2014-08-20 01:28:58 +08:00
|
|
|
# replace driver-specific options in the "Formatting..." line
|
|
|
|
_filter_img_create()
|
|
|
|
{
|
iotests: Make _filter_img_create more active
Right now, _filter_img_create just filters out everything that looks
format-dependent, and applies some filename filters. That means that we
have to add another filter line every time some format gets a new
creation option. This can be avoided by instead discarding everything
and just keeping what we know is format-independent (format, size,
backing file, encryption information[1], preallocation) or just
interesting to have in the reference output (external data file path).
Furthermore, we probably want to sort these options. Format drivers are
not required to define them in any specific order, so the output is
effectively random (although this has never bothered us until now). We
need a specific order for our reference outputs, though. Unfortunately,
just using a plain "sort" would change a lot of existing reference
outputs, so we have to pre-filter the option keys to keep our existing
order (fmt, size, backing*, data, encryption info, preallocation).
Finally, this makes it difficult for _filter_img_create to automagically
work for QMP output. Thus, this patch adds a separate
_filter_img_create_for_qmp function that echos every line verbatim that
does not start with "Formatting", and pipes those "Formatting" lines to
_filter_img_create.
[1] Actually, the only thing that is really important is whether
encryption is enabled or not. A patch by Maxim thus removes all
other "encrypt.*" options from the output:
https://lists.nongnu.org/archive/html/qemu-block/2020-06/msg00339.html
But that patch needs to come later so we can get away with changing
as few reference outputs in this patch here as possible.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200625125548.870061-2-mreitz@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
2020-06-25 20:55:30 +08:00
|
|
|
# Split the line into the pre-options part ($filename_part, which
|
|
|
|
# precedes ", fmt=") and the options part ($options, which starts
|
|
|
|
# with "fmt=")
|
|
|
|
# (And just echo everything before the first "^Formatting")
|
|
|
|
readarray formatting_line < <($SED -e 's/, fmt=/\n/')
|
|
|
|
|
|
|
|
filename_part=''
|
|
|
|
options=''
|
|
|
|
lines=${#formatting_line[@]}
|
|
|
|
for ((i = 0; i < $lines; i++)); do
|
|
|
|
line=${formatting_line[i]}
|
|
|
|
unset formatting_line[i]
|
|
|
|
|
|
|
|
filename_part="$filename_part$line"
|
|
|
|
|
|
|
|
if echo "$line" | grep -q '^Formatting'; then
|
|
|
|
next_i=$((i + 1))
|
|
|
|
if [ -n "${formatting_line[next_i]}" ]; then
|
|
|
|
options="fmt=${formatting_line[@]}"
|
|
|
|
fi
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Set grep_data_file to '\|data_file' to keep it; make it empty
|
|
|
|
# to drop it.
|
|
|
|
# We want to drop it if it is part of the global $IMGOPTS, and we
|
|
|
|
# want to keep it otherwise (if the test specifically wants to
|
|
|
|
# test data files).
|
|
|
|
grep_data_file=(-e data_file)
|
|
|
|
if _get_data_file "$TEST_IMG" > /dev/null; then
|
|
|
|
grep_data_file=()
|
2019-11-08 00:37:08 +08:00
|
|
|
fi
|
|
|
|
|
iotests: Make _filter_img_create more active
Right now, _filter_img_create just filters out everything that looks
format-dependent, and applies some filename filters. That means that we
have to add another filter line every time some format gets a new
creation option. This can be avoided by instead discarding everything
and just keeping what we know is format-independent (format, size,
backing file, encryption information[1], preallocation) or just
interesting to have in the reference output (external data file path).
Furthermore, we probably want to sort these options. Format drivers are
not required to define them in any specific order, so the output is
effectively random (although this has never bothered us until now). We
need a specific order for our reference outputs, though. Unfortunately,
just using a plain "sort" would change a lot of existing reference
outputs, so we have to pre-filter the option keys to keep our existing
order (fmt, size, backing*, data, encryption info, preallocation).
Finally, this makes it difficult for _filter_img_create to automagically
work for QMP output. Thus, this patch adds a separate
_filter_img_create_for_qmp function that echos every line verbatim that
does not start with "Formatting", and pipes those "Formatting" lines to
_filter_img_create.
[1] Actually, the only thing that is really important is whether
encryption is enabled or not. A patch by Maxim thus removes all
other "encrypt.*" options from the output:
https://lists.nongnu.org/archive/html/qemu-block/2020-06/msg00339.html
But that patch needs to come later so we can get away with changing
as few reference outputs in this patch here as possible.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200625125548.870061-2-mreitz@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
2020-06-25 20:55:30 +08:00
|
|
|
filename_filters=(
|
2019-11-08 00:37:08 +08:00
|
|
|
-e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
|
2018-05-18 00:33:52 +08:00
|
|
|
-e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
|
2014-08-20 01:28:58 +08:00
|
|
|
-e "s#$TEST_DIR#TEST_DIR#g" \
|
2019-10-17 21:31:36 +08:00
|
|
|
-e "s#$SOCK_DIR#SOCK_DIR#g" \
|
2014-08-20 01:28:58 +08:00
|
|
|
-e "s#$IMGFMT#IMGFMT#g" \
|
2019-11-15 05:34:13 +08:00
|
|
|
-e 's#nbd:127.0.0.1:[0-9]\\+#TEST_DIR/t.IMGFMT#g' \
|
iotests: Make _filter_img_create more active
Right now, _filter_img_create just filters out everything that looks
format-dependent, and applies some filename filters. That means that we
have to add another filter line every time some format gets a new
creation option. This can be avoided by instead discarding everything
and just keeping what we know is format-independent (format, size,
backing file, encryption information[1], preallocation) or just
interesting to have in the reference output (external data file path).
Furthermore, we probably want to sort these options. Format drivers are
not required to define them in any specific order, so the output is
effectively random (although this has never bothered us until now). We
need a specific order for our reference outputs, though. Unfortunately,
just using a plain "sort" would change a lot of existing reference
outputs, so we have to pre-filter the option keys to keep our existing
order (fmt, size, backing*, data, encryption info, preallocation).
Finally, this makes it difficult for _filter_img_create to automagically
work for QMP output. Thus, this patch adds a separate
_filter_img_create_for_qmp function that echos every line verbatim that
does not start with "Formatting", and pipes those "Formatting" lines to
_filter_img_create.
[1] Actually, the only thing that is really important is whether
encryption is enabled or not. A patch by Maxim thus removes all
other "encrypt.*" options from the output:
https://lists.nongnu.org/archive/html/qemu-block/2020-06/msg00339.html
But that patch needs to come later so we can get away with changing
as few reference outputs in this patch here as possible.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200625125548.870061-2-mreitz@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
2020-06-25 20:55:30 +08:00
|
|
|
-e 's#nbd+unix:///\??socket=SOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g'
|
|
|
|
)
|
|
|
|
|
|
|
|
filename_part=$(echo "$filename_part" | $SED "${filename_filters[@]}")
|
|
|
|
|
|
|
|
# Break the option line before each option (preserving pre-existing
|
|
|
|
# line breaks by replacing them by \0 and restoring them at the end),
|
|
|
|
# then filter out the options we want to keep and sort them according
|
|
|
|
# to some order that all block drivers used at the time of writing
|
|
|
|
# this function.
|
|
|
|
options=$(
|
|
|
|
echo "$options" \
|
|
|
|
| tr '\n' '\0' \
|
|
|
|
| $SED -e 's/ \([a-z0-9_.-]*\)=/\n\1=/g' \
|
|
|
|
| grep -a -e '^fmt' -e '^size' -e '^backing' -e '^preallocation' \
|
|
|
|
-e '^encrypt' "${grep_data_file[@]}" \
|
|
|
|
| $SED "${filename_filters[@]}" \
|
|
|
|
-e 's/^\(fmt\)/0-\1/' \
|
|
|
|
-e 's/^\(size\)/1-\1/' \
|
|
|
|
-e 's/^\(backing\)/2-\1/' \
|
|
|
|
-e 's/^\(data_file\)/3-\1/' \
|
|
|
|
-e 's/^\(encryption\)/4-\1/' \
|
|
|
|
-e 's/^\(encrypt\.format\)/5-\1/' \
|
|
|
|
-e 's/^\(encrypt\.key-secret\)/6-\1/' \
|
|
|
|
-e 's/^\(encrypt\.iter-time\)/7-\1/' \
|
|
|
|
-e 's/^\(preallocation\)/8-\1/' \
|
|
|
|
| sort \
|
|
|
|
| $SED -e 's/^[0-9]-//' \
|
|
|
|
| tr '\n\0' ' \n' \
|
|
|
|
| $SED -e 's/^ *$//' -e 's/ *$//'
|
|
|
|
)
|
|
|
|
|
|
|
|
if [ -n "$options" ]; then
|
|
|
|
echo "$filename_part, $options"
|
|
|
|
elif [ -n "$filename_part" ]; then
|
|
|
|
echo "$filename_part"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Filter the "Formatting..." line in QMP output (leaving the QMP output
|
|
|
|
# untouched)
|
|
|
|
# (In contrast to _filter_img_create(), this function does not support
|
|
|
|
# multi-line Formatting output)
|
|
|
|
_filter_img_create_in_qmp()
|
|
|
|
{
|
|
|
|
while read -r line; do
|
|
|
|
if echo "$line" | grep -q '^Formatting'; then
|
|
|
|
echo "$line" | _filter_img_create
|
|
|
|
else
|
|
|
|
echo "$line"
|
|
|
|
fi
|
|
|
|
done
|
2014-08-20 01:28:58 +08:00
|
|
|
}
|
|
|
|
|
2020-05-11 21:58:22 +08:00
|
|
|
_filter_img_create_size()
|
|
|
|
{
|
|
|
|
$SED -e "s# size=[0-9]\\+# size=SIZE#g"
|
|
|
|
}
|
|
|
|
|
2014-09-10 17:05:45 +08:00
|
|
|
_filter_img_info()
|
|
|
|
{
|
2017-11-23 10:08:21 +08:00
|
|
|
if [[ "$1" == "--format-specific" ]]; then
|
|
|
|
local format_specific=1
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
local format_specific=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
discard=0
|
|
|
|
regex_json_spec_start='^ *"format-specific": \{'
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
|
2018-05-18 00:33:52 +08:00
|
|
|
-e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
|
2014-09-10 17:05:45 +08:00
|
|
|
-e "s#$TEST_DIR#TEST_DIR#g" \
|
2019-10-17 21:31:36 +08:00
|
|
|
-e "s#$SOCK_DIR#SOCK_DIR#g" \
|
2014-09-10 17:05:45 +08:00
|
|
|
-e "s#$IMGFMT#IMGFMT#g" \
|
2019-11-15 05:34:13 +08:00
|
|
|
-e 's#nbd://127.0.0.1:[0-9]\\+$#TEST_DIR/t.IMGFMT#g' \
|
|
|
|
-e 's#nbd+unix:///\??socket=SOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g' \
|
2017-04-04 11:48:09 +08:00
|
|
|
-e 's#json.*vdisk-id.*vxhs"}}#TEST_DIR/t.IMGFMT#' \
|
2014-09-10 17:05:45 +08:00
|
|
|
-e "/encrypted: yes/d" \
|
|
|
|
-e "/cluster_size: [0-9]\\+/d" \
|
|
|
|
-e "/table_size: [0-9]\\+/d" \
|
|
|
|
-e "/compat: '[^']*'/d" \
|
|
|
|
-e "/compat6: \\(on\\|off\\)/d" \
|
2018-05-15 23:36:33 +08:00
|
|
|
-e "s/cid: [0-9]\+/cid: XXXXXXXXXX/" \
|
2014-09-10 17:05:45 +08:00
|
|
|
-e "/static: \\(on\\|off\\)/d" \
|
|
|
|
-e "/zeroed_grain: \\(on\\|off\\)/d" \
|
|
|
|
-e "/subformat: '[^']*'/d" \
|
|
|
|
-e "/adapter_type: '[^']*'/d" \
|
2016-05-03 17:43:30 +08:00
|
|
|
-e "/hwversion: '[^']*'/d" \
|
2014-09-10 17:05:45 +08:00
|
|
|
-e "/lazy_refcounts: \\(on\\|off\\)/d" \
|
|
|
|
-e "/block_size: [0-9]\\+/d" \
|
|
|
|
-e "/block_state_zero: \\(on\\|off\\)/d" \
|
2017-11-17 19:29:13 +08:00
|
|
|
-e "/log_size: [0-9]\\+/d" \
|
|
|
|
-e "s/iters: [0-9]\\+/iters: 1024/" \
|
2017-11-23 10:08:21 +08:00
|
|
|
-e "s/uuid: [-a-f0-9]\\+/uuid: 00000000-0000-0000-0000-000000000000/" | \
|
|
|
|
while IFS='' read -r line; do
|
|
|
|
if [[ $format_specific == 1 ]]; then
|
|
|
|
discard=0
|
|
|
|
elif [[ $line == "Format specific information:" ]]; then
|
|
|
|
discard=1
|
|
|
|
elif [[ $line =~ $regex_json_spec_start ]]; then
|
|
|
|
discard=2
|
|
|
|
regex_json_spec_end="^${line%%[^ ]*}\\},? *$"
|
|
|
|
fi
|
|
|
|
if [[ $discard == 0 ]]; then
|
|
|
|
echo "$line"
|
|
|
|
elif [[ $discard == 1 && ! $line ]]; then
|
|
|
|
echo
|
|
|
|
discard=0
|
|
|
|
elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then
|
|
|
|
discard=0
|
|
|
|
fi
|
|
|
|
done
|
2014-09-10 17:05:45 +08:00
|
|
|
}
|
|
|
|
|
iotests: Improve _filter_qemu_img_map
Although _filter_qemu_img_map documents that it scrubs offsets, it
was only doing so for human mode. Of the existing tests using the
filter (97, 122, 150, 154, 176), two of them are affected, but it
does not hurt the validity of the tests to not require particular
mappings (another test, 66, uses offsets but intentionally does not
pass through _filter_qemu_img_map, because it checks that offsets
are unchanged before and after an operation).
Another justification for this patch is that it will allow a future
patch to utilize 'qemu-img map --output=json' to check the status of
preallocated zero clusters without regards to the mapping (since
the qcow2 mapping can be very sensitive to the chosen cluster size,
when preallocation is not in use).
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 20170507000552.20847-9-eblake@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
2017-05-07 08:05:48 +08:00
|
|
|
# filter out offsets and file names from qemu-img map; good for both
|
|
|
|
# human and json output
|
2014-10-24 21:57:41 +08:00
|
|
|
_filter_qemu_img_map()
|
|
|
|
{
|
2019-11-08 00:37:08 +08:00
|
|
|
# Assuming the data_file value in $IMGOPTS contains a '$TEST_IMG',
|
|
|
|
# create a filter that replaces the data file name by $TEST_IMG.
|
|
|
|
# Example:
|
|
|
|
# In $IMGOPTS: 'data_file=$TEST_IMG.data_file'
|
|
|
|
# Then data_file_pattern == '\(.*\).data_file'
|
|
|
|
# And data_file_filter == -e 's#\(.*\).data_file#\1#
|
|
|
|
data_file_filter=()
|
|
|
|
if data_file_pattern=$(_get_data_file '\\(.*\\)'); then
|
|
|
|
data_file_filter=(-e "s#$data_file_pattern#\\1#")
|
|
|
|
fi
|
|
|
|
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
|
iotests: Improve _filter_qemu_img_map
Although _filter_qemu_img_map documents that it scrubs offsets, it
was only doing so for human mode. Of the existing tests using the
filter (97, 122, 150, 154, 176), two of them are affected, but it
does not hurt the validity of the tests to not require particular
mappings (another test, 66, uses offsets but intentionally does not
pass through _filter_qemu_img_map, because it checks that offsets
are unchanged before and after an operation).
Another justification for this patch is that it will allow a future
patch to utilize 'qemu-img map --output=json' to check the status of
preallocated zero clusters without regards to the mapping (since
the qcow2 mapping can be very sensitive to the chosen cluster size,
when preallocation is not in use).
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 20170507000552.20847-9-eblake@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
2017-05-07 08:05:48 +08:00
|
|
|
-e 's/"offset": [0-9]\+/"offset": OFFSET/g' \
|
2019-11-08 00:37:08 +08:00
|
|
|
-e 's/Mapped to *//' \
|
|
|
|
"${data_file_filter[@]}" \
|
|
|
|
| _filter_testdir | _filter_imgfmt
|
2014-10-24 21:57:41 +08:00
|
|
|
}
|
|
|
|
|
2016-01-26 02:41:11 +08:00
|
|
|
_filter_nbd()
|
|
|
|
{
|
|
|
|
# nbd.c error messages contain function names and line numbers that are
|
|
|
|
# prone to change. Message ordering depends on timing between send and
|
|
|
|
# receive callbacks sometimes, making them unreliable.
|
|
|
|
#
|
|
|
|
# Filter out the TCP port number since this changes between runs.
|
2019-03-07 22:58:39 +08:00
|
|
|
$SED -e '/nbd\/.*\.c:/d' \
|
2017-08-29 20:27:45 +08:00
|
|
|
-e 's#127\.0\.0\.1:[0-9]*#127.0.0.1:PORT#g' \
|
2019-10-17 21:31:36 +08:00
|
|
|
-e "s#?socket=$SOCK_DIR#?socket=SOCK_DIR#g" \
|
2017-08-29 20:27:45 +08:00
|
|
|
-e 's#\(foo\|PORT/\?\|.sock\): Failed to .*$#\1#'
|
2016-01-26 02:41:11 +08:00
|
|
|
}
|
|
|
|
|
2019-08-10 02:52:53 +08:00
|
|
|
_filter_qmp_empty_return()
|
|
|
|
{
|
|
|
|
grep -v '{"return": {}}'
|
|
|
|
}
|
|
|
|
|
2019-11-08 00:36:50 +08:00
|
|
|
_filter_json_filename()
|
|
|
|
{
|
|
|
|
$PYTHON -c 'import sys
|
|
|
|
result, *fnames = sys.stdin.read().split("json:{")
|
|
|
|
depth = 0
|
|
|
|
for fname in fnames:
|
|
|
|
depth += 1 # For the opening brace in the split separator
|
|
|
|
for chr_i, chr in enumerate(fname):
|
|
|
|
if chr == "{":
|
|
|
|
depth += 1
|
|
|
|
elif chr == "}":
|
|
|
|
depth -= 1
|
|
|
|
if depth == 0:
|
|
|
|
break
|
|
|
|
|
|
|
|
# json:{} filenames may be nested; filter out everything from
|
|
|
|
# inside the outermost one
|
|
|
|
if depth == 0:
|
|
|
|
chr_i += 1 # First character past the filename
|
|
|
|
result += "json:{ /* filtered */ }" + fname[chr_i:]
|
|
|
|
|
|
|
|
sys.stdout.write(result)'
|
|
|
|
}
|
|
|
|
|
2009-06-23 00:29:05 +08:00
|
|
|
# make sure this script returns success
|
2015-01-04 09:53:48 +08:00
|
|
|
true
|