Blame SOURCES/kvm-qemu-iotests-Modern-shell-scripting-use-instead-of.patch

7711c0
From 551c981778ea501b674fb4f6ae2cb5e86d9f5354 Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Fri, 22 Mar 2019 03:22:28 +0100
7711c0
Subject: [PATCH 061/163] qemu-iotests: Modern shell scripting (use $() instead
7711c0
 of ``)
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190322032241.8111-16-jsnow@redhat.com>
7711c0
Patchwork-id: 85098
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 15/28] qemu-iotests: Modern shell scripting (use $() instead of ``)
7711c0
Bugzilla: 1691563
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
7711c0
7711c0
Various shell files contain a mix between obsolete ``
7711c0
and modern $(); It would be nice to convert to using
7711c0
$() everywhere.  For now, just do the qemu-iotests directory.
7711c0
7711c0
Cc: kwolf@redhat.com
7711c0
Cc: mreitz@redhat.com
7711c0
Cc: eblake@redhat.com
7711c0
Suggested-by: Eric Blake <eblake@redhat.com>
7711c0
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
7711c0
Message-Id: <20181024094051.4470-4-maozhongyi@cmss.chinamobile.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
[eblake: tweak commit message]
7711c0
Signed-off-by: Eric Blake <eblake@redhat.com>
7711c0
(cherry picked from commit 4a9e751f61522991c2fa94a4da8feda6a4d09c70)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 tests/qemu-iotests/check         | 60 ++++++++++++++++++++--------------------
7711c0
 tests/qemu-iotests/common.config |  4 +--
7711c0
 2 files changed, 32 insertions(+), 32 deletions(-)
7711c0
7711c0
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
7711c0
index b377132..89ed275 100755
7711c0
--- a/tests/qemu-iotests/check
7711c0
+++ b/tests/qemu-iotests/check
7711c0
@@ -80,17 +80,17 @@ _full_imgfmt_details()
7711c0
 
7711c0
 _full_platform_details()
7711c0
 {
7711c0
-    os=`uname -s`
7711c0
-    host=`hostname -s`
7711c0
-    kernel=`uname -r`
7711c0
-    platform=`uname -m`
7711c0
+    os=$(uname -s)
7711c0
+    host=$(hostname -s)
7711c0
+    kernel=$(uname -r)
7711c0
+    platform=$(uname -m)
7711c0
     echo "$os/$platform $host $kernel"
7711c0
 }
7711c0
 
7711c0
 # $1 = prog to look for
7711c0
 set_prog_path()
7711c0
 {
7711c0
-    p=`command -v $1 2> /dev/null`
7711c0
+    p=$(command -v $1 2> /dev/null)
7711c0
     if [ -n "$p" -a -x "$p" ]; then
7711c0
         type -p "$p"
7711c0
     else
7711c0
@@ -147,9 +147,9 @@ do
7711c0
     if $group
7711c0
     then
7711c0
         # arg after -g
7711c0
-        group_list=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
7711c0
+        group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
7711c0
 s/ .*//p
7711c0
-}'`
7711c0
+}')
7711c0
         if [ -z "$group_list" ]
7711c0
         then
7711c0
             echo "Group \"$r\" is empty or not defined?"
7711c0
@@ -173,9 +173,9 @@ s/ .*//p
7711c0
         # arg after -x
7711c0
         # Populate $tmp.list with all tests
7711c0
         awk '/^[0-9]{3,}/ {print $1}' "${source_iotests}/group" > $tmp.list 2>/dev/null
7711c0
-        group_list=`sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
7711c0
+        group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
7711c0
 s/ .*//p
7711c0
-}'`
7711c0
+}')
7711c0
         if [ -z "$group_list" ]
7711c0
         then
7711c0
             echo "Group \"$r\" is empty or not defined?"
7711c0
@@ -193,7 +193,7 @@ s/ .*//p
7711c0
                 rm -f $tmp.sed
7711c0
             fi
7711c0
             echo "/^$t\$/d" >>$tmp.sed
7711c0
-            numsed=`expr $numsed + 1`
7711c0
+            numsed=$(expr $numsed + 1)
7711c0
         done
7711c0
         sed -f $tmp.sed <$tmp.list >$tmp.tmp
7711c0
         mv $tmp.tmp $tmp.list
7711c0
@@ -433,12 +433,12 @@ testlist options
7711c0
             ;;
7711c0
 
7711c0
         [0-9]*-[0-9]*)
7711c0
-            eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
7711c0
+            eval $(echo $r | sed -e 's/^/start=/' -e 's/-/ end=/')
7711c0
             ;;
7711c0
 
7711c0
         [0-9]*-)
7711c0
-            eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
7711c0
-            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/.* //'`
7711c0
+            eval $(echo $r | sed -e 's/^/start=/' -e 's/-//')
7711c0
+            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/.* //')
7711c0
             if [ -z "$end" ]
7711c0
             then
7711c0
                 echo "No tests in range \"$r\"?"
7711c0
@@ -455,8 +455,8 @@ testlist options
7711c0
     esac
7711c0
 
7711c0
     # get rid of leading 0s as can be interpreted as octal
7711c0
-    start=`echo $start | sed 's/^0*//'`
7711c0
-    end=`echo $end | sed 's/^0*//'`
7711c0
+    start=$(echo $start | sed 's/^0*//')
7711c0
+    end=$(echo $end | sed 's/^0*//')
7711c0
 
7711c0
     if $xpand
7711c0
     then
7711c0
@@ -531,7 +531,7 @@ fi
7711c0
 # should be sort -n, but this did not work for Linux when this
