Files
42_INT_12_webserv/telnet_test.sh
2022-08-14 21:26:57 +02:00

144 lines
1.6 KiB
Bash
Executable File

#! /bin/bash
# you need to put absolutely everything in ""
##########
# Colors
##########
_GREY='\033[30m'
_RED='\033[0;31m'
_GREEN='\033[32m'
_YELLOW='\033[33m'
_BLUE='\033[34m'
_PURPLE='\033[35m'
_CYAN='\033[36m'
_WHITE='\033[37m'
_END='\033[0m'
test_file=$1
source $test_file
connect_to_telnet="open $host $port"
start_telnet()
{
echo "open $host $port"
sleep 1
}
run_telnet()
{
echo "$connect_to_telnet"
sleep 1
echo -e "$request"
# echo "$l1"
# echo "$header"
# echo
# echo $body
# echo
# echo
echo
sleep 1
# ret = $(arg | telnet)
}
run()
{
echo "$connect_to_telnet"
sleep 1
run_this_test
}
run_a_test()
{
{
echo "----- $test_name -----"
echo -e "$_RED$request$_END"
} &> test.log
# run_telnet
# echo ${pid}
# echo -e "$_END---"
echo -e "$request" | telnet
# run_telnet | telnet
# run_telnet
# echo
# echo "----- end of test -----"
}
run_all()
{
echo
# ./webserv $config_file 2>&1 > webserv.log &
#while something i change headers
# for i in "${methods[@]}"
# do
# expected_result="something"
# run_a_test
# echo -e "${_GREEN}$expected_result${_END}"
## echo
# done
}
#######
# This is where stuff is launched
#######
rm -rf test.log
rm -rf telnet.out
#./webserv $config_file 2>&1 > webserv.log & run_all
#./webserv $config_file 2>&1 > webserv.log &
#./webserv $config_file &> /dev/null &
./webserv $config_file &> webserv.log &
#./webserv $config_file 1>&1 > webserv.log &
#run_all
#run_this_test
echo -e "${_GREEN}Running Telnet Test on '$test_name'${_END}"
sleep 1
run | telnet >> telnet.out
#run | telnet
pkill webserv