From 8efc8b081945d82646821602678d4cb9635a7df5 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Thu, 11 Aug 2022 06:26:43 -0600 Subject: [PATCH] Fix up other test scripts using the same logic --- scripts/ocsp-stapling.test | 13 ++++++++++++- scripts/ocsp-stapling2.test | 13 ++++++++++++- scripts/openssl_srtp.test | 13 ++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/scripts/ocsp-stapling.test b/scripts/ocsp-stapling.test index 787f7af66..075baea83 100755 --- a/scripts/ocsp-stapling.test +++ b/scripts/ocsp-stapling.test @@ -383,7 +383,18 @@ fi # need a unique port since may run the same time as testsuite generate_port() { - port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) + #-------------------------------------------------------------------------# + # Generate a random port number + #-------------------------------------------------------------------------# + + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + port=$(($(od -An -N2 /dev/urandom) % (65535-49512) + 49512)) + elif [[ "$OSTYPE" == "darwin"* ]]; then + port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) + else + echo "Unknown OS TYPE" + exit 1 + fi } # Start OpenSSL server that has no OCSP responses to return diff --git a/scripts/ocsp-stapling2.test b/scripts/ocsp-stapling2.test index 5fdc48bc6..7ede390df 100755 --- a/scripts/ocsp-stapling2.test +++ b/scripts/ocsp-stapling2.test @@ -448,7 +448,18 @@ printf '%s\n\n' "Test successfully REVOKED!" # need a unique port since may run the same time as testsuite generate_port() { - port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) + #-------------------------------------------------------------------------# + # Generate a random port number + #-------------------------------------------------------------------------# + + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + port=$(($(od -An -N2 /dev/urandom) % (65535-49512) + 49512)) + elif [[ "$OSTYPE" == "darwin"* ]]; then + port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) + else + echo "Unknown OS TYPE" + exit 1 + fi } # Start OpenSSL server that has no OCSP responses to return diff --git a/scripts/openssl_srtp.test b/scripts/openssl_srtp.test index 145eb4c56..1e47da972 100755 --- a/scripts/openssl_srtp.test +++ b/scripts/openssl_srtp.test @@ -15,7 +15,18 @@ WOLFSSL_CLIENT=${WOLFSSL_CLIENT:="./examples/client/client"} # need a unique port since may run the same time as testsuite generate_port() { - port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) + #-------------------------------------------------------------------------# + # Generate a random port number + #-------------------------------------------------------------------------# + + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + port=$(($(od -An -N2 /dev/urandom) % (65535-49512) + 49512)) + elif [[ "$OSTYPE" == "darwin"* ]]; then + port=$(($(od -An -N2 /dev/random) % (65535-49512) + 49512)) + else + echo "Unknown OS TYPE" + exit 1 + fi } # get size of key material based on the profile