7711c0
 # was ported from IRIX
7711c0
 #
7711c0
-list=`sort $tmp.list`
7711c0
+list=$(sort $tmp.list)
7711c0
 rm -f $tmp.list $tmp.tmp $tmp.sed
7711c0
 
7711c0
 if [ -z "$QEMU_PROG" ]
7711c0
@@ -590,7 +590,7 @@ fi
7711c0
 export QEMU_NBD_PROG="$(type -p "$QEMU_NBD_PROG")"
7711c0
 
7711c0
 if [ -z "$QEMU_VXHS_PROG" ]; then
7711c0
-  export QEMU_VXHS_PROG="`set_prog_path qnio_server`"
7711c0
+    export QEMU_VXHS_PROG="$(set_prog_path qnio_server)"
7711c0
 fi
7711c0
 
7711c0
 if [ -x "$build_iotests/socket_scm_helper" ]
7711c0
@@ -616,7 +616,7 @@ _wallclock()
7711c0
 
7711c0
 _timestamp()
7711c0
 {
7711c0
-    now=`date "+%T"`
7711c0
+    now=$(date "+%T")
7711c0
     printf %s " [$now]"
7711c0
 }
7711c0
 
7711c0
@@ -642,9 +642,9 @@ END        { if (NR > 0) {
7711c0
 
7711c0
         if [ -f $tmp.expunged ]
7711c0
         then
7711c0
-            notrun=`wc -l <$tmp.expunged | sed -e 's/  *//g'`
7711c0
-            try=`expr $try - $notrun`
7711c0
-            list=`echo "$list" | sed -f $tmp.expunged`
7711c0
+            notrun=$(wc -l <$tmp.expunged | sed -e 's/  *//g')
7711c0
+            try=$(expr $try - $notrun)
7711c0
+            list=$(echo "$list" | sed -f $tmp.expunged)
7711c0
         fi
7711c0
 
7711c0
         echo "" >>check.log
7711c0
@@ -682,8 +682,8 @@ trap "_wrapup; exit \$status" 0 1 2 3 15
7711c0
 
7711c0
 [ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE
7711c0
 
7711c0
-FULL_IMGFMT_DETAILS=`_full_imgfmt_details`
7711c0
-FULL_HOST_DETAILS=`_full_platform_details`
7711c0
+FULL_IMGFMT_DETAILS=$(_full_imgfmt_details)
7711c0
+FULL_HOST_DETAILS=$(_full_platform_details)
7711c0
 
7711c0
 cat <
7711c0
 QEMU          -- "$QEMU_PROG" $QEMU_OPTIONS
7711c0
@@ -729,7 +729,7 @@ do
7711c0
         # really going to try and run this one
7711c0
         #
7711c0
         rm -f $seq.out.bad
7711c0
-        lasttime=`sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE`
7711c0
+        lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE)
7711c0
         if [ "X$lasttime" != X ]; then
7711c0
                 printf %s " ${lasttime}s ..."
7711c0
         else
7711c0
@@ -737,7 +737,7 @@ do
7711c0
         fi
7711c0
         rm -f core $seq.notrun
7711c0
 
7711c0
-        start=`_wallclock`
7711c0
+        start=$(_wallclock)
7711c0
         $timestamp && printf %s "        [$(date "+%T")]"
7711c0
 
7711c0
         if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
7711c0
@@ -757,7 +757,7 @@ do
7711c0
         fi
7711c0
         sts=$?
7711c0
         $timestamp && _timestamp
7711c0
-        stop=`_wallclock`
7711c0
+        stop=$(_wallclock)
7711c0
 
7711c0
         if [ -f core ]
7711c0
         then
7711c0
@@ -806,7 +806,7 @@ do
7711c0
                     then
7711c0
                         :
7711c0
                     else
7711c0
-                        echo "$seq `expr $stop - $start`" >>$tmp.time
7711c0
+                        echo "$seq $(expr $stop - $start)" >>$tmp.time
7711c0
                     fi
7711c0
                 else
7711c0
                     echo " - output mismatch (see $seq.out.bad)"
7711c0
@@ -824,14 +824,14 @@ do
7711c0
     if $err
7711c0
     then
7711c0
         bad="$bad $seq"
7711c0
-        n_bad=`expr $n_bad + 1`
7711c0
+        n_bad=$(expr $n_bad + 1)
7711c0
         quick=false
7711c0
     fi
7711c0
-    [ -f $seq.notrun ] || try=`expr $try + 1`
7711c0
+    [ -f $seq.notrun ] || try=$(expr $try + 1)
7711c0
 
7711c0
     seq="after_$seq"
7711c0
 done
7711c0
 
7711c0
 interrupt=false
7711c0
-status=`expr $n_bad`
7711c0
+status=$(expr $n_bad)
7711c0
 exit
7711c0
diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
7711c0
index 3cda0fe..9f460f2 100644
7711c0
--- a/tests/qemu-iotests/common.config
7711c0
+++ b/tests/qemu-iotests/common.config
7711c0
@@ -21,8 +21,8 @@ export LANG=C
7711c0
 
7711c0
 PATH=".:$PATH"
7711c0
 
7711c0
-HOSTOS=`uname -s`
7711c0
-arch=`uname -m`
7711c0
+HOSTOS=$(uname -s)
7711c0
+arch=$(uname -m)
7711c0
 [[ "$arch" =~ "ppc64" ]] && qemu_arch=ppc64 || qemu_arch="$arch"
7711c0
 
7711c0
 # make sure we have a standard umask
7711c0
-- 
7711c0
1.8.3.1
7711c0