forked from sakai135/wsl-vpnkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·55 lines (44 loc) · 1.96 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
#!/bin/sh -xe
# ensuring distro is stopped before running tests
wsl.exe -d wsl-vpnkit --cd /app service wsl-vpnkit stop
if wsl.exe -d wsl-vpnkit --cd /app service wsl-vpnkit status; then
wsl.exe -t wsl-vpnkit
fi
# tests
for debug_value in '1' '2' ''; do
if [ -n "${debug_value}" ]; then
debug_str="DEBUG=${debug_value}"
else
debug_str=""
fi
echo "####### Test Round with debug_str [${debug_str}] #######" | grep --colour=always .
# inital status should be stopped
output=$(wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit status)||echo "ignoring exit code"
echo "$output" | grep --colour=always "Service wsl-vpnkit is not running"
# start service
wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit start
sleep 2
output=$(wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit status)
echo "$output" | grep --colour=always "Service wsl-vpnkit is running"
# check latest log
sleep 5
output=$(wsl.exe -d wsl-vpnkit --cd /app sh -c "tac /var/log/wsl-vpnkit.log | awk '{print}; /starting wsl-vpnkit/{exit}' | tac")
( set +x # avoid clutter during output checks
# check for working ping
echo "$output" | grep --colour=always "ping success"
# check for working dns
echo "$output" | grep --colour=always "nslookup success"
)
# restart service
wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit restart
sleep 2
output=$(wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit status)
echo "$output" | grep --colour=always "Service wsl-vpnkit is running"
# stop service
wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit stop
output=$(wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit status)||echo "ignoring exit code"
echo "$output" | grep --colour=always "Service wsl-vpnkit is not running"
# check welcome screen
wsl.exe -d wsl-vpnkit --cd /app sh -c 'echo 1 | source /etc/profile'
done
echo "$0 Finished" | grep --colour=always .