add bash script for test

This commit is contained in:
ubuntu201711081 2020-12-06 06:22:56 +00:00
parent 0b148fe3f0
commit f04d3d86ea
6 changed files with 54 additions and 11 deletions

4
.gitignore vendored
View File

@ -54,10 +54,10 @@ dkms.conf
#Bin
bin/*
client_test/*
server_test/*
tmp/*
p-client
p-server
server
client
slowclient

View File

@ -23,14 +23,13 @@ p-mulclient: socket_wrapper.o p-client.c
slowclient: socket_wrapper.o client.c
$(CC) -o slowclient client.c socket_wrapper.o $(CFLAGS) -D SLOW_CLIENT=1000
.PHONY: clean moveall
.PHONY: clean test
clean:
rm *.o $(Bin)
rm $(addprefix client_test/,$(ClientBin))
rm $(addprefix server_test/,$(ServerBin))
moveall:
mv client client_test/client
mv p-client client_test/p-client
mv server server_test/server
mv p-server server_test/p-server
test:
make all
make slowclient
./test.sh

View File

@ -1,3 +0,0 @@
#! /bin/bash
cd server_test
./server

45
test.sh Executable file
View File

@ -0,0 +1,45 @@
#! /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
../client localhost 9091 test.txt
do_test "normal"
../client localhost 9091 notexistfile.txt
do_test "notexistfile"
echo test.txt | ../client localhost 9091
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
rm *.txt
echo turn off server :$server_pid
kill $server_pid

1
testdata/list.txt vendored Normal file
View File

@ -0,0 +1 @@
test.txt

1
testdata/test.txt vendored Executable file
View File

@ -0,0 +1 @@
teststring