# /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

#echo "Console N1: "
#cat ./console_n1

#echo "Console N4: "
#cat ./console_n4

#echo "Console N4: "
#cat ./console_n4

#echo "Console N4: "
#cat ./console_n4


#echo "Table N1-D1: "
#cat ./n1_t1_d1_table.dt

#echo "Table N1-D2: "
#cat ./n1_t1_d2_table.dt

#echo "Table N2-D2: "
#cat ./n2_t1_d2_table.dt


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

DIFF1=$(diff ./can_n1_t1_d1_table.out ./n1_t1_d1_table.dt)
DIFF2=$(diff ./can_n1_t1_d2_table.out ./n1_t1_d2_table.dt)
DIFF3=$(diff ./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