3 # Copyright (C) 2017 Genome Research Ltd.
5 # Author: Robert Davies <rmd@sanger.ac.uk>
7 # Permission is hereby granted, free of charge, to any person obtaining a copy
8 # of this software and associated documentation files (the "Software"), to deal
9 # in the Software without restriction, including without limitation the rights
10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 # copies of the Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
14 # The above copyright notice and this permission notice shall be included in
15 # all copies or substantial portions of the Software.
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 # DEALINGS IN THE SOFTWARE.
25 # Executes a single test and compares against the expected output
27 # Expected result: pass (P) / fail (F) / nonzero exit (N)
29 # File with expected output (empty or '.' if none)
35 if [ "x$test_iter" = "x" ]
39 test_iter
=`expr $test_iter + 1`
41 result
=`eval ${@+"$@"} 2>_err.tmp > _out.tmp`
46 # Expected zero exit code, got non-zero
50 # Expected non-zero exit code and got it
55 # Expected non-zero exit code, but got zero
58 elif [ "x$e" != "x" -a "$e" != "." ]
60 if cmp -s _out.tmp
"$e"
62 # Output was as expected
64 rm -f _out.tmp _err.tmp
71 # Expected zero exit code and got it.
73 rm -f _out.tmp _err.tmp
82 if [ "x$e" != "x" -a "$e" != "." ]
84 keep_output
="FAIL-$e.${test_iter}"
86 keep_output
="FAIL.${test_iter}"
88 mv _out.tmp
"${keep_output}.out"
89 mv _err.tmp
"${keep_output}.err"
90 nufail
=`expr $nufail + 1`
91 if [ "$y" = "exit_code" ]
95 echo "Got non-zero exit code"
97 echo "Got unexpected zero exit code"
99 echo "See ${keep_output}.{out,err} for output"
101 echo "Output differed from expected result"
102 echo "Compare $e ${keep_output}.out"
107 nefail
=`expr $nefail + 1`
115 nepass
=`expr $nepass + 1`
118 echo "PASS : $@ (must exit non-zero)"
119 nepass
=`expr $nepass + 1`
123 nupass
=`expr $nupass + 1`
134 while read -r line
<&9
138 "#"*) # skip comments
140 "") # skip blank lines too
145 eval ${@+"$@"} > /dev
/null
156 run_test
"$p" "$o" ${@+"$@"}
163 echo "Expected passes: $nepass"
164 echo "Unexpected passes: $nupass"
165 echo "Expected failures: $nefail"
166 echo "Unexpected failures: $nufail"
167 if [ "$nupass" -gt 0 -o "$nufail" -gt 0 ]
175 echo "Testing tabix..."