blob: ad47f5ce8cacc9e10e15e6a2f0b060f6e625e683 (
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
|
#!/bin/bash
#
# ui browser tests by using Robot framework
#
# Copyright (C) 2016 Linaro Limited
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Author: Naresh Kamboju <naresh.kamboju@linaro.org>
set -eu
. ../../lib/sh-test-lib
WD="$(pwd)"
OUTPUT="$(pwd)/output"
RESULT_FILE="${OUTPUT}/ui-browser-test-results.txt"
UI_BROWSER_TEST_OUTPUT="ui-browser-test-output"
usage()
{
echo "Usage: $0 [-u username] [-s <true|false>]" 1>&2
echo "the user should own X process and DISPLAY=:0"
exit 1
}
while getopts "s:u:" o; do
case "$o" in
# Skip package installation
s) SKIP_INSTALL="${OPTARG}" ;;
# Default user is linaro
u) TESTUSER="${OPTARG}" && id "${TESTUSER}" ;;
*) usage ;;
esac
done
if [ $# -ne 4 ]; then
usage
fi
# Test run.
! check_root && error_msg "This script must be run as root"
pkgs="python2.7 python-pip python-lxml"
install_deps "${pkgs}" "${SKIP_INSTALL}"
create_out_dir "${OUTPUT}"
dist_name
# shellcheck disable=SC2154
if [ "${dist}" = "debian" ] || [ "${dist}" = "ubuntu" ]; then
"${WD}"/install-on-debian.sh
else
echo "Not a debian machine"
fi
(
# Copy robot test scripts to /tmp
cp -a robot-test-scripts /tmp/ || error_msg "Could not copy scripts to /tmp"
# Tests should runs by linaro users because X owned by linaro user.
# linaro user can not create output files in /root
# so change directory to /tmp
cd /tmp || error_msg "Could not cd into /tmp"
# Run as TESTUSER
su "${TESTUSER}" -c "${WD}"/run-robot-tests.sh
# "${UI_BROWSER_TEST_OUTPUT}" directory created by TESTUSER from run-robot-tests.sh
mv "${UI_BROWSER_TEST_OUTPUT}" "${OUTPUT}"
mv robot-test-scripts "${OUTPUT}"
# Parse test results
python "${WD}"/robot-results-parser.py "${OUTPUT}"/"${UI_BROWSER_TEST_OUTPUT}"/output.xml >> "${RESULT_FILE}"
)
|