blob: b1d75724a9da55f3c7a032cb61a7074221d8e951 (
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
|
check_output() {
testname=$1
cmdtorun=$2
expectedoutput=$3
usestdout=$4
expoutfile=$(mktemp)
actualoutfile=$(mktemp)
ret=0
printf "$expectedoutput" > $expoutfile
if [ $usestdout -eq 1 ]; then
eval $cmdtorun > $actualoutfile 2> /dev/null
else
eval $cmdtorun 2> $actualoutfile 1> /dev/null
fi
cmp $expoutfile $actualoutfile 2>&1 > /dev/null
if [ $? -eq 1 ]; then
printf "$testname:\n"
printf "\tWanted:\n"
cat $expoutfile
printf "\n\tGot:\n"
cat $actualoutfile
printf "\n\n"
ret=1
fi
if [ $? -eq 2 ]; then
printf "cmp error\n"
ret=1
fi
rm $expoutfile $actualoutfile
return $ret
}
check_stdout() {
check_output "$1" "$2" "$3" 1
}
check_stderr() {
check_output "$1" "$2" "$3" 0
}
|