qemu-iotests: Modern shell scripting (use $() instead of ``)

Various shell files contain a mix between obsolete ``
and modern $(); It would be nice to convert to using
$() everywhere.  For now, just do the qemu-iotests directory.

Cc: kwolf@redhat.com
Cc: mreitz@redhat.com
Cc: eblake@redhat.com
Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Message-Id: <20181024094051.4470-4-maozhongyi@cmss.chinamobile.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: tweak commit message]
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Mao Zhongyi 2018-10-24 17:40:51 +08:00 committed by Eric Blake
parent e8d81a61e1
commit 4a9e751f61
2 changed files with 32 additions and 32 deletions

View File

@ -80,17 +80,17 @@ _full_imgfmt_details()
_full_platform_details() _full_platform_details()
{ {
os=`uname -s` os=$(uname -s)
host=`hostname -s` host=$(hostname -s)
kernel=`uname -r` kernel=$(uname -r)
platform=`uname -m` platform=$(uname -m)
echo "$os/$platform $host $kernel" echo "$os/$platform $host $kernel"
} }
# $1 = prog to look for # $1 = prog to look for
set_prog_path() set_prog_path()
{ {
p=`command -v $1 2> /dev/null` p=$(command -v $1 2> /dev/null)
if [ -n "$p" -a -x "$p" ]; then if [ -n "$p" -a -x "$p" ]; then
type -p "$p" type -p "$p"
else else
@ -147,9 +147,9 @@ do
if $group if $group
then then
# arg after -g # arg after -g
group_list=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
s/ .*//p s/ .*//p
}'` }')
if [ -z "$group_list" ] if [ -z "$group_list" ]
then then
echo "Group \"$r\" is empty or not defined?" echo "Group \"$r\" is empty or not defined?"
@ -173,9 +173,9 @@ s/ .*//p
# arg after -x # arg after -x
# Populate $tmp.list with all tests # Populate $tmp.list with all tests
awk '/^[0-9]{3,}/ {print $1}' "${source_iotests}/group" > $tmp.list 2>/dev/null awk '/^[0-9]{3,}/ {print $1}' "${source_iotests}/group" > $tmp.list 2>/dev/null
group_list=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
s/ .*//p s/ .*//p
}'` }')
if [ -z "$group_list" ] if [ -z "$group_list" ]
then then
echo "Group \"$r\" is empty or not defined?" echo "Group \"$r\" is empty or not defined?"
@ -193,7 +193,7 @@ s/ .*//p
rm -f $tmp.sed rm -f $tmp.sed
fi fi
echo "/^$t\$/d" >>$tmp.sed echo "/^$t\$/d" >>$tmp.sed
numsed=`expr $numsed + 1` numsed=$(expr $numsed + 1)
done done
sed -f $tmp.sed <$tmp.list >$tmp.tmp sed -f $tmp.sed <$tmp.list >$tmp.tmp
mv $tmp.tmp $tmp.list mv $tmp.tmp $tmp.list
@ -433,12 +433,12 @@ testlist options
;; ;;
[0-9]*-[0-9]*) [0-9]*-[0-9]*)
eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'` eval $(echo $r | sed -e 's/^/start=/' -e 's/-/ end=/')
;; ;;
[0-9]*-) [0-9]*-)
eval `echo $r | sed -e 's/^/start=/' -e 's/-//'` eval $(echo $r | sed -e 's/^/start=/' -e 's/-//')
end=`echo [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //'` end=$(echo [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //')
if [ -z "$end" ] if [ -z "$end" ]
then then
echo "No tests in range \"$r\"?" echo "No tests in range \"$r\"?"
@ -455,8 +455,8 @@ testlist options
esac esac
# get rid of leading 0s as can be interpreted as octal # get rid of leading 0s as can be interpreted as octal
start=`echo $start | sed 's/^0*//'` start=$(echo $start | sed 's/^0*//')
end=`echo $end | sed 's/^0*//'` end=$(echo $end | sed 's/^0*//')
if $xpand if $xpand
then then
@ -531,7 +531,7 @@ fi
# should be sort -n, but this did not work for Linux when this # should be sort -n, but this did not work for Linux when this
# was ported from IRIX # was ported from IRIX
# #
list=`sort $tmp.list` list=$(sort $tmp.list)
rm -f $tmp.list $tmp.tmp $tmp.sed rm -f $tmp.list $tmp.tmp $tmp.sed
if [ -z "$QEMU_PROG" ] if [ -z "$QEMU_PROG" ]
@ -590,7 +590,7 @@ fi
export QEMU_NBD_PROG="$(type -p "$QEMU_NBD_PROG")" export QEMU_NBD_PROG="$(type -p "$QEMU_NBD_PROG")"
if [ -z "$QEMU_VXHS_PROG" ]; then if [ -z "$QEMU_VXHS_PROG" ]; then
export QEMU_VXHS_PROG="`set_prog_path qnio_server`" export QEMU_VXHS_PROG="$(set_prog_path qnio_server)"
fi fi
if [ -x "$build_iotests/socket_scm_helper" ] if [ -x "$build_iotests/socket_scm_helper" ]
@ -616,7 +616,7 @@ _wallclock()
_timestamp() _timestamp()
{ {
now=`date "+%T"` now=$(date "+%T")
printf %s " [$now]" printf %s " [$now]"
} }
@ -642,9 +642,9 @@ END { if (NR > 0) {
if [ -f $tmp.expunged ] if [ -f $tmp.expunged ]
then then
notrun=`wc -l <$tmp.expunged | sed -e 's/ *//g'` notrun=$(wc -l <$tmp.expunged | sed -e 's/ *//g')
try=`expr $try - $notrun` try=$(expr $try - $notrun)
list=`echo "$list" | sed -f $tmp.expunged` list=$(echo "$list" | sed -f $tmp.expunged)
fi fi
echo "" >>check.log echo "" >>check.log
@ -682,8 +682,8 @@ trap "_wrapup; exit \$status" 0 1 2 3 15
[ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE [ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE
FULL_IMGFMT_DETAILS=`_full_imgfmt_details` FULL_IMGFMT_DETAILS=$(_full_imgfmt_details)
FULL_HOST_DETAILS=`_full_platform_details` FULL_HOST_DETAILS=$(_full_platform_details)
cat <<EOF cat <<EOF
QEMU -- "$QEMU_PROG" $QEMU_OPTIONS QEMU -- "$QEMU_PROG" $QEMU_OPTIONS
@ -729,7 +729,7 @@ do
# really going to try and run this one # really going to try and run this one
# #
rm -f $seq.out.bad rm -f $seq.out.bad
lasttime=`sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE` lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE)
if [ "X$lasttime" != X ]; then if [ "X$lasttime" != X ]; then
printf %s " ${lasttime}s ..." printf %s " ${lasttime}s ..."
else else
@ -737,7 +737,7 @@ do
fi fi
rm -f core $seq.notrun rm -f core $seq.notrun
start=`_wallclock` start=$(_wallclock)
$timestamp && printf %s " [$(date "+%T")]" $timestamp && printf %s " [$(date "+%T")]"
if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
@ -757,7 +757,7 @@ do
fi fi
sts=$? sts=$?
$timestamp && _timestamp $timestamp && _timestamp
stop=`_wallclock` stop=$(_wallclock)
if [ -f core ] if [ -f core ]
then then
@ -806,7 +806,7 @@ do
then then
: :
else else
echo "$seq `expr $stop - $start`" >>$tmp.time echo "$seq $(expr $stop - $start)" >>$tmp.time
fi fi
else else
echo " - output mismatch (see $seq.out.bad)" echo " - output mismatch (see $seq.out.bad)"
@ -824,14 +824,14 @@ do
if $err if $err
then then
bad="$bad $seq" bad="$bad $seq"
n_bad=`expr $n_bad + 1` n_bad=$(expr $n_bad + 1)
quick=false quick=false
fi fi
[ -f $seq.notrun ] || try=`expr $try + 1` [ -f $seq.notrun ] || try=$(expr $try + 1)
seq="after_$seq" seq="after_$seq"
done done
interrupt=false interrupt=false
status=`expr $n_bad` status=$(expr $n_bad)
exit exit

View File

@ -21,8 +21,8 @@ export LANG=C
PATH=".:$PATH" PATH=".:$PATH"
HOSTOS=`uname -s` HOSTOS=$(uname -s)
arch=`uname -m` arch=$(uname -m)
[[ "$arch" =~ "ppc64" ]] && qemu_arch=ppc64 || qemu_arch="$arch" [[ "$arch" =~ "ppc64" ]] && qemu_arch=ppc64 || qemu_arch="$arch"
# make sure we have a standard umask # make sure we have a standard umask