aboutsummaryrefslogtreecommitdiff
path: root/util/run_test_suite.sh
diff options
context:
space:
mode:
authordavidhofman2021-10-08 16:44:37 +0200
committerGitHub2021-10-08 16:44:37 +0200
commit22ef8bacc8f8238cfe07f12f2fa94b45deee04b2 (patch)
tree94c8328f567344558d4bda0e4916fa20ea60dd33 /util/run_test_suite.sh
parentbd9de73be52f738b6346e5003b79114d212666bc (diff)
downloadECTester-22ef8bacc8f8238cfe07f12f2fa94b45deee04b2.tar.gz
ECTester-22ef8bacc8f8238cfe07f12f2fa94b45deee04b2.tar.zst
ECTester-22ef8bacc8f8238cfe07f12f2fa94b45deee04b2.zip
Add 2 scripts for testing libraries. Change suites to prevent error in some libraries. (#14)
* Add two scripts for testing libraries. * Fix KeyAgreement phase already executed error * Small change to the new testing script. * Fix comments in Composite suite.
Diffstat (limited to '')
-rwxr-xr-xutil/run_test_suite.sh74
1 files changed, 74 insertions, 0 deletions
diff --git a/util/run_test_suite.sh b/util/run_test_suite.sh
new file mode 100755
index 0000000..c465c79
--- /dev/null
+++ b/util/run_test_suite.sh
@@ -0,0 +1,74 @@
+#!/usr/bin/bash
+#
+# ECTesterStandalone testing script,
+# runs the specified suite on all installed libraries
+#
+suite=${1,,}
+tempfolder=.temp_results
+cur=$PWD
+timeout=10
+
+cd "$(dirname "${BASH_SOURCE[0]}")"/../dist
+if [[ $# -eq 0 ]]; then
+ echo 'No test suite specified.'
+ exit 0
+fi
+if [[ ! -f ECTesterStandalone-dist.jar ]]; then
+ echo 'ECTesterStandalone-dist.jar not found. Build ECTesterStandalone first.'
+ exit 0
+fi
+
+rm -rf $tempfolder
+mkdir $tempfolder
+run="$(which java) -jar ECTesterStandalone-dist.jar"
+libs=$($run list-libs | grep -P "^\t-" | cut -d"-" -f 2 | cut -d"(" -f1)
+while read -r lib; do
+ echo "Testing library: $lib..."
+ filename=$tempfolder/$"${lib// /_}"-${suite}_suite-results.txt
+
+ #Botan and Crypto++ don't recognize default kgt type EC, specify kgt=ECDH instead.
+ if [[ $lib == *"Botan"* ]] || [[ $lib == *"Crypto++"* ]]; then
+ args="-gt ECDH"
+ else
+ args=""
+ fi
+
+ #Wrong suite can cause a freeze in some libraries. Try running the tests again with the -skip argument if it happens. Default timeout is 10s.
+ if [[ $suite == "wrong" ]]; then
+ timeout ${timeout}s $run test $args $suite "$lib" > $filename 2>&1
+ if [[ $? -eq 124 ]]; then
+ echo "#" >> $filename
+ echo "# NOTE: Tests timeouted at this point after taking longer than ${timeout}s. What follows next is a second run with -skip argument." >> $filename
+ echo "#" >> $filename
+ $run test $args $suite -skip "$lib" >> $filename 2>&1
+ fi
+ #Composite suite can also cause a freeze, but this time there is no -skip argument.
+ elif [[ $suite == "composite" ]]; then
+ timeout ${timeout}s $run test $args $suite "$lib" > $filename 2>&1
+ if [[ $? -eq 124 ]]; then
+ echo "#" >> $filename
+ echo "# NOTE: Tests timeouted at this point after taking longer than ${timeout}s." >> $filename
+ echo "#" >> $filename
+ fi
+ #Signature suite requires SHA1withECDSA signature type
+ elif [[ $suite == "signature" ]]; then
+ $run test $args -st SHA1withECDSA $suite "$lib" > $tempfolder/$"${lib// /_}"-${suite}_suite-results.txt 2>&1
+ else
+ $run test $args $suite "$lib" > $tempfolder/$"${lib// /_}"-${suite}_suite-results.txt 2>&1
+ fi
+done <<< "$libs"
+
+#Comment out these two lines to keep java error logs. They are removed by default to prevent unnecessary cluttering of dist folder.
+echo 'Removing java error logs...'
+find . -type f -name 'hs_err_*' -exec rm {} \;
+
+if [[ -f $cur/results_$suite.zip ]]; then
+ echo 'Removing old archive...'
+ rm -f $cur/results_$suite.zip
+fi
+echo 'Creating archive...'
+zip -r -j $cur/results_$suite.zip $tempfolder/
+rm -rf $tempfolder
+
+echo "Finished. The results can be found in results_$suite.zip."
+exit 1