Petri Latvala | 9fe6ea9 | 2017-09-25 12:34:02 +0300 | [diff] [blame] | 1 | #!/bin/bash |
Thomas Wood | 1a0ae51 | 2014-10-16 17:29:55 +0100 | [diff] [blame] | 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 | # Check that command line handling works consistently across all tests |
| 26 | # |
| 27 | |
Petri Latvala | 3174974 | 2017-03-21 11:47:34 +0200 | [diff] [blame] | 28 | # top_builddir is not set during distcheck. Distcheck executes this |
| 29 | # script in the directory where the built binaries are so just use '.' |
| 30 | # as the directory if top_builddir is not set. |
| 31 | |
| 32 | tests_dir="$top_builddir" |
| 33 | if [ -z "$tests_dir" ]; then |
| 34 | tests_dir="." |
Chris Wilson | 7213c3e | 2016-08-24 09:24:33 +0100 | [diff] [blame] | 35 | fi |
| 36 | |
Petri Latvala | 3174974 | 2017-03-21 11:47:34 +0200 | [diff] [blame] | 37 | # Manually running this script is possible in the source root or the |
| 38 | # tests directory. |
| 39 | |
Chris Wilson | 7213c3e | 2016-08-24 09:24:33 +0100 | [diff] [blame] | 40 | fail () { |
| 41 | echo "FAIL: $1" |
| 42 | exit 1 |
| 43 | } |
Thomas Wood | 1a0ae51 | 2014-10-16 17:29:55 +0100 | [diff] [blame] | 44 | |
Daniel Vetter | f0243a7 | 2017-09-06 10:02:52 +0200 | [diff] [blame] | 45 | check_test () |
| 46 | { |
| 47 | local test |
| 48 | |
| 49 | test=$1 |
| 50 | |
Thomas Wood | 1a0ae51 | 2014-10-16 17:29:55 +0100 | [diff] [blame] | 51 | if [ "$test" = "TESTLIST" -o "$test" = "END" ]; then |
Daniel Vetter | f0243a7 | 2017-09-06 10:02:52 +0200 | [diff] [blame] | 52 | return |
Thomas Wood | 1a0ae51 | 2014-10-16 17:29:55 +0100 | [diff] [blame] | 53 | fi |
| 54 | |
Petri Latvala | 3174974 | 2017-03-21 11:47:34 +0200 | [diff] [blame] | 55 | testname="$test" |
| 56 | if [ -x "$tests_dir/$test" ]; then |
| 57 | test="$tests_dir/$test" |
| 58 | else |
| 59 | # Possibly a script, not found in builddir but in srcdir |
| 60 | if [ -x "$srcdir/$test" ]; then |
| 61 | test="$srcdir/$test" |
| 62 | else |
| 63 | fail "Cannot execute $test" |
| 64 | fi |
Thomas Wood | 1a0ae51 | 2014-10-16 17:29:55 +0100 | [diff] [blame] | 65 | fi |
| 66 | |
| 67 | echo "$test:" |
| 68 | |
| 69 | # check invalid option handling |
| 70 | echo " Checking invalid option handling..." |
Chris Wilson | 7213c3e | 2016-08-24 09:24:33 +0100 | [diff] [blame] | 71 | ./$test --invalid-option 2> /dev/null && fail $test |
Thomas Wood | 1a0ae51 | 2014-10-16 17:29:55 +0100 | [diff] [blame] | 72 | |
| 73 | # check valid options succeed |
| 74 | echo " Checking valid option handling..." |
Chris Wilson | 7213c3e | 2016-08-24 09:24:33 +0100 | [diff] [blame] | 75 | ./$test --help > /dev/null || fail $test |
Thomas Wood | 1a0ae51 | 2014-10-16 17:29:55 +0100 | [diff] [blame] | 76 | |
| 77 | # check --list-subtests works correctly |
| 78 | echo " Checking subtest enumeration..." |
Thomas Wood | f0516f3 | 2015-01-28 16:30:54 +0000 | [diff] [blame] | 79 | LIST=`./$test --list-subtests` |
| 80 | RET=$? |
| 81 | if [ $RET -ne 0 -a $RET -ne 79 ]; then |
Chris Wilson | 7213c3e | 2016-08-24 09:24:33 +0100 | [diff] [blame] | 82 | fail $test |
Thomas Wood | f0516f3 | 2015-01-28 16:30:54 +0000 | [diff] [blame] | 83 | fi |
| 84 | |
| 85 | if [ $RET -eq 79 -a -n "$LIST" ]; then |
Chris Wilson | 7213c3e | 2016-08-24 09:24:33 +0100 | [diff] [blame] | 86 | fail $test |
Thomas Wood | f0516f3 | 2015-01-28 16:30:54 +0000 | [diff] [blame] | 87 | fi |
| 88 | |
| 89 | if [ $RET -eq 0 -a -z "$LIST" ]; then |
Petri Latvala | fa5dc96 | 2017-03-21 14:05:04 +0200 | [diff] [blame] | 90 | # Subtest enumeration of kernel selftest launchers depends |
| 91 | # on the running kernel. If selftests are not enabled, |
| 92 | # they will output nothing and exit with 0. |
Petri Latvala | 3ee83cf | 2017-08-14 12:51:52 +0300 | [diff] [blame] | 93 | if [ "$testname" != "drv_selftest" -a "$testname" != "drm_mm" ]; then |
Petri Latvala | fa5dc96 | 2017-03-21 14:05:04 +0200 | [diff] [blame] | 94 | fail $test |
| 95 | fi |
Thomas Wood | 1a0ae51 | 2014-10-16 17:29:55 +0100 | [diff] [blame] | 96 | fi |
| 97 | |
| 98 | # check invalid subtest handling |
| 99 | echo " Checking invalid subtest handling..." |
Chris Wilson | 7213c3e | 2016-08-24 09:24:33 +0100 | [diff] [blame] | 100 | ./$test --run-subtest invalid-subtest > /dev/null 2>&1 && fail $test |
Daniel Vetter | f0243a7 | 2017-09-06 10:02:52 +0200 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | TESTLISTFILE="$tests_dir/test-list.txt" |
| 104 | if [ ! -r "$TESTLISTFILE" ]; then |
| 105 | tests_dir="tests" |
| 106 | TESTLISTFILE="$tests_dir/test-list.txt" |
| 107 | fi |
| 108 | |
| 109 | TESTLIST=`cat $TESTLISTFILE` |
| 110 | if [ $? -ne 0 ]; then |
| 111 | echo "Error: Could not read test lists" |
| 112 | exit 99 |
| 113 | fi |
| 114 | |
Petri Latvala | 9fe6ea9 | 2017-09-25 12:34:02 +0300 | [diff] [blame] | 115 | if [ -n "$1" ] ; then |
Daniel Vetter | f0243a7 | 2017-09-06 10:02:52 +0200 | [diff] [blame] | 116 | check_test $1 |
| 117 | exit 0 |
| 118 | fi |
| 119 | |
| 120 | for test in $TESTLIST; do |
| 121 | check_test $test |
Thomas Wood | 1a0ae51 | 2014-10-16 17:29:55 +0100 | [diff] [blame] | 122 | done |