]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/encoding/check-generated.sh: run loop in the same shell
authorKefu Chai <kchai@redhat.com>
Sun, 25 Aug 2019 04:09:24 +0000 (12:09 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 27 Aug 2019 05:00:41 +0000 (13:00 +0800)
set parent scope variables in the same shell.

foo | while read ....

in the above statement, `while read ...` is executed in a subshell. so
it cannot change the bash variables in its parent shell.

in this change, the output of `foo` is redirected to the stdin of `while
read` statement. so we can capture the test failures.

before this change, the test always succeed, even if there are failures.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/test/encoding/check-generated.sh

index 55a9195db859c5c2392eeca3fbfefdf28cddd448..2726d64941adb622e5fceb322d7455f921651ab6 100755 (executable)
@@ -15,7 +15,7 @@ failed=0
 numtests=0
 echo "checking ceph-dencoder generated test instances..."
 echo "numgen type"
-ceph-dencoder list_types | while read type; do
+while read type; do
     num=`ceph-dencoder type $type count_tests`
     echo "$num $type"
     for n in `seq 1 1 $num 2>/dev/null`; do
@@ -90,7 +90,7 @@ ceph-dencoder list_types | while read type; do
 
        numtests=$(($numtests + 3))
     done
-done
+done < <(ceph-dencoder list_types)
 
 rm -f $tmp1 $tmp2 $tmp3 $tmp4