blob: 9d7b377499b8a34320758a8bc418ff503f3177a9 [file] [log] [blame]
Naresh Kambojuf88f4d72016-08-17 17:11:30 +05301#!/bin/bash
2#
3# ui browser tests by using Robot framework
4#
5# Copyright (C) 2016 Linaro Limited
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License
9# as published by the Free Software Foundation; either version 2
10# of the License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20#
21# Author: Naresh Kamboju <naresh.kamboju@linaro.org>
22
23set -eu
24. ../../lib/sh-test-lib
25WD="$(pwd)"
26OUTPUT="$(pwd)/output"
27RESULT_FILE="${OUTPUT}/ui-browser-test-results.txt"
28UI_BROWSER_TEST_OUTPUT="ui-browser-test-output"
29
30usage()
31{
32 echo "Usage: $0 [-u username] [-s <true|false>]" 1>&2
33 echo "the user should own X process and DISPLAY=:0"
34 exit 1
35}
36
37
38while getopts "s:u:" o; do
39 case "$o" in
40 # Skip package installation
41 s) SKIP_INSTALL="${OPTARG}" ;;
42 # Default user is linaro
43 u) TESTUSER="${OPTARG}" && id "${TESTUSER}" ;;
44 *) usage ;;
45 esac
46done
47
48if [ $# -ne 4 ]; then
49 usage
50fi
51
52
53# Test run.
54! check_root && error_msg "This script must be run as root"
55pkgs="python2.7 python-pip python-lxml"
56install_deps "${pkgs}" "${SKIP_INSTALL}"
57
58[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)"
59mkdir -p "${OUTPUT}"
60
61dist_name
62if [ "${dist}" = "Debian" ] || [ "${dist}" = "Ubuntu" ]; then
63 "${WD}"/install-on-debian.sh
64else
65 echo "Not a debian machine"
66fi
67
68# Copy robot test scripts to /tmp
69cp -a robot-test-scripts /tmp/
70# Tests should runs by linaro users because X owned by linaro user.
71# linaro user can not create output files in /root
72# so change directory to /tmp
73cd /tmp
74# Run as TESTUSER
75su "${TESTUSER}" -c "${WD}"/run-robot-tests.sh
76# "${UI_BROWSER_TEST_OUTPUT}" directory created by TESTUSER from run-robot-tests.sh
77mv "${UI_BROWSER_TEST_OUTPUT}" "${OUTPUT}"
78mv robot-test-scripts "${OUTPUT}"
79# Parse test results
80python "${WD}"/robot-results-parser.py "${OUTPUT}"/"${UI_BROWSER_TEST_OUTPUT}"/output.xml >> "${RESULT_FILE}"
81cd -