2022-04-23 08:49:51 -04:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2022-04-23 14:14:21 -04:00
|
|
|
# shell script menus for elinks binary testing
|
2022-04-23 08:49:51 -04:00
|
|
|
#
|
|
|
|
|
2022-04-23 14:14:21 -04:00
|
|
|
CUR_TEST=hello
|
|
|
|
|
2022-04-23 08:49:51 -04:00
|
|
|
clear
|
|
|
|
|
|
|
|
echo ' --/ \--'
|
|
|
|
echo ' --[ Welcome to the elinks test helper ]--'
|
|
|
|
echo ' --[ ]--'
|
|
|
|
echo ' --[ [*] use option 1 to run dump test ]--'
|
|
|
|
echo ' --\ /--'
|
|
|
|
echo ' '
|
|
|
|
|
2022-04-23 14:14:21 -04:00
|
|
|
# RUN TEST
|
|
|
|
run_test() {
|
2022-04-23 08:49:51 -04:00
|
|
|
if [ "$1" = "hello" ]; then
|
2022-04-24 03:53:42 -04:00
|
|
|
$ELINKS --dump ./test/hello.html
|
2022-04-23 14:14:21 -04:00
|
|
|
elif [ "$1" = "http" ]; then
|
2022-04-24 03:53:42 -04:00
|
|
|
echo "[=] assumes You're running https server on port 9452"
|
|
|
|
echo "[=] see http_server option"
|
|
|
|
$ELINKS \
|
|
|
|
--dump http://127.0.0.1:9452 | head
|
2022-04-23 14:14:21 -04:00
|
|
|
elif [ "$1" = "https" ]; then
|
|
|
|
echo "[=] assumes You're running https server on port 9453"
|
|
|
|
echo "[=] see https_server option"
|
2022-04-24 03:53:42 -04:00
|
|
|
$ELINKS \
|
2022-04-23 14:14:21 -04:00
|
|
|
-eval 'set connection.ssl.cert_verify = 0' \
|
|
|
|
--dump https://127.0.0.1:9453 | head
|
2022-04-24 03:53:42 -04:00
|
|
|
elif [ "$1" = "interactive" ]; then
|
|
|
|
# set 256 colors terminal
|
|
|
|
# use: export TERM=xterm-256color
|
|
|
|
# and use compiled elinks with the tests folder
|
|
|
|
if [ "$ARCH" = "win64" ]; then
|
|
|
|
export TERM=dumb
|
|
|
|
$ELINKS \
|
|
|
|
--config-dir `pwd`/test/etc \
|
|
|
|
./test
|
|
|
|
else
|
|
|
|
export TERM=xterm-256color
|
|
|
|
$ELINKS \
|
|
|
|
--config-dir `pwd`/test/etc \
|
|
|
|
-eval 'set terminal.xterm-256color.colors = 3' \
|
|
|
|
./test
|
|
|
|
fi
|
2022-04-23 08:49:51 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-04-24 03:53:42 -04:00
|
|
|
# HTTP SERVER MENU
|
|
|
|
http_menu() {
|
|
|
|
HTTP_OPTS="start_http stop_http return"
|
|
|
|
echo ""
|
|
|
|
echo "--[ http server menu ]--"
|
|
|
|
echo ""
|
|
|
|
select SEL in $HTTP_OPTS; do
|
|
|
|
echo " [*] http server menu "
|
|
|
|
if [ "$SEL" = "start_http" ]; then
|
|
|
|
python3 ./test/server/httpf.py &
|
|
|
|
PID=`echo $!`
|
|
|
|
echo $PID > /tmp/eltmpf.pid
|
|
|
|
echo "[*} Starting http server (pid $PID)"
|
|
|
|
elif [ "$SEL" = "stop_http" ]; then
|
|
|
|
PID=`cat /tmp/eltmpf.pid`
|
|
|
|
echo "[*] Stopping http server (pid $PID)"
|
|
|
|
kill $PID
|
|
|
|
elif [ "$SEL" = "return" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-23 14:14:21 -04:00
|
|
|
# HTTPS SERVER MENU
|
|
|
|
https_menu() {
|
|
|
|
HTTPS_OPTS="start_https stop_https certgen return"
|
|
|
|
echo "--[ https server menu ]--"
|
|
|
|
echo ""
|
|
|
|
echo " [*] use certgen to generate server certificate"
|
|
|
|
echo ""
|
|
|
|
select SEL in $HTTPS_OPTS; do
|
|
|
|
echo " [*] https server menu "
|
|
|
|
if [ "$SEL" = "start_https" ]; then
|
|
|
|
python3 ./test/server/https.py &
|
|
|
|
PID=`echo $!`
|
|
|
|
echo $PID > /tmp/eltmp.pid
|
|
|
|
echo "[*} Starting https server (pid $PID)"
|
|
|
|
elif [ "$SEL" = "stop_https" ]; then
|
|
|
|
PID=`cat /tmp/eltmp.pid`
|
|
|
|
echo "[*] Stopping https server (pid $PID)"
|
|
|
|
kill $PID
|
|
|
|
elif [ "$SEL" = "certgen" ]; then
|
|
|
|
echo "[*] generation ssl certificate for the https server"
|
|
|
|
./test/server/gen.sh
|
|
|
|
elif [ "$SEL" = "return" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-04-23 08:49:51 -04:00
|
|
|
# MAIN LOOP
|
2022-04-24 03:53:42 -04:00
|
|
|
#
|
|
|
|
# When called from build.sh it will get first
|
|
|
|
# parameter as binary suffix and second parameter
|
|
|
|
# as architecture
|
|
|
|
#
|
|
|
|
if [ -d $1 ]; then
|
|
|
|
BIN_SUFFIX=""
|
|
|
|
else
|
|
|
|
BIN_SUFFIX=$1
|
|
|
|
fi
|
|
|
|
if [ -d $2 ]; then
|
|
|
|
ARCHIT="lin64"
|
|
|
|
else
|
|
|
|
ARCHIT=$2
|
|
|
|
fi
|
|
|
|
echo $ARCH $BIN_SUFFIX
|
|
|
|
if [ -f ../bin/elinks_$ARCH$BIN_SUFFIX ]; then
|
|
|
|
ELINKS=../bin/elinks_$ARCH$BIN_SUFFIX
|
|
|
|
else
|
|
|
|
ELINKS=./src/elinks$BIN_SUFFIX
|
|
|
|
fi
|
|
|
|
SEL="none"
|
|
|
|
OPTS="hello http https interactive null null null null null http_server https_server exit"
|
2022-04-23 08:49:51 -04:00
|
|
|
select SEL in $OPTS; do
|
2022-04-24 03:53:42 -04:00
|
|
|
echo "[*] Current test : " $SEL
|
|
|
|
echo "[*] Current bin : " $ELINKS
|
2022-04-23 14:14:21 -04:00
|
|
|
if [ "$SEL" = "hello" ]; then
|
|
|
|
run_test $SEL
|
|
|
|
elif [ "$SEL" = "http" ]; then
|
|
|
|
run_test $SEL
|
|
|
|
elif [ "$SEL" = "https" ]; then
|
|
|
|
run_test $SEL
|
2022-04-24 03:53:42 -04:00
|
|
|
elif [ "$SEL" = "interactive" ]; then
|
|
|
|
run_test $SEL
|
|
|
|
elif [ "$SEL" = "http_server" ]; then
|
|
|
|
http_menu
|
2022-04-23 14:14:21 -04:00
|
|
|
elif [ "$SEL" = "https_server" ]; then
|
|
|
|
https_menu
|
|
|
|
elif [ "$SEL" = "exit" ]; then
|
2022-04-23 08:49:51 -04:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|