From f7d5957f95d8d35e61233e846964b9b66104cb24 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 23 Jun 2022 16:55:59 +1000 Subject: [PATCH 1/2] Add missing update of status variable in rrsetorder system test (cherry picked from commit da63e63c41190cfe8f5acc021c05c58585fb6e7f) --- bin/tests/system/rrsetorder/tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/tests/system/rrsetorder/tests.sh b/bin/tests/system/rrsetorder/tests.sh index 24e63aba48..07415bd406 100644 --- a/bin/tests/system/rrsetorder/tests.sh +++ b/bin/tests/system/rrsetorder/tests.sh @@ -489,6 +489,7 @@ done echo_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status + ret)) echo_i "Checking order none (cache)" ret=0 From 7901261121c1145bf26799afb12c329c3ddb21ed Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 21 Jun 2022 12:42:21 +1000 Subject: [PATCH 2/2] Replace expr's with $((expression)) shell constucts Also make indenting consistent. (cherry picked from commit 669c42cd950da295bbfc47c93c97931b3b46344e) --- bin/tests/system/rrsetorder/tests.sh | 216 +++++++++++++-------------- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/bin/tests/system/rrsetorder/tests.sh b/bin/tests/system/rrsetorder/tests.sh index 07415bd406..b2159c6cca 100644 --- a/bin/tests/system/rrsetorder/tests.sh +++ b/bin/tests/system/rrsetorder/tests.sh @@ -40,20 +40,20 @@ if $test_fixed; then diff dig.out.fixed dig.out.fixed.good >/dev/null || ret=1 done if [ $ret != 0 ]; then echo_i "failed"; fi - status=`expr $status + $ret` + status=$((status + ret)) else echo_i "Checking order fixed behaves as cyclic when disabled (primary)" ret=0 matches=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - j=`expr $i % 4` + j=$((i % 4)) $DIGCMD @10.53.0.1 fixed.example > dig.out.fixed || ret=1 - if [ $i -le 4 ]; then - cp dig.out.fixed dig.out.$j - else - diff dig.out.fixed dig.out.$j >/dev/null && matches=`expr $matches + 1` - fi + if [ $i -le 4 ]; then + cp dig.out.fixed dig.out.$j + else + diff dig.out.fixed dig.out.$j >/dev/null && matches=$((matches + 1)) + fi done diff dig.out.0 dig.out.1 >/dev/null && ret=1 diff dig.out.0 dig.out.2 >/dev/null && ret=1 @@ -63,7 +63,7 @@ else diff dig.out.2 dig.out.3 >/dev/null && ret=1 if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi - status=`expr $status + $ret` + status=$((status + ret)) fi # @@ -74,12 +74,12 @@ ret=0 matches=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - j=`expr $i % 4` + j=$((i % 4)) $DIGCMD @10.53.0.1 cyclic.example > dig.out.cyclic || ret=1 if [ $i -le 4 ]; then - cp dig.out.cyclic dig.out.$j + cp dig.out.cyclic dig.out.$j else - diff dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1` + diff dig.out.cyclic dig.out.$j >/dev/null && matches=$((matches + 1)) fi done diff dig.out.0 dig.out.1 >/dev/null && ret=1 @@ -90,7 +90,7 @@ diff dig.out.1 dig.out.3 >/dev/null && ret=1 diff dig.out.2 dig.out.3 >/dev/null && ret=1 if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) # # @@ -100,12 +100,12 @@ ret=0 matches=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - j=`expr $i % 4` + j=$((i % 4)) $DIGCMD @10.53.0.1 cyclic2.example > dig.out.cyclic2 || ret=1 if [ $i -le 4 ]; then - cp dig.out.cyclic2 dig.out.$j + cp dig.out.cyclic2 dig.out.$j else - diff dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1` + diff dig.out.cyclic2 dig.out.$j >/dev/null && matches=$((matches + 1)) fi done diff dig.out.0 dig.out.1 >/dev/null && ret=1 @@ -116,12 +116,12 @@ diff dig.out.1 dig.out.3 >/dev/null && ret=1 diff dig.out.2 dig.out.3 >/dev/null && ret=1 if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "Checking order random (primary)" ret=0 for i in $GOOD_RANDOM do - eval match$i=0 + eval match$i=0 done for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9 do @@ -137,27 +137,27 @@ done match=0 for i in $GOOD_RANDOM do - eval "match=\`expr \$match + \$match$i\`" + eval "match=\$((match + match$i))" done echo_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" -if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi +if [ $match -lt $((GOOD_RANDOM_NO / 3)) ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "Checking order none (primary)" ret=0 # Fetch the "reference" response and ensure it contains the expected records. $DIGCMD @10.53.0.1 none.example > dig.out.none || ret=1 for i in 1 2 3 4; do - grep -F -q 1.2.3.$i dig.out.none || ret=1 + grep -F -q 1.2.3.$i dig.out.none || ret=1 done # Ensure 20 further queries result in the same response as the "reference" one. for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do - $DIGCMD @10.53.0.1 none.example > dig.out.test$i || ret=1 - diff dig.out.none dig.out.test$i >/dev/null || ret=1 + $DIGCMD @10.53.0.1 none.example > dig.out.test$i || ret=1 + diff dig.out.none dig.out.test$i >/dev/null || ret=1 done if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) # # @@ -171,7 +171,7 @@ if $test_fixed; then diff dig.out.fixed dig.out.fixed.good || ret=1 done if [ $ret != 0 ]; then echo_i "failed"; fi - status=`expr $status + $ret` + status=$((status + ret)) fi # @@ -182,12 +182,12 @@ ret=0 matches=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - j=`expr $i % 4` + j=$((i % 4)) $DIGCMD @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1 if [ $i -le 4 ]; then - cp dig.out.cyclic dig.out.$j + cp dig.out.cyclic dig.out.$j else - diff dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1` + diff dig.out.cyclic dig.out.$j >/dev/null && matches=$((matches + 1)) fi done diff dig.out.0 dig.out.1 >/dev/null && ret=1 @@ -198,7 +198,7 @@ diff dig.out.1 dig.out.3 >/dev/null && ret=1 diff dig.out.2 dig.out.3 >/dev/null && ret=1 if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) # # @@ -208,12 +208,12 @@ ret=0 matches=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - j=`expr $i % 4` + j=$((i % 4)) $DIGCMD @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1 if [ $i -le 4 ]; then - cp dig.out.cyclic2 dig.out.$j + cp dig.out.cyclic2 dig.out.$j else - diff dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1` + diff dig.out.cyclic2 dig.out.$j >/dev/null && matches=$((matches + 1)) fi done diff dig.out.0 dig.out.1 >/dev/null && ret=1 @@ -224,13 +224,13 @@ diff dig.out.1 dig.out.3 >/dev/null && ret=1 diff dig.out.2 dig.out.3 >/dev/null && ret=1 if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "Checking order random (secondary)" ret=0 for i in $GOOD_RANDOM do - eval match$i=0 + eval match$i=0 done for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9 do @@ -246,27 +246,27 @@ done match=0 for i in $GOOD_RANDOM do -eval "match=\`expr \$match + \$match$i\`" + eval "match=\$((match + match$i))" done echo_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" -if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi +if [ $match -lt $((GOOD_RANDOM_NO / 3)) ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "Checking order none (secondary)" ret=0 # Fetch the "reference" response and ensure it contains the expected records. $DIGCMD @10.53.0.2 none.example > dig.out.none || ret=1 for i in 1 2 3 4; do - grep -F -q 1.2.3.$i dig.out.none || ret=1 + grep -F -q 1.2.3.$i dig.out.none || ret=1 done # Ensure 20 further queries result in the same response as the "reference" one. for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do - $DIGCMD @10.53.0.2 none.example > dig.out.test$i || ret=1 - diff dig.out.none dig.out.test$i >/dev/null || ret=1 + $DIGCMD @10.53.0.2 none.example > dig.out.test$i || ret=1 + diff dig.out.none dig.out.test$i >/dev/null || ret=1 done if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "Shutting down secondary" @@ -276,8 +276,8 @@ echo_i "Checking for secondary's on disk copy of zone" if [ ! -f ns2/root.bk ] then - echo_i "failed"; - status=`expr $status + 1` + echo_i "failed"; + status=$((status + 1)) fi echo_i "Re-starting secondary" @@ -296,7 +296,7 @@ if $test_fixed; then diff dig.out.fixed dig.out.fixed.good || ret=1 done if [ $ret != 0 ]; then echo_i "failed"; fi - status=`expr $status + $ret` + status=$((status + ret)) fi # @@ -307,12 +307,12 @@ ret=0 matches=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - j=`expr $i % 4` + j=$((i % 4)) $DIGCMD @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1 if [ $i -le 4 ]; then - cp dig.out.cyclic dig.out.$j + cp dig.out.cyclic dig.out.$j else - diff dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1` + diff dig.out.cyclic dig.out.$j >/dev/null && matches=$((matches + 1)) fi done diff dig.out.0 dig.out.1 >/dev/null && ret=1 @@ -323,7 +323,7 @@ diff dig.out.1 dig.out.3 >/dev/null && ret=1 diff dig.out.2 dig.out.3 >/dev/null && ret=1 if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) # # @@ -333,12 +333,12 @@ ret=0 matches=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - j=`expr $i % 4` + j=$((i % 4)) $DIGCMD @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1 if [ $i -le 4 ]; then - cp dig.out.cyclic2 dig.out.$j + cp dig.out.cyclic2 dig.out.$j else - diff dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1` + diff dig.out.cyclic2 dig.out.$j >/dev/null && matches=$((matches + 1)) fi done diff dig.out.0 dig.out.1 >/dev/null && ret=1 @@ -349,49 +349,49 @@ diff dig.out.1 dig.out.3 >/dev/null && ret=1 diff dig.out.2 dig.out.3 >/dev/null && ret=1 if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "Checking order random (secondary loaded from disk)" ret=0 for i in $GOOD_RANDOM do - eval match$i=0 + eval match$i=0 done for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9 do - $DIGCMD @10.53.0.2 random.example > dig.out.random || ret=1 - match=0 - for j in $GOOD_RANDOM - do - eval "diff dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" - if [ $match -eq 1 ]; then break; fi - done - if [ $match -eq 0 ]; then ret=1; fi + $DIGCMD @10.53.0.2 random.example > dig.out.random || ret=1 + match=0 + for j in $GOOD_RANDOM + do + eval "diff dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" + if [ $match -eq 1 ]; then break; fi + done + if [ $match -eq 0 ]; then ret=1; fi done match=0 for i in $GOOD_RANDOM do -eval "match=\`expr \$match + \$match$i\`" + eval "match=\$((match + match$i))" done echo_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" -if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi +if [ $match -lt $((GOOD_RANDOM_NO / 3)) ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "Checking order none (secondary loaded from disk)" ret=0 # Fetch the "reference" response and ensure it contains the expected records. $DIGCMD @10.53.0.2 none.example > dig.out.none || ret=1 for i in 1 2 3 4; do - grep -F -q 1.2.3.$i dig.out.none || ret=1 + grep -F -q 1.2.3.$i dig.out.none || ret=1 done # Ensure 20 further queries result in the same response as the "reference" one. for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do - $DIGCMD @10.53.0.2 none.example > dig.out.test$i || ret=1 - diff dig.out.none dig.out.test$i >/dev/null || ret=1 + $DIGCMD @10.53.0.2 none.example > dig.out.test$i || ret=1 + diff dig.out.none dig.out.test$i >/dev/null || ret=1 done if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) # # @@ -405,7 +405,7 @@ if $test_fixed; then diff dig.out.fixed dig.out.fixed.good || ret=1 done if [ $ret != 0 ]; then echo_i "failed"; fi - status=`expr $status + $ret` + status=$((status + ret)) fi # @@ -418,12 +418,12 @@ $DIGCMD @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1 matches=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - j=`expr $i % 4` + j=$((i % 4)) $DIGCMD @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1 if [ $i -le 4 ]; then - cp dig.out.cyclic dig.out.$j + cp dig.out.cyclic dig.out.$j else - diff dig.out.cyclic dig.out.$j >/dev/null && matches=`expr $matches + 1` + diff dig.out.cyclic dig.out.$j >/dev/null && matches=$((matches + 1)) fi done diff dig.out.0 dig.out.1 >/dev/null && ret=1 @@ -434,7 +434,7 @@ diff dig.out.1 dig.out.3 >/dev/null && ret=1 diff dig.out.2 dig.out.3 >/dev/null && ret=1 if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) # # @@ -446,12 +446,12 @@ $DIGCMD @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1 matches=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - j=`expr $i % 4` + j=$((i % 4)) $DIGCMD @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1 if [ $i -le 4 ]; then - cp dig.out.cyclic2 dig.out.$j + cp dig.out.cyclic2 dig.out.$j else - diff dig.out.cyclic2 dig.out.$j >/dev/null && matches=`expr $matches + 1` + diff dig.out.cyclic2 dig.out.$j >/dev/null && matches=$((matches + 1)) fi done diff dig.out.0 dig.out.1 >/dev/null && ret=1 @@ -462,32 +462,32 @@ diff dig.out.1 dig.out.3 >/dev/null && ret=1 diff dig.out.2 dig.out.3 >/dev/null && ret=1 if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "Checking order random (cache)" ret=0 for i in $GOOD_RANDOM do - eval match$i=0 + eval match$i=0 done for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9 do - $DIGCMD @10.53.0.3 random.example > dig.out.random || ret=1 - match=0 - for j in $GOOD_RANDOM - do - eval "diff dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" - if [ $match -eq 1 ]; then break; fi - done - if [ $match -eq 0 ]; then ret=1; fi + $DIGCMD @10.53.0.3 random.example > dig.out.random || ret=1 + match=0 + for j in $GOOD_RANDOM + do + eval "diff dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" + if [ $match -eq 1 ]; then break; fi + done + if [ $match -eq 0 ]; then ret=1; fi done match=0 for i in $GOOD_RANDOM do -eval "match=\`expr \$match + \$match$i\`" + eval "match=\$((match + match$i))" done echo_i "Random selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" -if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi +if [ $match -lt $((GOOD_RANDOM_NO / 3)) ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) @@ -496,57 +496,57 @@ ret=0 # Fetch the "reference" response and ensure it contains the expected records. $DIGCMD @10.53.0.3 none.example > dig.out.none || ret=1 for i in 1 2 3 4; do - grep -F -q 1.2.3.$i dig.out.none || ret=1 + grep -F -q 1.2.3.$i dig.out.none || ret=1 done # Ensure 20 further queries result in the same response as the "reference" one. for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do - $DIGCMD @10.53.0.3 none.example > dig.out.test$i || ret=1 - diff dig.out.none dig.out.test$i >/dev/null || ret=1 + $DIGCMD @10.53.0.3 none.example > dig.out.test$i || ret=1 + diff dig.out.none dig.out.test$i >/dev/null || ret=1 done if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "Checking default order (cache)" ret=0 for i in $GOOD_RANDOM do - eval match$i=0 + eval match$i=0 done for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9 do - $DIGCMD @10.53.0.5 random.example > dig.out.random || ret=1 - match=0 - for j in $GOOD_RANDOM - do - eval "diff dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" - if [ $match -eq 1 ]; then break; fi - done - if [ $match -eq 0 ]; then ret=1; fi + $DIGCMD @10.53.0.5 random.example > dig.out.random || ret=1 + match=0 + for j in $GOOD_RANDOM + do + eval "diff dig.out.random dig.out.random.good$j >/dev/null && match$j=1 match=1" + if [ $match -eq 1 ]; then break; fi + done + if [ $match -eq 0 ]; then ret=1; fi done match=0 for i in $GOOD_RANDOM do -eval "match=\`expr \$match + \$match$i\`" + eval "match=\$((match + match$i))" done echo_i "Default selection return $match of ${GOOD_RANDOM_NO} possible orders in 36 samples" -if [ $match -lt `expr ${GOOD_RANDOM_NO} / 3` ]; then ret=1; fi +if [ $match -lt $((GOOD_RANDOM_NO / 3)) ]; then ret=1; fi if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "Checking default order no match in rrset-order (cache)" ret=0 # Fetch the "reference" response and ensure it contains the expected records. $DIGCMD @10.53.0.4 nomatch.example > dig.out.nomatch || ret=1 for i in 1 2 3 4; do - grep -F -q 1.2.3.$i dig.out.nomatch || ret=1 + grep -F -q 1.2.3.$i dig.out.nomatch || ret=1 done # Ensure 20 further queries result in the same response as the "reference" one. for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do - $DIGCMD @10.53.0.4 nomatch.example > dig.out.test$i || ret=1 - diff dig.out.nomatch dig.out.test$i >/dev/null || ret=1 + $DIGCMD @10.53.0.4 nomatch.example > dig.out.test$i || ret=1 + diff dig.out.nomatch dig.out.test$i >/dev/null || ret=1 done if [ $ret != 0 ]; then echo_i "failed"; fi -status=`expr $status + $ret` +status=$((status + ret)) echo_i "exit status: $status" [ $status -eq 0 ] || exit 1