aboutsummaryrefslogtreecommitdiff
path: root/Practical1/tester/test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'Practical1/tester/test.sh')
-rwxr-xr-xPractical1/tester/test.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/Practical1/tester/test.sh b/Practical1/tester/test.sh
new file mode 100755
index 0000000..a13fd63
--- /dev/null
+++ b/Practical1/tester/test.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+java="/usr/lib/jvm/java-8-openjdk-amd64/bin/java"
+
+failed=0
+
+cd "$(dirname $0)/../out/production/Practical1"
+for tc in ../../../tester/samples/cas*.in
+do
+ answer=$(cat ${tc/in/out})
+ header=$(head -n1 "$tc" | tr -d '\n')
+ echo -n "Running $(basename $tc) $(printf '%-12s' "($answer ")$(printf '%-12s' "/ $header)") ... "
+ time_start=$(($(date +%s%N)/1000000))
+ result=$(eval "cat '$tc' | /usr/lib/jvm/java-8-openjdk-amd64/bin/java nl.camilstaps.cs.GarbageCollectionHelper")
+ time_end=$(($(date +%s%N)/1000000))
+ time=`expr $time_end - $time_start`
+ if [ $result != $answer ]
+ then
+ echo "failure ($time ms)."
+ failed+=1
+ else
+ echo "success ($time ms)."
+ fi
+done
+cd -
+
+if [ $failed -eq 0 ]
+then
+ echo "All tests passed"
+else
+ echo "$failed tests failed"
+fi
+