diff --git a/Docker/OpenWrt/runTests.sh b/Docker/OpenWrt/runTests.sh index 1585da5d9a1..9dbdee441f8 100755 --- a/Docker/OpenWrt/runTests.sh +++ b/Docker/OpenWrt/runTests.sh @@ -1,14 +1,19 @@ #!/bin/sh -runCMD() { # usage: runCMD "" "" +runCMD() { # usage: runCMD "" "[ ...]" TMP_FILE=$(mktemp) - eval $1 > $TMP_FILE 2>&1 + eval $1 > "$TMP_FILE" 2>&1 RETVAL=$? - if [ "$RETVAL" != "$2" ]; then - echo "Command ($1) returned ${RETVAL}, but expected $2. Error output:" - cat $TMP_FILE - exit 1 - fi + case " $2 " in + *" $RETVAL "*) + rm -f "$TMP_FILE" + return 0 + ;; + esac + echo "Command ($1) returned ${RETVAL}, but expected one of: $2. Error output:" + cat "$TMP_FILE" + rm -f "$TMP_FILE" + exit 1 } # Successful tests @@ -21,7 +26,7 @@ runCMD "uclient-fetch 'https://letsencrypt.org'" 0 # Negative tests runCMD "uclient-fetch --ca-certificate=/dev/null 'https://letsencrypt.org'" 5 runCMD "uclient-fetch 'https://self-signed.badssl.com/'" 5 -runCMD "uclient-fetch 'https://untrusted-root.badssl.com/'" 5 +runCMD "uclient-fetch 'https://untrusted-root.badssl.com/'" "4 5" runCMD "uclient-fetch 'https://expired.badssl.com/'" 5 echo "All tests passed."