3 # Copyright © 2014 Intel Corporation
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:
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
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
26 ROOT="`readlink -f $ROOT/..`"
27 IGT_TEST_ROOT="$ROOT/tests"
28 RESULTS="$ROOT/results"
29 PIGLIT=`which piglit 2> /dev/null`
31 if [ ! -d "$IGT_TEST_ROOT" ]; then
32 echo "Error: could not find tests directory."
36 if [ ! -f "$IGT_TEST_ROOT/single-tests.txt" ]; then
37 echo "Error: test list not found."
38 echo "Please run make in the tests directory to generate the test list."
41 SINGLE_TEST_LIST=`cat "$IGT_TEST_ROOT/single-tests.txt" | sed -e '/TESTLIST/d' -e 's/ /\n/g'`
42 MULTI_TEST_LIST=`cat "$IGT_TEST_ROOT/multi-tests.txt" | sed -e '/TESTLIST/d' -e 's/ /\n/g'`
44 function download_piglit {
45 git clone git://anongit.freedesktop.org/piglit "$ROOT/piglit"
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"
58 echo " (can be used more than once)"
59 echo " -v enable verbose mode"
60 echo " -x <regex> exclude tests that match the regular expression"
61 echo " (can be used more than once)"
62 echo " -R resume interrupted test where the partial results"
63 echo " are in the directory given by -r"
65 echo "Useful patterns for test filtering are described in tests/NAMING-CONVENTION"
69 echo "$SINGLE_TEST_LIST"
70 for test in $MULTI_TEST_LIST; do
71 SUBTESTS=`"$IGT_TEST_ROOT/$test" --list-subtests`
72 for subtest in $SUBTESTS; do
78 while getopts ":dhlr:st:vx:R" opt; do
80 d) download_piglit; exit ;;
81 h) print_help; exit ;;
82 l) list_tests; exit ;;
83 r) RESULTS="$OPTARG" ;;
85 t) FILTER="$FILTER -t $OPTARG" ;;
87 x) EXCLUDE="$EXCLUDE -x $OPTARG" ;;
90 echo "Option -$OPTARG requires an argument."
94 echo "Unknown option: -$OPTARG"
102 if [ "x$1" != "x" ]; then
103 echo "Unknown option: $1"
108 if [ "x$PIGLIT" == "x" ]; then
109 PIGLIT="$ROOT/piglit/piglit"
112 if [ ! -x "$PIGLIT" ]; then
113 echo "Could not find Piglit."
114 echo "Please install Piglit or use -d to download Piglit locally."
118 if [ "x$RESUME" != "x" ]; then
119 sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" "$PIGLIT" resume "$RESULTS"
122 sudo IGT_TEST_ROOT="$IGT_TEST_ROOT" "$PIGLIT" run igt "$RESULTS" $VERBOSE $EXCLUDE $FILTER
125 if [ "$SUMMARY" == "html" ]; then
126 "$PIGLIT" summary html --overwrite "$RESULTS/html" "$RESULTS"
127 echo "HTML summary has been written to $RESULTS/html/index.html"