From 6d81ef9443797d9174fc0849f8ec01d423754490 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sat, 5 Sep 2020 15:39:19 +1200 Subject: Handle multiple returned domains in 002-test-key-name.test This patch resolves a source of unreliability in the 002-test-key-name test. If sand-leek returned multiple "Found: " lines, then the test script would take only the first, and expect that they RSA key is for this domain. However, this isn't always true, due to the parallel nature of the program. Instead, this patch adjusts the test to capture all found domains, and assert that the domain calculated from the RSA key is one of these domains. Tested 100% reliable over 1000 repetitions. --- test/002-test-key-name.test/run.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/test/002-test-key-name.test/run.sh b/test/002-test-key-name.test/run.sh index cdd0004..aa2adca 100755 --- a/test/002-test-key-name.test/run.sh +++ b/test/002-test-key-name.test/run.sh @@ -15,9 +15,9 @@ stderr="$(mktemp)" # Four character search should be a < 1 second CPU burst for CI runner ${EXECUTABLE} -s site > $key 2>$stderr -found="$(tr '\r' '\n' < $stderr | grep Found | cut -d ' ' -f 3)" +found=($(tr '\r' '\n' < $stderr | grep Found | cut -d ' ' -f 3)) -echo "sand-leek says it found $found..." +echo "sand-leek says it found ${found[*]}..." # Trick adapted to py3 from https://swehack.org/viewtopic.php?f=37&p=6978 real="$( \ @@ -30,13 +30,16 @@ real="$( \ echo "Key analysis shows it's for ${real}" -if [ "$found" = "$real" ] ; then - echo "It's a match, I'm happy" - rm $key - rm $stderr - exit 0 -else - echo "Error: No match. Key file contents:" - cat "$key" - exit 1 -fi +for f in "${found[@]}" ; do + if [ "$f" == "$real" ] ; then + echo "Found a match, I'm happy" + rm $key + rm $stderr + exit 0 + fi +done + +# fallthrough: not found +echo "Error: No match. Key file contents:" +cat "$key" +exit 1 -- cgit v1.1