-
Notifications
You must be signed in to change notification settings - Fork 38
/
test.sh
executable file
·143 lines (136 loc) · 3.67 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
#
# shell script menus for elinks binary testing
#
CUR_TEST=hello
clear
echo ' --/ \--'
echo ' --[ Welcome to the elinks test helper ]--'
echo ' --[ ]--'
echo ' --[ [*] use option 1 to run dump test ]--'
echo ' --\ /--'
echo ' '
# RUN TEST
run_test() {
if [ "$1" = "hello" ]; then
$ELINKS --dump ./test/hello.html
elif [ "$1" = "http" ]; then
echo "[=] assumes You're running https server on port 9452"
echo "[=] see http_server option"
$ELINKS \
--dump http://127.0.0.1:9452 | head
elif [ "$1" = "https" ]; then
echo "[=] assumes You're running https server on port 9453"
echo "[=] see https_server option"
$ELINKS \
-eval 'set connection.ssl.cert_verify = 0' \
--dump https://127.0.0.1:9453 | head
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
fi
}
# 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
}
# 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
}
# MAIN LOOP
#
# 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"
select SEL in $OPTS; do
echo "[*] Current test : " $SEL
echo "[*] Current bin : " $ELINKS
if [ "$SEL" = "hello" ]; then
run_test $SEL
elif [ "$SEL" = "http" ]; then
run_test $SEL
elif [ "$SEL" = "https" ]; then
run_test $SEL
elif [ "$SEL" = "interactive" ]; then
run_test $SEL
elif [ "$SEL" = "http_server" ]; then
http_menu
elif [ "$SEL" = "https_server" ]; then
https_menu
elif [ "$SEL" = "exit" ]; then
exit
fi
done