blob: 97ba9e5564ab3ec43429a5d2d9d393376d36d5bc [file] [log] [blame]
Thomas Woodee62ca42014-07-01 11:35:16 +01001#!/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
25ROOT="`dirname $0`"
26ROOT="`readlink -f $ROOT/..`"
27IGT_TEST_ROOT="$ROOT/tests"
28RESULTS="$ROOT/results"
29PIGLIT=`which piglit 2> /dev/null`
30
31if [ ! -d "$IGT_TEST_ROOT" ]; then
32 echo "Error: could not find tests directory."
33 exit 1
34fi
35
Mike Mason3db57622015-05-05 17:14:55 -070036if [ ! -f "$IGT_TEST_ROOT/test-list.txt" ]; then
Thomas Woodee62ca42014-07-01 11:35:16 +010037 echo "Error: test list not found."
38 echo "Please run make in the tests directory to generate the test list."
Mike Mason3db57622015-05-05 17:14:55 -070039 exit 1
Thomas Woodee62ca42014-07-01 11:35:16 +010040fi
41
Mike Mason3db57622015-05-05 17:14:55 -070042TEST_LIST=`cat "$IGT_TEST_ROOT/test-list.txt" | sed -e '/TESTLIST/d' -e 's/ /\n/g'`
Thomas Woodee62ca42014-07-01 11:35:16 +010043
44function download_piglit {
45 git clone git://anongit.freedesktop.org/piglit "$ROOT/piglit"
46}
47
48function 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 Masone9da0932014-08-18 10:43:09 -070058 echo " (can be used more than once)"
Thomas Woodee62ca42014-07-01 11:35:16 +010059 echo " -v enable verbose mode"
60 echo " -x <regex> exclude tests that match the regular expression"
Mike Masone9da0932014-08-18 10:43:09 -070061 echo " (can be used more than once)"
Mike Mason822cc6a2014-08-26 13:31:27 -070062 echo " -R resume interrupted test where the partial results"
63 echo " are in the directory given by -r"
Mike Masonb1e40e92015-05-27 08:25:06 -070064 echo " -n do not retry incomplete tests when resuming a"
65 echo " test run with -R"
Thomas Woodee62ca42014-07-01 11:35:16 +010066 echo ""
Thomas Wood498fb622015-12-02 16:35:50 +000067 echo "Useful patterns for test filtering are described in the API documentation."
Thomas Woodee62ca42014-07-01 11:35:16 +010068}
69
70function list_tests {
Mike Mason3db57622015-05-05 17:14:55 -070071 for test in $TEST_LIST; do
Thomas Woodee62ca42014-07-01 11:35:16 +010072 SUBTESTS=`"$IGT_TEST_ROOT/$test" --list-subtests`
Mike Mason3db57622015-05-05 17:14:55 -070073 if [ -z "$SUBTESTS" ]; then
74 echo "$test"
75 else
76 for subtest in $SUBTESTS; do
77 echo "$test/$subtest"
78 done
79 fi
Thomas Woodee62ca42014-07-01 11:35:16 +010080 done
81}
82
Mike Masonb1e40e92015-05-27 08:25:06 -070083while getopts ":dhlr:st:vx:Rn" opt; do
Thomas Woodee62ca42014-07-01 11:35:16 +010084 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 Masone9da0932014-08-18 10:43:09 -070090 t) FILTER="$FILTER -t $OPTARG" ;;
Thomas Woodee62ca42014-07-01 11:35:16 +010091 v) VERBOSE="-v" ;;
Mike Masone9da0932014-08-18 10:43:09 -070092 x) EXCLUDE="$EXCLUDE -x $OPTARG" ;;
Mike Mason822cc6a2014-08-26 13:31:27 -070093 R) RESUME="true" ;;
Mike Masonb1e40e92015-05-27 08:25:06 -070094 n) NORETRY="--no-retry" ;;
Thomas Woodee62ca42014-07-01 11:35:16 +010095 :)
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
105done
106shift $(($OPTIND-1))
107
108if [ "x$1" != "x" ]; then
109 echo "Unknown option: $1"
110 print_help
111 exit 1
112fi
113
114if [ "x$PIGLIT" == "x" ]; then
115 PIGLIT="$ROOT/piglit/piglit"
116fi
117
118if [ ! -x "$PIGLIT" ]; then
119 echo "Could not find Piglit."
120 echo "Please install Piglit or use -d to download Piglit locally."
121 exit 1
122fi
123
Mike Mason822cc6a2014-08-26 13:31:27 -0700124if [ "x$RESUME" != "x" ]; then
Mike Masonb1e40e92015-05-27 08:25:06 -0700125 sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" "$PIGLIT" resume "$RESULTS" $NORETRY
Mike Mason822cc6a2014-08-26 13:31:27 -0700126else
127 mkdir -p "$RESULTS"
Feceoru, Gabriel203591b2016-03-07 17:16:25 +0200128 sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" "$PIGLIT" run igt -o "$RESULTS" -s $VERBOSE $EXCLUDE $FILTER
Mike Mason822cc6a2014-08-26 13:31:27 -0700129fi
Thomas Woodee62ca42014-07-01 11:35:16 +0100130
131if [ "$SUMMARY" == "html" ]; then
132 "$PIGLIT" summary html --overwrite "$RESULTS/html" "$RESULTS"
133 echo "HTML summary has been written to $RESULTS/html/index.html"
134fi