Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright © 2014 Intel Corporation |
| 4 | # |
| 5 | # Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | # copy of this software and associated documentation files (the "Software"), |
| 7 | # to deal in the Software without restriction, including without limitation |
| 8 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | # and/or sell copies of the Software, and to permit persons to whom the |
| 10 | # Software is furnished to do so, subject to the following conditions: |
| 11 | # |
| 12 | # The above copyright notice and this permission notice (including the next |
| 13 | # paragraph) shall be included in all copies or substantial portions of the |
| 14 | # Software. |
| 15 | # |
| 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 22 | # IN THE SOFTWARE. |
| 23 | |
| 24 | |
| 25 | ROOT="`dirname $0`" |
| 26 | ROOT="`readlink -f $ROOT/..`" |
| 27 | IGT_TEST_ROOT="$ROOT/tests" |
| 28 | RESULTS="$ROOT/results" |
| 29 | PIGLIT=`which piglit 2> /dev/null` |
| 30 | |
| 31 | if [ ! -d "$IGT_TEST_ROOT" ]; then |
| 32 | echo "Error: could not find tests directory." |
| 33 | exit 1 |
| 34 | fi |
| 35 | |
Mike Mason | 3db5762 | 2015-05-05 17:14:55 -0700 | [diff] [blame] | 36 | if [ ! -f "$IGT_TEST_ROOT/test-list.txt" ]; then |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 37 | echo "Error: test list not found." |
| 38 | echo "Please run make in the tests directory to generate the test list." |
Mike Mason | 3db5762 | 2015-05-05 17:14:55 -0700 | [diff] [blame] | 39 | exit 1 |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 40 | fi |
| 41 | |
Mike Mason | 3db5762 | 2015-05-05 17:14:55 -0700 | [diff] [blame] | 42 | TEST_LIST=`cat "$IGT_TEST_ROOT/test-list.txt" | sed -e '/TESTLIST/d' -e 's/ /\n/g'` |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 43 | |
| 44 | function download_piglit { |
| 45 | git clone git://anongit.freedesktop.org/piglit "$ROOT/piglit" |
| 46 | } |
| 47 | |
| 48 | function print_help { |
| 49 | echo "Usage: run-tests.sh [options]" |
| 50 | echo "Available options:" |
| 51 | echo " -d download Piglit to $ROOT/piglit" |
| 52 | echo " -h display this help message" |
| 53 | echo " -l list all available tests" |
| 54 | echo " -r <directory> store the results in directory" |
| 55 | echo " (default: $RESULTS)" |
| 56 | echo " -s create html summary" |
| 57 | echo " -t <regex> only include tests that match the regular expression" |
Mike Mason | e9da093 | 2014-08-18 10:43:09 -0700 | [diff] [blame] | 58 | echo " (can be used more than once)" |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 59 | echo " -v enable verbose mode" |
| 60 | echo " -x <regex> exclude tests that match the regular expression" |
Mike Mason | e9da093 | 2014-08-18 10:43:09 -0700 | [diff] [blame] | 61 | echo " (can be used more than once)" |
Mike Mason | 822cc6a | 2014-08-26 13:31:27 -0700 | [diff] [blame] | 62 | echo " -R resume interrupted test where the partial results" |
| 63 | echo " are in the directory given by -r" |
Mike Mason | b1e40e9 | 2015-05-27 08:25:06 -0700 | [diff] [blame] | 64 | echo " -n do not retry incomplete tests when resuming a" |
| 65 | echo " test run with -R" |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 66 | echo "" |
Thomas Wood | 498fb62 | 2015-12-02 16:35:50 +0000 | [diff] [blame] | 67 | echo "Useful patterns for test filtering are described in the API documentation." |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | function list_tests { |
Mike Mason | 3db5762 | 2015-05-05 17:14:55 -0700 | [diff] [blame] | 71 | for test in $TEST_LIST; do |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 72 | SUBTESTS=`"$IGT_TEST_ROOT/$test" --list-subtests` |
Mike Mason | 3db5762 | 2015-05-05 17:14:55 -0700 | [diff] [blame] | 73 | if [ -z "$SUBTESTS" ]; then |
| 74 | echo "$test" |
| 75 | else |
| 76 | for subtest in $SUBTESTS; do |
| 77 | echo "$test/$subtest" |
| 78 | done |
| 79 | fi |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 80 | done |
| 81 | } |
| 82 | |
Mike Mason | b1e40e9 | 2015-05-27 08:25:06 -0700 | [diff] [blame] | 83 | while getopts ":dhlr:st:vx:Rn" opt; do |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 84 | case $opt in |
| 85 | d) download_piglit; exit ;; |
| 86 | h) print_help; exit ;; |
| 87 | l) list_tests; exit ;; |
| 88 | r) RESULTS="$OPTARG" ;; |
| 89 | s) SUMMARY="html" ;; |
Mike Mason | e9da093 | 2014-08-18 10:43:09 -0700 | [diff] [blame] | 90 | t) FILTER="$FILTER -t $OPTARG" ;; |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 91 | v) VERBOSE="-v" ;; |
Mike Mason | e9da093 | 2014-08-18 10:43:09 -0700 | [diff] [blame] | 92 | x) EXCLUDE="$EXCLUDE -x $OPTARG" ;; |
Mike Mason | 822cc6a | 2014-08-26 13:31:27 -0700 | [diff] [blame] | 93 | R) RESUME="true" ;; |
Mike Mason | b1e40e9 | 2015-05-27 08:25:06 -0700 | [diff] [blame] | 94 | n) NORETRY="--no-retry" ;; |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 95 | :) |
| 96 | echo "Option -$OPTARG requires an argument." |
| 97 | exit 1 |
| 98 | ;; |
| 99 | \?) |
| 100 | echo "Unknown option: -$OPTARG" |
| 101 | print_help |
| 102 | exit 1 |
| 103 | ;; |
| 104 | esac |
| 105 | done |
| 106 | shift $(($OPTIND-1)) |
| 107 | |
| 108 | if [ "x$1" != "x" ]; then |
| 109 | echo "Unknown option: $1" |
| 110 | print_help |
| 111 | exit 1 |
| 112 | fi |
| 113 | |
| 114 | if [ "x$PIGLIT" == "x" ]; then |
| 115 | PIGLIT="$ROOT/piglit/piglit" |
| 116 | fi |
| 117 | |
| 118 | if [ ! -x "$PIGLIT" ]; then |
| 119 | echo "Could not find Piglit." |
| 120 | echo "Please install Piglit or use -d to download Piglit locally." |
| 121 | exit 1 |
| 122 | fi |
| 123 | |
Mike Mason | 822cc6a | 2014-08-26 13:31:27 -0700 | [diff] [blame] | 124 | if [ "x$RESUME" != "x" ]; then |
Mike Mason | b1e40e9 | 2015-05-27 08:25:06 -0700 | [diff] [blame] | 125 | sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" "$PIGLIT" resume "$RESULTS" $NORETRY |
Mike Mason | 822cc6a | 2014-08-26 13:31:27 -0700 | [diff] [blame] | 126 | else |
| 127 | mkdir -p "$RESULTS" |
Feceoru, Gabriel | 203591b | 2016-03-07 17:16:25 +0200 | [diff] [blame] | 128 | sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" "$PIGLIT" run igt -o "$RESULTS" -s $VERBOSE $EXCLUDE $FILTER |
Mike Mason | 822cc6a | 2014-08-26 13:31:27 -0700 | [diff] [blame] | 129 | fi |
Thomas Wood | ee62ca4 | 2014-07-01 11:35:16 +0100 | [diff] [blame] | 130 | |
| 131 | if [ "$SUMMARY" == "html" ]; then |
| 132 | "$PIGLIT" summary html --overwrite "$RESULTS/html" "$RESULTS" |
| 133 | echo "HTML summary has been written to $RESULTS/html/index.html" |
| 134 | fi |