-
Notifications
You must be signed in to change notification settings - Fork 1
/
validate.sh
129 lines (111 loc) · 3.04 KB
/
validate.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
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
123
124
125
126
127
128
129
#!/bin/bash
QOICONV_REF=./qoi/qoiconv
QOICONV_TARGET=./rapid-qoi/target/release/qoiconv
IMAGES=./qoi_benchmark_suite/images/screenshot_game
rm -f /tmp/{ref,target}.qoi /tmp/{ref,target}.{raw,target}.{raw,png}
result=0
find ${IMAGES} | grep -E '.png$' | while read x; do
# Encoding
${QOICONV_REF} "${x}" /tmp/ref.qoi
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : encode failed by reference encoder. skip...
rm /tmp/ref.qoi
continue
fi
${QOICONV_TARGET} "${x}" /tmp/target.qoi
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : encode failed by target encoder. skip...
rm /tmp/{ref,target}.qoi
continue
fi
# Decoding
${QOICONV_REF} /tmp/ref.qoi /tmp/ref.ref.png
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : decode failed by reference decoder
rm /tmp/{ref,target}.qoi /tmp/ref.ref.png
result=1
continue
fi
${QOICONV_REF} /tmp/target.qoi /tmp/target.ref.png
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : decode failed by reference decoder
rm /tmp/{ref,target}.qoi /tmp/ref.{ref,target}.png
result=1
continue
fi
${QOICONV_TARGET} /tmp/ref.qoi /tmp/ref.target.png
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : decode failed by target decoder
rm /tmp/{ref,target}.qoi /tmp/{ref,target}.{ref,target}.png
result=1
continue
fi
${QOICONV_TARGET} /tmp/target.qoi /tmp/target.target.png
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : decode failed by target decoder
rm /tmp/{ref,target}.qoi /tmp/{ref,target}.{ref,target}.png
result=1
continue
fi
# Extracting
${QOICONV_TARGET} /tmp/ref.ref.png /tmp/ref.ref.raw
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : extraction failed
rm /tmp/{ref,target}.qoi /tmp/{ref,target}.{ref,target}.{png,raw}
result=1
continue
fi
${QOICONV_TARGET} /tmp/target.ref.png /tmp/target.ref.raw
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : extraction failed
rm /tmp/{ref,target}.qoi /tmp/{ref,target}.{ref,target}.{png,raw}
result=1
continue
fi
${QOICONV_TARGET} /tmp/ref.target.png /tmp/ref.target.raw
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : extraction failed
rm /tmp/{ref,target}.qoi /tmp/{ref,target}.{ref,target}.{png,raw}
result=1
continue
fi
${QOICONV_TARGET} /tmp/target.target.png /tmp/target.target.raw
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : extraction failed
rm /tmp/{ref,target}.qoi /tmp/{ref,target}.{ref,target}.{png,raw}
result=1
continue
fi
# Comparing
diff /tmp/ref.ref.raw /tmp/target.ref.raw
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : encode by target encoder is not correct
result=1
fi
diff /tmp/ref.ref.raw /tmp/ref.target.raw
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : decode by target decoder is not correct
result=1
fi
diff /tmp/ref.ref.raw /tmp/target.target.raw
ret=$?
if [ ${ret} -ne 0 ]; then
echo ${x} : roundtrip by target encoder-decoder is not correct
result=1
fi
# Cleanup
rm /tmp/{ref,target}.qoi /tmp/{ref,target}.{ref,target}.{png,raw}
done
exit ${result}