Naresh Kamboju | f88f4d7 | 2016-08-17 17:11:30 +0530 | [diff] [blame] | 1 | #!/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 | |
| 23 | set -eu |
| 24 | . ../../lib/sh-test-lib |
| 25 | WD="$(pwd)" |
| 26 | OUTPUT="$(pwd)/output" |
| 27 | RESULT_FILE="${OUTPUT}/ui-browser-test-results.txt" |
| 28 | UI_BROWSER_TEST_OUTPUT="ui-browser-test-output" |
| 29 | |
| 30 | usage() |
| 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 | |
| 38 | while 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 |
| 46 | done |
| 47 | |
| 48 | if [ $# -ne 4 ]; then |
| 49 | usage |
| 50 | fi |
| 51 | |
| 52 | |
| 53 | # Test run. |
| 54 | ! check_root && error_msg "This script must be run as root" |
| 55 | pkgs="python2.7 python-pip python-lxml" |
| 56 | install_deps "${pkgs}" "${SKIP_INSTALL}" |
| 57 | |
| 58 | [ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)" |
| 59 | mkdir -p "${OUTPUT}" |
| 60 | |
| 61 | dist_name |
| 62 | if [ "${dist}" = "Debian" ] || [ "${dist}" = "Ubuntu" ]; then |
| 63 | "${WD}"/install-on-debian.sh |
| 64 | else |
| 65 | echo "Not a debian machine" |
| 66 | fi |
| 67 | |
| 68 | # Copy robot test scripts to /tmp |
| 69 | cp -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 |
| 73 | cd /tmp |
| 74 | # Run as TESTUSER |
| 75 | su "${TESTUSER}" -c "${WD}"/run-robot-tests.sh |
| 76 | # "${UI_BROWSER_TEST_OUTPUT}" directory created by TESTUSER from run-robot-tests.sh |
| 77 | mv "${UI_BROWSER_TEST_OUTPUT}" "${OUTPUT}" |
| 78 | mv robot-test-scripts "${OUTPUT}" |
| 79 | # Parse test results |
| 80 | python "${WD}"/robot-results-parser.py "${OUTPUT}"/"${UI_BROWSER_TEST_OUTPUT}"/output.xml >> "${RESULT_FILE}" |
| 81 | cd - |