-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsng_regress
executable file
·122 lines (117 loc) · 3.39 KB
/
sng_regress
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
#
# sng_regress -- regression test harness for sng
#
#viewer="xv -cmap"
viewer=display
stop_on_error=0
eyeball_test=0
for file in $*
do
case $file in
-s) # Stop on any regression failure
stop_on_error=1
;;
-e) # Test that decompilation/compilation gives same image
eyeball_test=1
;;
*.png)
if [ "$stop_on_error" = "0" ]
then
trap "rm -f /tmp/*$$.[ps]ng" 0 1 2 15
else
trap "ls /tmp/*$$.[ps]ng" 0 1 2 15
fi
if [ "$eyeball_test" = "1" ]
then
echo $file.
sng <$file | sng >/tmp/recompiled$$.png && $viewer $file /tmp/recompiled$$.png
fi
# echo "Regression-testing against PNG file \`$file'"
if sng <${file} >/tmp/decompiled$$.sng
then
:
else
echo "$file: decompilation of the test PNG failed.";
case $stop_on_error in 1) exit 1;; 0) continue;; esac
fi
if sng </tmp/decompiled$$.sng >/tmp/decompiled$$.png
then
:
else
echo "$file: recompilation of the decompiled form failed.";
case $stop_on_error in 1) exit 1;; 0) continue;; esac
fi
if sng </tmp/decompiled$$.png >/tmp/canonicalized$$.sng
then
:
else
echo "$file: generation of the canonicalized form failed.";
case $stop_on_error in 1) exit 1;; 0) continue;; esac
fi
if sng </tmp/canonicalized$$.sng >/tmp/canonicalized$$.png
then
:
else
echo "$file: recompilation of the canonicalized form failed.";
case $stop_on_error in 1) exit 1;; 0) continue;; esac
fi
if cmp -s /tmp/decompiled$$.png /tmp/canonicalized$$.png
then
:
#echo "$file: regression test passed."
else
echo "$file: decompiled and canonicalized versions differ.";
case $stop_on_error in 1) exit 1;; 0) continue;; esac
fi
;;
*.sng)
# echo "Regression-testing against SNG file \`$file'"
# Make a canonicalized version of the test file
# Regenerate canonicalized version from its PNG
# Diff the two
if sng <${file} >/tmp/test$$.png
then
:
else
echo "$file: compilation of the test SNG failed.";
case $stop_on_error in 1) exit 1;; 0) continue;; esac
fi
if sng </tmp/test$$.png >/tmp/canonicalized$$.sng
then
:
else
echo "$file: generation of the canonicalized form failed.";
case $stop_on_error in 1) exit 1;; 0) continue;; esac
fi
if sng </tmp/canonicalized$$.sng >/tmp/canonicalized$$.png
then
:
else
echo "$file: recompilation of the canonicalized form failed.";
case $stop_on_error in 1) exit 1;; 0) continue;; esac
fi
if sng </tmp/canonicalized$$.png >/tmp/decompiled$$.sng
then
:
else
echo "$file: decompilation of the canonicalized form failed.";
case $stop_on_error in 1) exit 1;; 0) continue;; esac
fi
if diff -c /tmp/canonicalized$$.sng /tmp/decompiled$$.sng
then
:
#echo "$file: regression test passed."
else
echo "$file: decompiled and canonicalized versions differ.";
case $stop_on_error in 1) exit 1;; 0) continue;; esac
fi
;;
*)
echo "Non-PNG, non-SNG file \`$file' ignored"
;;
esac
done
trap '' 0 12 2 15
rm -f /tmp/*$$.[ps]ng
# sng_regress ends here