#! /bin/bash function do_test(){ local testname=$1 if [ $? -eq 0 ];then echo -e "${testname} test \e[92m[success]\e[0m" else echo -e "${testname} test \e[91m[fail\e[0m" fi } if [[ ! -d 'tmp' ]] then mkdir tmp fi cd testdata ../server & server_pid=$! sleep 1 cd ../tmp ../client localhost 9091 list.txt && \ diff list.txt ../testdata/list.txt do_test "normal" ../client localhost 9091 notexistfile.txt do_test "notexistfile" echo list.txt | ../client localhost 9091&& \ diff test.txt ../testdata/test.txt do_test "pipeinput" ../slowclient localhost 9091 test.txt & process_id1=$! ../p-client localhost 9091 test.txt & process_id2=$! ../p-client localhost 9091 test.txt & process_id3=$! wait $process_id1 return_code1=$? wait $process_id2 return_code2=$? wait $process_id3 return_code3=$? if [ $return_code1 -eq 0 -a $return_code2 -eq 0 -a $return_code3 -eq 0 ];then echo -e "multiconnection test \e[92m[success]\e[0m" else echo -e "multiconnection test \e[91m[fail\e[0m" fi ../client localhost 9091 -t 2 test.txt bootstrap.js react.js lorem.txt && \ diff test.txt ../testdata/test.txt && \ diff bootstrap.js ../testdata/bootstrap.js && \ diff react.js ../testdata/react.js && \ diff lorem.txt ../testdata/lorem.txt do_test "thread_normal" rm * echo turn off server :$server_pid kill $server_pid