HW12/test.sh

55 lines
1.3 KiB
Bash
Raw Normal View History

2020-12-06 15:22:56 +09:00
#! /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
}
cd testdata
../server &
server_pid=$!
sleep 1
cd ../tmp
2020-12-06 18:50:13 +09:00
../client localhost 9091 list.txt && \
diff list.txt ../testdata/list.txt
2020-12-06 15:22:56 +09:00
do_test "normal"
../client localhost 9091 notexistfile.txt
do_test "notexistfile"
2020-12-06 18:50:13 +09:00
echo list.txt | ../client localhost 9091&& \
diff test.txt ../testdata/test.txt
2020-12-06 15:22:56 +09:00
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
2020-12-06 18:50:13 +09:00
../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 *
2020-12-06 15:22:56 +09:00
echo turn off server :$server_pid
kill $server_pid