]>
Commit | Line | Data |
---|---|---|
c1192f8a | 1 | #! /bin/sh |
5a9c6b89 | 2 | set -x |
c1192f8a AD |
3 | # Copyright (C) 2005-2012 Free Software Foundation, Inc. |
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation, either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
5a9c6b89 | 18 | me=`basename $1 .test` |
c1192f8a AD |
19 | |
20 | # Number of the current test. | |
21 | number=1 | |
22 | ||
23 | # Exit status of this script. | |
24 | exit=true | |
25 | ||
5a9c6b89 AD |
26 | # top_buiddir. |
27 | cwd=`pwd` | |
28 | ||
c1192f8a | 29 | # The exercised program. |
5a9c6b89 | 30 | prog=$cwd/examples/$me/$me |
c3a2e0e6 AD |
31 | |
32 | # cleanup | |
33 | # ------- | |
34 | cleanup () | |
35 | { | |
36 | local status=$? | |
37 | if test -z "$DEBUG"; then | |
5a9c6b89 | 38 | cd $cwd |
c3a2e0e6 AD |
39 | rm -rf $$.dir |
40 | fi | |
41 | exit $status | |
42 | } | |
43 | trap cleanup 0 1 2 13 15 | |
44 | mkdir $$.dir | |
45 | cd $$.dir | |
c1192f8a AD |
46 | |
47 | # run EXPECTED-EXIT-STATUS EXPECTED-OUTPUT [PARSER-OPTIONS] | |
48 | # --------------------------------------------------------- | |
49 | run () | |
50 | { | |
c3a2e0e6 | 51 | # Expected exit status. |
c1192f8a AD |
52 | local sta_exp=$1 |
53 | shift | |
c3a2e0e6 | 54 | # Expected output. |
c1192f8a AD |
55 | local out_exp=$1 |
56 | shift | |
c3a2e0e6 AD |
57 | $prog "$@" - <input >out_eff |
58 | # Effective exit status. | |
c1192f8a | 59 | local sta_eff=$? |
c3a2e0e6 | 60 | # Effective output. |
c1192f8a AD |
61 | local out_eff=`cat out_eff` |
62 | if test $sta_eff -eq $sta_exp; then | |
63 | if test "$out_eff" = "$out_exp"; then | |
c3a2e0e6 | 64 | echo "$me: PASS: $number" |
c1192f8a | 65 | else |
c3a2e0e6 | 66 | echo "$me: FAIL: $number (expected output: $out_exp, effective: $out_eff)" |
c1192f8a AD |
67 | exit=false |
68 | fi | |
69 | else | |
c3a2e0e6 | 70 | echo "$me: FAIL: $number (expected status: $sta_exp, effective: $sta_eff)" |
c1192f8a AD |
71 | exit=false |
72 | fi | |
73 | number=`expr $number + 1` | |
74 | } | |
75 | ||
5a9c6b89 AD |
76 | # We have cd'd one level deeper. |
77 | . "../$1" | |
c1192f8a | 78 | |
c1192f8a | 79 | $exit |