# /usr/bin/env sh

pkill -f node.rb
#cp ./p3-zip/controller.rb ./"$1"
#cp ./p3-zip/nodes.txt ./"$1"
#cp ./p3-zip/config ./"$1"

rm -f ./console_n*

./controller nodes.txt config < public02.in

touch ./n1_t1_d1_table.dt
touch ./n1_t1_d2_table.dt
touch ./n2_t1_d2_table.dt

DIFF1=$(diff -b -B ./can_n1_t1_d1_table.out ./n1_t1_d1_table.dt)
DIFF2=$(diff -b -B ./can_n1_t1_d2_table.out ./n1_t1_d2_table.dt)
DIFF3=$(diff -b -B ./can_n2_t1_d2_table.out ./n2_t1_d2_table.dt)

if [ "$DIFF1" != "" ]
then
    echo "Node 1 / Dump 1 Routing table mismatch"
    echo "$DIFF1"
    exit 1
else
    echo "+Passed (1)"
fi


if [ "$DIFF2" != "" ]
then
    echo "Node 1 / Dump 2 Routing table mismatch"
    echo "$DIFF2"
    exit 1
else
    echo "+Passed (2)"
fi


if [ "$DIFF3" != "" ]
then
    echo "Node 2 / Dump 2 Routing table mismatch"
    echo "$DIFF3"
    exit 1
else
    echo "+Passed (3)"
fi

exit 0