#!/bin/bash java="/usr/lib/jvm/java-8-openjdk-amd64/bin/java" # Java #dir="$(dirname $0)/../out/production/Practical2" #samples="../../../tester/samples" #cmd="$java nl.camilstaps.cs.Main" # C dir="$(dirname $0)/../c" samples="../tester/samples" cmd="./checkout" failed=0 cd "$dir" for tc in "$samples/"*.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' | $cmd") time_end=$(($(date +%s%N)/1000000)) time=`expr $time_end - $time_start` if [ "$result" != "$answer" ]; then echo "failure ($time ms)." failed=$(($failed+1)) else echo "success ($time ms)." fi done cd - >/dev/null if [ $failed -eq 0 ]; then echo "All tests passed." elif [ $failed -eq 1 ]; then echo "1 test failed." else echo "$failed tests failed." fi