diff --git a/CHANGELOG b/CHANGELOG index 770a3db3f..33cc6ef60 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # Nmap Changelog ($Id$); -*-text-*- +o [Ncat] Made test-addrset.sh exit with nonzero status if any tests + fail. This in turn causes "make check" to fail if any tests fail. + [Andreas Stieger] + o Fixed compilation with --without-liblua. The bug was reported by Rick Farina, Nikos Chantziaras, and Alex Turbov. [David Fifield] diff --git a/ncat/test/test-addrset.sh b/ncat/test/test-addrset.sh index 04b1ae968..7bf31c3b3 100755 --- a/ncat/test/test-addrset.sh +++ b/ncat/test/test-addrset.sh @@ -5,6 +5,9 @@ # and checks that the output is what is expected. ADDRSET=./addrset +TESTS=0 +TEST_PASS=0 +TEST_FAIL=0 # Takes as arguments a whitespace-separated list of host specifications # and a space-separated list of expected matching addresses. Tests hosts @@ -16,13 +19,17 @@ function test_addrset() { ret=$? # Change newlines to spaces. result=$(echo $result) + let TESTS++; if [ "$ret" != "0" ]; then echo "FAIL $ADDRSET returned $ret." + let TEST_FAIL++ elif [ "$result" != "$expected" ]; then echo "FAIL \"$result\" !=" echo " \"$expected\"." + let TEST_FAIL++ else echo "PASS $specs" + let TEST_PASS++ fi } @@ -32,10 +39,13 @@ function expect_fail() { specs=$1 $ADDRSET $specs < /dev/null 2> /dev/null ret=$? + let TESTS++ if [ "$ret" == "0" ]; then echo "FAIL $ADDRSET $specs was expected to fail, but didn't." + let TEST_FAIL++ else echo "PASS $specs" + let TEST_PASS++ fi } @@ -296,3 +306,9 @@ expect_fail "FF::FF/129" # 1.2.0.3 # 1.2.3.4 # EOF + +if [ "$TEST_FAIL" -gt 0 ]; then + echo "$TEST_PASS / $TESTS passed, $TEST_FAIL failed" + exit 1 +fi +echo "$TEST_PASS / $TESTS passed"