blob: 100c3280a27afd64517ff28d881c60e3e750a8e7 (
plain)
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
|
#!/bin/bash
# Copyright 2015 Holger Levsen <holger@layer-acht.org>
# released under the GPLv=2
DEBUG=false
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
set -e
cleanup_all() {
set +e
# kill xvfb and ffmpeg
kill $XPID $FFMPEGPID 2>/dev/null|| true
# preserve screenshots
[ ! -f screenshot.png ] || mv screenshot.png $RESULTS/
[ ! -f screenshot-thumb.png ] || mv screenshot-thumb.png $RESULTS/
[ ! -f test-torbrowser-$SUITE.mpg ] || mv test-torbrowser-$SUITE.mpg $RESULTS/
[ ! -f screenshot_from_git.png ] || mv screenshot_from_git.png screenshot.png
# shutdown and end session if it still exists
schroot --run-session -c $SESSION --directory /tmp -u root -- service dbus stop || true
schroot --end-session -c tbb-launcher-$SUITE-$(basename $TMPDIR) > /dev/null 2>&1 || true
# delete main work dir
cd
rm $TMPDIR -r
# end
echo "$(date -u) - $TMPDIR deleted. Cleanup done."
}
update_screenshot() {
TIMESTAMP=$(date +%Y%m%d%H%M)
xwd -root -silent -display :$SCREEN.0 | xwdtopnm > screenshot.pnm 2>/dev/null
pnmtopng screenshot.pnm > screenshot.png
convert screenshot.png -adaptive-resize 128x96 screenshot-thumb.png
# for publishing
cp -v screenshot.png $RESULTS/screenshot_$TIMESTAMP.png
# for the live screenshot plugin
mv screenshot.png screenshot-thumb.png $WORKSPACE/
}
first_test() {
echo
local SESSION="tbb-launcher-$SUITE-$(basename $TMPDIR)"
schroot --begin-session --session-name=$SESSION -c jenkins-torbrowser-launcher-$SUITE
schroot --run-session -c $SESSION --directory /tmp -u root -- mkdir $HOME
schroot --run-session -c $SESSION --directory /tmp -u root -- chown jenkins:jenkins $HOME
schroot --run-session -c $SESSION --directory /tmp -u root -- service dbus start
sleep 2
SCREEN=77
Xvfb -ac -br -screen 0 1024x768x16 :$SCREEN &
XPID=$!
sleep 1
export DISPLAY=":$SCREEN.0"
unset http_proxy
unset https_proxy
timeout -k 12m 11m schroot --run-session -c $SESSION --preserve-environment -- awesome &
sleep 1
update_screenshot
timeout -k 12m 11m schroot --run-session -c $SESSION --preserve-environment -- torbrowser-launcher https://www.debian.org &
ffmpeg -f x11grab -i :$SCREEN.0 -s 1024x768 test-torbrowser-${SUITE}_$(date +%Y%m%d%H%M).mpg > /dev/null 2>&1 &
FFMPEGPID=$!
for i in $(seq 1 16) ; do
sleep 15
update_screenshot
done
timeout -k 12m 11m schroot --run-session -c $SESSION --preserve-environment -- torbrowser-launcher https://www.debian.org &
for i in $(seq 1 16) ; do
sleep 15
update_screenshot
done
schroot --run-session -c $SESSION --directory /tmp -u root -- service dbus stop
schroot --end-session -c $SESSION
kill $XPID $FFMPEGPID || true
echo
}
#
# main
#
TMPDIR=$(mktemp -d) # where everything actually happens
trap cleanup_all INT TERM EXIT
WORKSPACE=$(pwd)
RESULTS=$WORKSPACE/results
[ ! -f screenshot.png ] || mv screenshot.png screenshot_from_git.png
mkdir -p $RESULTS
cd $TMPDIR
SUITE=$1
echo "$(date -u) - testing torbrowser-launcher on $SUITE now."
first_test # test package from the archive
# then build package and test it (probably via triggering another job)
# not sure how to test updates. maybe just run old install?
cd
cleanup_all
trap - INT TERM EXIT
echo "$(date -u) - the end."
|