add bash script for test
This commit is contained in:
parent
0b148fe3f0
commit
f04d3d86ea
4
.gitignore
vendored
4
.gitignore
vendored
@ -54,10 +54,10 @@ dkms.conf
|
|||||||
|
|
||||||
#Bin
|
#Bin
|
||||||
bin/*
|
bin/*
|
||||||
client_test/*
|
tmp/*
|
||||||
server_test/*
|
|
||||||
|
|
||||||
p-client
|
p-client
|
||||||
p-server
|
p-server
|
||||||
server
|
server
|
||||||
client
|
client
|
||||||
|
slowclient
|
11
Makefile
11
Makefile
@ -23,14 +23,13 @@ p-mulclient: socket_wrapper.o p-client.c
|
|||||||
slowclient: socket_wrapper.o client.c
|
slowclient: socket_wrapper.o client.c
|
||||||
$(CC) -o slowclient client.c socket_wrapper.o $(CFLAGS) -D SLOW_CLIENT=1000
|
$(CC) -o slowclient client.c socket_wrapper.o $(CFLAGS) -D SLOW_CLIENT=1000
|
||||||
|
|
||||||
.PHONY: clean moveall
|
.PHONY: clean test
|
||||||
clean:
|
clean:
|
||||||
rm *.o $(Bin)
|
rm *.o $(Bin)
|
||||||
rm $(addprefix client_test/,$(ClientBin))
|
rm $(addprefix client_test/,$(ClientBin))
|
||||||
rm $(addprefix server_test/,$(ServerBin))
|
rm $(addprefix server_test/,$(ServerBin))
|
||||||
|
|
||||||
moveall:
|
test:
|
||||||
mv client client_test/client
|
make all
|
||||||
mv p-client client_test/p-client
|
make slowclient
|
||||||
mv server server_test/server
|
./test.sh
|
||||||
mv p-server server_test/p-server
|
|
45
test.sh
Executable file
45
test.sh
Executable 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
1
testdata/list.txt
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
test.txt
|
1
testdata/test.txt
vendored
Executable file
1
testdata/test.txt
vendored
Executable file
@ -0,0 +1 @@
|
|||||||
|
teststring
|
Loading…
Reference in New Issue
Block a user