This commit is contained in:
asus
2023-02-20 16:19:41 +01:00
parent 3ed006b652
commit 1d690b43bd
9 changed files with 12371 additions and 75 deletions

View File

@@ -1,9 +1,24 @@
#!/bin/bash
path="mini_serv.c"
nine=0
for var in "$@"
do
if [ "$var" = "nine" ]
then
nine=1
else
path="$var"
fi
done
port=0
while [ $port -lt 1024 -o $port -gt 10000 ]; do
while [ $port -lt 1024 -o $port -gt 10000 ]
do
port=$RANDOM
done
id=1
test_number=0
@@ -13,7 +28,8 @@ launch_client() {
while read -r line
do
echo "$test_number - receiver $id $(date +%s%N): $line"
#echo "$test_number - receiver $id $(date +%s%N): $line"
echo "$test_number - receiver $id : $line"
done < <(echo "$1" | nc localhost "$port" 2>&1) &
sleep 0.1
@@ -32,10 +48,26 @@ new_test() {
launch_client ""
}
clang -Wall -Wextra -Werror mini_serv.c 2>&1
clang -Wall -Wextra -Werror $path 2>&1
./a.out "$port" 2>&1 &
## # # # # # # # # # # # # # # # # # # # # # # # # #
# #
if [ "$nine" -eq 1 ]
then
nc localhost "$port" 2>&1 &
for i in {1..3000}
do
#launch_client
nc localhost "$port" 2>&1 &
stop_last_client
done
killall -q a.out nc
exit 1
fi
# # # # # # # # # # # # # # # # # # # # # # # # # #
#
new_test "open a client an close, 3 times"
@@ -96,17 +128,6 @@ launch_client "$text"
stop_last_client
## # # # # # # # # # # # # # # # # # # # # # # # # #
# #
for i in {1..3000}
do
#launch_client
nc localhost "$port" 2>&1 &
stop_last_client
done
echo ""
echo "done"
killall -q a.out nc