-
Notifications
You must be signed in to change notification settings - Fork 20
/
run-tests.sh
executable file
·80 lines (72 loc) · 1.63 KB
/
run-tests.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
TESTDIR=tests
UNSIGNED=./coinjoin-merge-unsigned
SIGNED=./coinjoin-merge-signed
process_output()
{
local prog="$1"
local input="$2"
local ln
# Run the program output through an awk script which
# simply filters for the actual data output and echos
# it in a well-defined order.
"$prog" < "$input" | awk '
function despace(s) {
gsub(/[[:space:]]*/, "", s);
return s;
}
BEGIN {
while (getline) {
split ($0, fields, ":");
switch (despace(fields[1])) {
case "mpo":
mpo = despace(fields[2]);
break;
case "mpc":
mpc = despace(fields[2]);
break;
case "hex":
hex = despace(fields[2]);
break;
case "err":
err = despace(fields[2]);
break;
}
}
print "mpo:", mpo;
print "mpc:", mpc;
print "hex:", hex;
print "err:", err;
}'
}
# Run unsigned tests
for suite in $TESTDIR/unsigned/*
do
for run in $suite/*.input
do
if [[ -f $run ]]
then
echo -n "$UNSIGNED: Running $run... ";
outf=$(echo $run | sed 's/input$/output/')
expf=$(echo $run | sed 's/input$/expected/')
if [[ -f "$expf" ]]
then
process_output $UNSIGNED "$run" > "$outf"
diff -q "$expf" "$outf" > /dev/null
if [[ "$?" == "0" ]]
then echo "success."
else
echo "failed."
echo "Diff output:"
diff "$expf" "$outf"
fi
rm $outf
elif [[ -e "$expf" ]]
then
echo "failed (expected output file not an ordinary file)."
else
echo "failed (no expected output file)."
fi
fi
done
done