From f88f4d732720599b4bf2fcadcb70203994c019b0 Mon Sep 17 00:00:00 2001 From: Naresh Kamboju Date: Wed, 17 Aug 2016 17:11:30 +0530 Subject: ui-browser-test: Adding UI browser testing Ui browser test developed on top of Robot frame work. Test runs chromium, chrome and firefox test cases. On LAVA we have access to serial console and we have to run ui tests from this serial console, this is possible by changing user from root to linaro and exporting the DISPLAY=:0. because linaro owns the X display process. Change-Id: I43bda407f468120839b0a4c8248777303945529e Signed-off-by: Naresh Kamboju --- automated/linux/ui-browser-test/ui-browser-test.sh | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 automated/linux/ui-browser-test/ui-browser-test.sh (limited to 'automated/linux/ui-browser-test/ui-browser-test.sh') diff --git a/automated/linux/ui-browser-test/ui-browser-test.sh b/automated/linux/ui-browser-test/ui-browser-test.sh new file mode 100755 index 0000000..9d7b377 --- /dev/null +++ b/automated/linux/ui-browser-test/ui-browser-test.sh @@ -0,0 +1,81 @@ +#!/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 + +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 ]" 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}" + +[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)" +mkdir -p "${OUTPUT}" + +dist_name +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/ +# 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 +# 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}" +cd - -- cgit v1.2.3