Skip to content

Commit e7d9301

Browse files
committed
Update x11vnc tests
1 parent 655b63d commit e7d9301

File tree

2 files changed

+59
-30
lines changed

2 files changed

+59
-30
lines changed

.github/scripts/x11vnc/test_x11vnc.sh

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
#!/bin/bash
22

3+
# Usage: ./test_x11vnc.sh [log_file]
4+
# If no log file is provided, defaults to "x11vnc_test.log"
5+
6+
# Set default log file
7+
LOG_FILE="${1:-x11vnc_test.log}"
8+
9+
# Show usage if help is requested
10+
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
11+
echo "Usage: $0 [log_file]"
12+
echo " log_file: Path to the log file (default: x11vnc_test.log)"
13+
echo " -h, --help: Show this help message"
14+
exit 0
15+
fi
16+
317
SCRIPTS_DIR="$GITHUB_WORKSPACE/.github/scripts/x11vnc"
418

519
killall x11vnc > /dev/null 2> /dev/null
@@ -11,9 +25,9 @@ X11VNC_TEST_FAIL=0
1125
# CA / cert generation
1226

1327

14-
echo -e "\n\nTesting -sslGenCA\n" > x11vnc_test.log
28+
echo -e "\n\nTesting -sslGenCA\n" > "$LOG_FILE"
1529

16-
$SCRIPTS_DIR/x11vnc_sslgenca.exp >> x11vnc_test.log 2>> x11vnc_test.log
30+
$SCRIPTS_DIR/x11vnc_sslgenca.exp >> "$LOG_FILE" 2>> "$LOG_FILE"
1731

1832
if [ $? -eq 0 ] && [ -f "ca-dir/CA/cacert.pem" ] && [ -f "ca-dir/CA/private/cakey.pem" ]
1933
then
@@ -24,9 +38,9 @@ else
2438
fi
2539

2640

27-
echo -e "\n\nTesting -sslGenCert client\n" >> x11vnc_test.log
41+
echo -e "\n\nTesting -sslGenCert client\n" >> "$LOG_FILE"
2842

29-
$SCRIPTS_DIR/x11vnc_sslgencert_client.exp >> x11vnc_test.log 2>> x11vnc_test.log
43+
$SCRIPTS_DIR/x11vnc_sslgencert_client.exp >> "$LOG_FILE" 2>> "$LOG_FILE"
3044

3145
if [ $? -eq 0 ] && [ -f "ca-dir/clients/wolf.pem" ] && [ -f "ca-dir/clients/wolf.crt" ]
3246
then
@@ -37,9 +51,9 @@ else
3751
fi
3852

3953

40-
echo -e "\n\nTesting -sslGenCert server\n" >> x11vnc_test.log
54+
echo -e "\n\nTesting -sslGenCert server\n" >> "$LOG_FILE"
4155

42-
$SCRIPTS_DIR/x11vnc_sslgencert_server.exp >> x11vnc_test.log 2>> x11vnc_test.log
56+
$SCRIPTS_DIR/x11vnc_sslgencert_server.exp >> "$LOG_FILE" 2>> "$LOG_FILE"
4357

4458
if [ $? -eq 0 ] && [ -f "ca-dir/server-wolf.pem" ] && [ -f "ca-dir/server-wolf.crt" ]
4559
then
@@ -50,13 +64,13 @@ else
5064
fi
5165

5266

53-
echo -e "\n\nTesting -sslCertInfo\n" >> x11vnc_test.log
67+
echo -e "\n\nTesting -sslCertInfo\n" >> "$LOG_FILE"
5468

5569
OPENSSL_CONF='' OPENSSL_MODULES='' timeout 5 x11vnc -sslCertInfo ca-dir/server-wolf.pem > cert_info_ossl.txt
5670
timeout 5 x11vnc -sslCertInfo ca-dir/server-wolf.pem > cert_info.txt
5771

58-
if [ $? -eq 0 ] && diff -y cert_info.txt cert_info_ossl.txt >> x11vnc_test.log 2>> x11vnc_test.log \
59-
&& cat cert_info.txt >> x11vnc_test.log
72+
if [ $? -eq 0 ] && diff -y cert_info.txt cert_info_ossl.txt >> "$LOG_FILE" 2>> "$LOG_FILE" \
73+
&& cat cert_info.txt >> "$LOG_FILE"
6074
then
6175
echo "[ PASSED ] -sslCertInfo"
6276
else
@@ -65,9 +79,9 @@ else
6579
fi
6680

6781

68-
echo -e "\n\nTesting -sslEncKey\n" >> x11vnc_test.log
82+
echo -e "\n\nTesting -sslEncKey\n" >> "$LOG_FILE"
6983

70-
$SCRIPTS_DIR/x11vnc_sslenckey.exp >> x11vnc_test.log 2>> x11vnc_test.log
84+
$SCRIPTS_DIR/x11vnc_sslenckey.exp >> "$LOG_FILE" 2>> "$LOG_FILE"
7185

7286
if [ $? -eq 0 ] && grep -q "BEGIN ENCRYPTED PRIVATE KEY" ca-dir/server-wolf.pem
7387
then
@@ -83,12 +97,12 @@ fi
8397

8498
# Setup Xvfb, which is a purely virtual display, i.e., humans cannot see it
8599
# but it works the same as any other X server
86-
Xvfb :0 -screen 0 100x100x8 2>> x11vnc_test.log &
100+
Xvfb :0 -screen 0 100x100x8 2>> "$LOG_FILE" &
87101
sleep 2
88102

89103

