Skip to content

Instantly share code, notes, and snippets.

@JanTvrdik
Created October 23, 2011 12:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JanTvrdik/1307328 to your computer and use it in GitHub Desktop.
Save JanTvrdik/1307328 to your computer and use it in GitHub Desktop.
ProgTest test tool
#!/bin/bash
if [[ $1 = "" || $2 = "" ]]
then
echo "Chybí povinné parametry"
echo "check-io <programPath> <samplesDir>"
exit 1
fi
pg="$1"
samples="$2"
n=$(ls "$samples/"*_in.txt | wc -l);
echo "Testuji program $pg..."
echo
for((i=0;i<$n;i++)); do
fn=$(printf "%04d" $i);
in="$samples/${fn}_in.txt"
out="$samples/${fn}_out.txt"
my="$samples/${fn}_my.txt"
"$pg" < "$in" > "$my";
dos2unix --d2u "$my";
if diff -y --suppress-common-lines "$my" "$out" > /dev/null
then
echo "$fn: OK"
rm "$my"
else
echo "$fn: Chyba"
echo
echo "Vstupní data:"
echo "============="
cat "$in"
echo
echo "Rozdíl:"
echo "======="
diff -y --suppress-common-lines "$my" "$out"
echo
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment