From 2c5e59c1fb8064078343e1e8b8b491751bcd9245 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 25 Aug 2019 12:09:24 +0800 Subject: [PATCH] test/encoding/check-generated.sh: run loop in the same shell 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 --- src/test/encoding/check-generated.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/encoding/check-generated.sh b/src/test/encoding/check-generated.sh index 55a9195db85..2726d64941a 100755 --- a/src/test/encoding/check-generated.sh +++ b/src/test/encoding/check-generated.sh @@ -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 -- 2.39.5