blob: 15bf34f048ef0d478d60142428a676924e10c244 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/bin/sh
new_tag() {
for t in $TAGS; do
if test "$t" = "$1"; then
echo "Duplicate tag $t" 1>&2 ; exit 1
fi
done
TAGS="$TAGS $tag"
}
# Usage: run tag program args ...
# Runs 'program args ...' with output to tag.out and tag.err
run() {
tag=$1; shift
test -n "$*" || { echo "No command for tag: $tag" 1>&2; exit 1; }
new_tag $tag
rm -f $tag.out $tag.err $tag.diff
"$@" > $tag.out 2> $tag.err || echo "exit status $?" >> $tag.err &
}
# Genereate error report
errors() {
for tag in "$@"; do
DIFF=`diff $tag.out $tag.expect 2>&1` || {
echo "==== $tag.out != $tag.expect ===="
echo $DIFF
}
test -s $tag.err && {
echo "==== $tag.err ===="
cat $tag.err
}
done
}
# Wait for processes, verify output.
# Verifies tag.expect == tag.out and ! tag.err for each tag,
# creates errors.txt if there are any discrepancies.
#
verify() {
wait
rm -f errors.txt
ERRORS=`errors $TAGS`
if test -n "$ERRORS"; then
echo "$ERRORS" 1>&2
return 1
fi
return 0
}
|