#! /bin/bash RESET="\033[0m" RED="\033[0;31m" GREEN="\033[0;32m" BROWN="\033[0;33m" GPP_OPTS="-std=c++11 -O0 -ggdb" #GPP_OPTS="-std=c++11 -O2" binaries=() for src in $(find . -name \*.cpp | sort) do bin=/tmp/${src##*/}.bin sed -i 's/^\/\/ #define DEBUG 1/#define DEBUG 1/' $src echo -e "${RED}compile $GREEN${src}$RESET" && g++ $GPP_OPTS "$src" -o "$bin" || exit 1 binaries+=("$bin") done for t in "$@" do tf="./tests/$t" echo -en "$GREEN*****$RESET try $RED$t$RESET ...\n$BROWN>$RESET\n" # cat "$tf" cat "$tf.a" cat "$tf.a" | sed 's/\([0-9]\+\.[0-9]\{4\}\)[0-9]\+/\1/g' > "/tmp/$t.a" for bin in ${binaries[@]} do echo -en "$BROWN> $bin$RESET\n" cat "$tf" | "$bin" 2>"${bin}-${t}-steps" | sed 's/\([0-9]\+\.[0-9]\{4\}\)[0-9]\+/\1/g' > "${bin}-${t}-out" cmp "/tmp/$t.a" "${bin}-${t}-out" >/dev/null if [ $? -ne 0 ]; then echo -e " $BROWN$t$RESET is ${RED}KO$RESET" # cat "${bin}-${t}-out" else echo -e " $BROWN$t$RESET is ${GREEN}ok$RESET" fi done done