tests: Fix cidr.sh, keep running despite errors
Phil Sutter
reviewercover tests: Fix cidr.sh, keep running despite errors
The first two fix cidr.sh for testing a RHEL machine's host binary. The last one is unrelated but convenient when testing systems which expectedly fail some tests.
Phil Sutter (3):
tests: cidr.sh: Respect IPSET_BIN env var
tests: cidr.sh: Fix for quirks in RHEL's ipcalc
tests: runtest.sh: Keep running, print summary of failed tests
tests/cidr.sh | 5 +++-- tests/runtest.sh | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-)
Signature · 1 line
2.47.0
Phil Sutter
reviewerPATCH 1/3 tests: cidr.sh: Respect IPSET_BIN env var
Allow callers to specify the ipset binary to test (with), just like runtest.sh itself does, too.
--- tests/cidr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/cidr.sh +1 -1
@@ -35,7 +35,7 @@ NETS="0.0.0.0/1 255.255.255.252/31 255.255.255.254/32" -ipset="../src/ipset" +ipset="${IPSET_BIN:-../src/ipset}" if which netmask >/dev/null 2>&1; then net_first_addr() {
Signature · 1 line
2.47.0
Phil Sutter
reviewerPATCH 2/3 tests: cidr.sh: Fix for quirks in RHEL's ipcalc
In reply to Phil SutterRHEL ships a special ipset[1] tool with different output in corner-cases than the common one[2]:
* Reduced output with /32 netmasks:
| # ipcalc 255.255.255.254/32 | Address: 255.255.255.254 | Address space: Reserved
To cover for this, make net_last_addr() fall back to the 'Address:' line. Simply adding this keyword is fine as in normal output it appears first and thus the other recognized keywords' values take precedence.
* No "Address:" line with all-zero addresses:
| # ipcalc 0.0.0.0/1 | Network: 0.0.0.0/1 | Netmask: 128.0.0.0 = 1 | Broadcast: 127.255.255.255 | | Address space: This host on this network | HostMin: 0.0.0.1 | HostMax: 127.255.255.254 | Hosts/Net: 2147483646
Have net_first_addr() fall back to the 'HostMin:' line in this case.
[1] https://gitlab.com/ipcalc/ipcalc
[2] http://jodies.de/ipcalc
--- tests/cidr.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/cidr.sh +2 -1
@@ -46,7 +46,7 @@ if which netmask >/dev/null 2>&1; then } elif which ipcalc >/dev/null 2>&1; then net_first_addr() { - ipcalc $1 | awk '/^Address:/{print $2}' + ipcalc $1 | awk '/^(Address|HostMin):/{print $2; exit}' } net_last_addr() { # Netmask tool prints broadcast address as last one, so
@@ -54,6 +54,7 @@ elif which ipcalc >/dev/null 2>&1; then # being recognized as special by ipcalc. ipcalc $1 | awk '/^(Hostroute|HostMax):/{out=$2} /^Broadcast:/{out=$2} + /^Address:/{out=$2} END{print out}' } else
Signature · 1 line
2.47.0
Phil Sutter
reviewerPATCH 3/3 tests: runtest.sh: Keep running, print summary of failed tests
In reply to Phil SutterDo not exit at each failure.
--- tests/runtest.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
tests/runtest.sh +9 -3
@@ -76,6 +76,7 @@ fi # Make sure the scripts are executable chmod a+x check_* *.sh +failcount=0 for types in $tests; do $ipset -X test >/dev/null 2>&1 if [ -f $types ]; then
@@ -116,7 +117,8 @@ for types in $tests; do echo "FAILED" echo "Failed test: $cmd" cat .foo.err - exit 1 + let "failcount++" + break fi # sleep 1 done < $filename
@@ -136,5 +138,9 @@ for x in $tests; do done rmmod ip_set >/dev/null 2>&1 rm -f .foo* -echo "All tests are passed" - +if [ "$failcount" -eq 0 ]; then + echo "All tests are passed" +else + echo "$failcount tests have failed" + exit 1 +fi
Signature · 1 line
2.47.0
Hi Phil,
Quoted 4 lines · Phil Sutter
The first two fix
cidr.shfor testing a RHEL machine's host binary. The last one is unrelated but convenient when testing systems which expectedly fail some tests.
Quoted 8 lines
Phil Sutter (3):
tests:cidr.sh: RespectIPSET_BINenv var
tests:cidr.sh: Fix for quirks in RHEL's ipcalc
tests:runtest.sh: Keep running, print summary of failed teststests/cidr.sh | 5 +++-- tests/runtest.sh | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-)
Thanks! All patches are applied in the ipset git tree. A new release is coming soon.
Best regards,
Jozsef
Signature · 3 lines
E-mail : [email protected], [email protected], [email protected] Address: Wigner Research Centre for Physics H-1525 Budapest 114, POB. 49, Hungary