Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Mar 2021 17:36:24 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 65f4ff4e68af - main - tests/sys/netgraph/ng_macfilter_test: Fix invalid TAP output
Message-ID:  <202103121736.12CHaOkI052654@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=65f4ff4e68afc3867781dfc8cd4faf2a8be1c74f

commit 65f4ff4e68afc3867781dfc8cd4faf2a8be1c74f
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2021-03-12 17:35:24 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2021-03-12 17:35:26 +0000

    tests/sys/netgraph/ng_macfilter_test: Fix invalid TAP output
    
    This should allow the test to pass in Jenkins. Testing it locally now
    reports "passed" instead of "invalid TAP data".
    
    While touching this file also fix some shellcheck warnings that were
    pointed out by my IDE.
    
    Reviewed By:    lwhsu, afedorov
    Differential Revision: https://reviews.freebsd.org/D29054
---
 tests/sys/netgraph/ng_macfilter_test.sh | 46 ++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/tests/sys/netgraph/ng_macfilter_test.sh b/tests/sys/netgraph/ng_macfilter_test.sh
index 56e201094bcc..269de3e130aa 100755
--- a/tests/sys/netgraph/ng_macfilter_test.sh
+++ b/tests/sys/netgraph/ng_macfilter_test.sh
@@ -45,7 +45,7 @@ find_iface () {
 
 loaded_modules=''
 load_modules () {
-	for kmod in $*; do
+	for kmod in "$@"; do
 		if ! kldstat -q -m $kmod; then
 			test_comment "Loading $kmod..."
 			kldload $kmod
@@ -96,16 +96,16 @@ TSTNR=0
 TSTFAILS=0
 TSTSUCCS=0
 
-_test_next () { TSTNR=$(($TSTNR + 1)); }
-_test_succ () { TSTSUCCS=$(($TSTSUCCS + 1)); }
-_test_fail () { TSTFAILS=$(($TSTFAILS + 1)); }
+_test_next () { TSTNR=$((TSTNR + 1)); }
+_test_succ () { TSTSUCCS=$((TSTSUCCS + 1)); }
+_test_fail () { TSTFAILS=$((TSTFAILS + 1)); }
 
 test_cnt () { echo "1..${1:-$TSTNR}"; }
 test_title () {
 	local msg="$1"
 
 	printf '### %s ' "$msg"
-	printf '#%.0s' `seq $((80 - ${#msg} - 5))`
+	printf '#%.0s' $(seq $((80 - ${#msg} - 5)))
 	printf "\n"
 }
 test_comment () { echo "# $1"; }
@@ -229,7 +229,8 @@ trap 'cleanup' EXIT
 created_hooks=$(gethooks)
 rc=0
 
-test_cnt
+# Update this number when adding new tests
+test_cnt 46
 
 
 ################################################################################
@@ -244,12 +245,12 @@ test_failure "duplicate connect of default hook"
 
 ################################################################################
 test_title "Test: Add and remove hooks"
-ngctl connect MF: O2M: xxx1 many$(($HOOKS + 1))
-test_success "connect MF:xxx1 to O2M:many$(($HOOKS + 1))"
-ngctl connect MF: O2M: xxx2 many$(($HOOKS + 2))
-test_success "connect MF:xxx2 to O2M:many$(($HOOKS + 2))"
-ngctl connect MF: O2M: xxx3 many$(($HOOKS + 3))
-test_success "connect MF:xxx3 to O2M:many$(($HOOKS + 3))"
+ngctl connect MF: O2M: xxx1 many$((HOOKS + 1))
+test_success "connect MF:xxx1 to O2M:many$((HOOKS + 1))"
+ngctl connect MF: O2M: xxx2 many$((HOOKS + 2))
+test_success "connect MF:xxx2 to O2M:many$((HOOKS + 2))"
+ngctl connect MF: O2M: xxx3 many$((HOOKS + 3))
+test_success "connect MF:xxx3 to O2M:many$((HOOKS + 3))"
 hooks=$(gethooks)
 test_eq $created_hooks:xxx1:xxx2:xxx3 $hooks 'hooks after adding xxx1-3'
 
@@ -273,7 +274,7 @@ test_title "Test: Add many hooks"
 added_hooks=""
 for i in $(seq 10 1 $HOOKSADD); do
 	added_hooks="$added_hooks:xxx$i"
-	ngctl connect MF: O2M: xxx$i many$(($HOOKS + $i))
+	ngctl connect MF: O2M: xxx$i many$((HOOKS + i))
 done
 hooks=$(gethooks)
 test_eq $created_hooks$added_hooks $hooks 'hooks after adding many hooks'
@@ -291,21 +292,21 @@ test_bail_on_fail
 test_title "Test: Adding many MACs..."
 I=1
 for i in $(seq $ITERATIONS | sort -R); do
-	test_comment "Iteration $I/$iterations..."
+	test_comment "Iteration $I/$ITERATIONS..."
 	for j in $(seq 0 1 $SUBITERATIONS); do
 		test $i = 2 && edge='out2' || edge='out1'
 		ether=$(genmac $j $i)
 
 		ngctl msg MF: 'direct' "{ hookname=\"$edge\" ether=$ether }"
 	done
-	I=$(($I + 1))
+	I=$((I + 1))
 done
 
 n=$(countmacs out1)
-n2=$(( ( $ITERATIONS - 1 ) * ( $SUBITERATIONS + 1 ) ))
+n2=$(( ( ITERATIONS - 1 ) * ( SUBITERATIONS + 1 ) ))
 test_eq $n $n2 'MACs in table for out1'
 n=$(countmacs out2)
-n2=$(( 1 * ( $SUBITERATIONS + 1 ) ))
+n2=$(( 1 * ( SUBITERATIONS + 1 ) ))
 test_eq $n $n2 'MACs in table for out2'
 n=$(countmacs out3)
 n2=0
@@ -324,10 +325,10 @@ for i in $(seq $ITERATIONS); do
 done
 
 n=$(countmacs out1)
-n2=$(( ( $ITERATIONS - 1 ) * ( $SUBITERATIONS + 1 - 1 ) ))
+n2=$(( ( ITERATIONS - 1 ) * ( SUBITERATIONS + 1 - 1 ) ))
 test_eq $n $n2 'MACs in table for out1'
 n=$(countmacs out2)
-n2=$(( 1 * ( $SUBITERATIONS + 1 - 1 ) ))
+n2=$(( 1 * ( SUBITERATIONS + 1 - 1 ) ))
 test_eq $n $n2 'MACs in table for out2'
 n=$(countmacs out3)
 n2=$ITERATIONS
@@ -340,7 +341,7 @@ test_bail_on_fail
 test_title "Test: Removing all MACs one by one..."
 I=1
 for i in $(seq $ITERATIONS | sort -R); do
-	test_comment "Iteration $I/$iterations..."
+	test_comment "Iteration $I/$ITERATIONS..."
 	for j in $(seq 0 1 $SUBITERATIONS | sort -R); do
 		edge="default"
 		ether=$(genmac $j $i)
@@ -360,7 +361,7 @@ test_bail_on_fail
 test_title "Test: Randomly adding MACs on random hooks..."
 rm -f $entries_lst
 for i in $(seq $ITERATIONS); do
-	test_comment "Iteration $i/$iterations..."
+	test_comment "Iteration $i/$ITERATIONS..."
 	for j in $(seq 0 1 $SUBITERATIONS | sort -R); do
 		edge=$(randomedge)
 		ether=$(genmac $j $i)
@@ -390,7 +391,7 @@ test_bail_on_fail
 test_title "Test: Randomly changing MAC assignments..."
 rm -f $entries2_lst
 for i in $(seq $ITERATIONS); do
-	test_comment "Iteration $i/$iterations..."
+	test_comment "Iteration $i/$ITERATIONS..."
 	cat $entries_lst | while read ether edge; do
 		edge2=$(randomedge)
 
@@ -425,6 +426,5 @@ test_bail_on_fail
 
 
 ################################################################################
-test_cnt
 
 exit 0



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103121736.12CHaOkI052654>