3
# A thin wrapper that sets up an environment, runs a test, and exits with an
4
# error if the test does not write a file indicating success.
5
# Copyright Canonical, 2013. Author: Chad MILLER <chad.miller@canonical.com>
13
python3 -u -m http.server 0 >webserver-out 2>webserver-err &
16
trap "echo FAILURE" ERR
17
trap ":" USR1 # Clean-up after every test
18
trap ":" USR2 # Clean-up after every test
19
trap "kill -KILL ${webserver_pid} || echo No web server.; kill -USR1 $$ || echo No cleanup 1.; kill -USR2 $$ || echo No cleanup 2." EXIT
23
while test "$retry" -lt "$retrylimit"; do
26
# "Serving HTTP on 0.0.0.0 port 49074 ..."
27
grep "\\.\\.\\." webserver-out >/dev/null || continue
29
webserver_port=$(head -1 webserver-out |cut -d\ -f6)
32
test "$retry" -lt ${retrylimit}
36
# Now everything is set up for a series of tests.
38
echo -n "Test command-line URL retrieves page from server: "
41
# Create a file that our web server can read. Run chromium with that URL and
42
# see that the web server receives a request for that file/resource.
46
chromium-browser --window-size=400,200 --window-position=100,100 --user-data-dir=profile_storage http://localhost:${webserver_port}/$f >browser_stdout 2>browser_stderr &
48
trap "kill -KILL ${webclient_pid}" USR1
52
while test "$retry" -lt "$retrylimit"; do
55
grep $f webserver-err >/dev/null || continue
59
#kill -USR1 $$ # cleanup
60
test "$retry" -lt ${retrylimit} || echo BAD
61
test "$retry" -lt ${retrylimit} || failures="one:serveraccess $failures"
64
# While we have a chromium running, let's use it. Test that the processes are constrained by a sandbox.
66
echo -n "Test security enclosure: "
67
if ps h --ppid ${webclient_pid} -o label |grep _sandbox\$ >/dev/null; then
68
# At least one process's security label ends with "_sandbox".
70
if { ps h -p ${webclient_pid} -o label; ps h --ppid ${webclient_pid} -o label; } |grep unconfined >/dev/null; then
71
# No processes created immediately by chromium are unconstrained
73
failures="two-b:unconfined $failures"
80
failures="two-a:sandbox $failures"
89
test -z "$failures" && touch result-success || echo "failure list: $failures"
90
test -z "$failures" || exit 1