90104
# Testing with SSL will use the TLSNone security type
91-
echo -e "\n\nTesting -ssl handshake, authentication, initialization...\n" >> x11vnc_test.log
105+
echo -e "\n\nTesting -ssl handshake, authentication, initialization...\n" >> "$LOG_FILE"
92106

93107
PORT=`x11vnc -ssl TMP -display :0 -localhost -bg -o server.log`
94108
PORT=`echo "$PORT" | grep -m 1 "PORT=" | sed -e 's/PORT=//'`
@@ -105,13 +119,13 @@ else
105119
X11VNC_TEST_FAIL=1
106120
fi
107121
killall x11vnc > /dev/null 2> /dev/null
108-
cat server.log client.log >> x11vnc_test.log
122+
cat server.log client.log >> "$LOG_FILE"
109123

110124

111125
# Testing with a password changes the security type from TLSNone to TLSVnc
112-
echo -e "\n\nTesting -ssl with a password...\n" >> x11vnc_test.log
126+
echo -e "\n\nTesting -ssl with a password...\n" >> "$LOG_FILE"
113127

114-
x11vnc -storepasswd wolfprov passwd 2>> x11vnc_test.log
128+
x11vnc -storepasswd wolfprov passwd 2>> "$LOG_FILE"
115129

116130
PORT=`x11vnc -ssl TMP -display :0 -localhost -bg -o server.log -rfbauth passwd`
117131
PORT=`echo "$PORT" | grep -m 1 "PORT=" | sed -e 's/PORT=//'`
@@ -128,7 +142,7 @@ else
128142
X11VNC_TEST_FAIL=1
129143
fi
130144
killall x11vnc > /dev/null 2> /dev/null
131-
cat server.log client.log >> x11vnc_test.log
145+
cat server.log client.log >> "$LOG_FILE"
132146

133147

134148
# HTTP HTTPS
@@ -140,9 +154,9 @@ echo "<html><body>Use WolfSSL!</body></html>" > index.html
140154
PORT=`x11vnc -ssl TMP -display :0 -localhost -httpdir . -https 5678 -bg -o server.log`
141155
PORT=`echo "$PORT" | grep -m 1 -Eo "http://localhost:[0-9]+" server.log | sed -e 's/http:\/\/localhost://'`
142156

143-
echo -e "\n\nTesting -https with http...\n" >> x11vnc_test.log
157+
echo -e "\n\nTesting -https with http...\n" >> "$LOG_FILE"
144158

145-
if OPENSSL_CONF='' OPENSSL_MODULES='' curl -ks "http://localhost:$PORT/index.html" >> x11vnc_test.log
159+
if OPENSSL_CONF='' OPENSSL_MODULES='' curl -ks "http://localhost:$PORT/index.html" >> "$LOG_FILE"
146160
then
147161
echo "[ PASSED ] -https with an http request"
148162
else
@@ -151,23 +165,20 @@ else
151165
fi
152166

153167

154-
echo -e "\n\nTesting -https with https...\n" >> x11vnc_test.log
168+
echo -e "\n\nTesting -https with https...\n" >> "$LOG_FILE"
155169

156-
if OPENSSL_CONF='' OPENSSL_MODULES='' curl -ks "https://localhost:5678/index.html" >> x11vnc_test.log
170+
if OPENSSL_CONF='' OPENSSL_MODULES='' curl -ks "https://localhost:5678/index.html" >> "$LOG_FILE"
157171
then
158172
echo "[ PASSED ] -https with an https request"
159173
else
160174
echo "[ FAILED ] -https with an https request"
161175
X11VNC_TEST_FAIL=1
162176
fi
163177

164-
killall x11vnc > /dev/null 2> /dev/null
165-
killall Xvfb > /dev/null 2> /dev/null
166-
cat server.log >> x11vnc_test.log
167-
168-
$GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $X11VNC_TEST_FAIL "$WOLFPROV_FORCE_FAIL_STR" x11vnc
169-
X11VNC_TEST_FAIL=$?
170-
171-
if [[ $X11VNC_TEST_FAIL -eq 1 ]]; then cat x11vnc_test.log; fi
178+
killall x11vnc > /dev/null 2> /dev/null || true
179+
killall Xvfb > /dev/null 2> /dev/null || true
180+
cat server.log >> "$LOG_FILE"
172181

182+
printf "\n\nX11VNC_TEST_FAIL: $X11VNC_TEST_FAIL\n\n"
173183
exit $X11VNC_TEST_FAIL
184+

.github/workflows/x11vnc.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,22 @@ jobs:
122122
run: |
123123
export ${{ matrix.force_fail }}
124124
export WOLFPROV_FORCE_FAIL_STR="${{ matrix.force_fail }}"
125-
$GITHUB_WORKSPACE/.github/scripts/x11vnc/test_x11vnc.sh
125+
export X11VNC_TEST_LOG=/tmp/x11vnc-test.log
126+
export X11VNC_TEST_STATUS=0
127+
if ! $GITHUB_WORKSPACE/.github/scripts/x11vnc/test_x11vnc.sh $X11VNC_TEST_LOG; then
128+
X11VNC_TEST_STATUS=1
129+
fi
130+
131+
if $GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $X11VNC_TEST_STATUS "$WOLFPROV_FORCE_FAIL_STR" x11vnc; then
132+
X11VNC_TEST_STATUS=0
133+
else
134+
X11VNC_TEST_STATUS=1
135+
fi
136+
137+
- name: Show x11vnc test log on failure
138+
run: |
139+
if [ $X11VNC_TEST_STATUS -ne 0 ]; then
140+
cat $X11VNC_TEST_LOG
141+
fi
142+
exit $X11VNC_TEST_STATUS
143+

0 commit comments

Comments
 (0)