mirrored from https://chromium.googlesource.com/webm/libwebp-test-data
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest_cwebp.sh
More file actions
executable file
·97 lines (85 loc) · 1.89 KB
/
test_cwebp.sh
File metadata and controls
executable file
·97 lines (85 loc) · 1.89 KB
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
#!/bin/sh
##
## test_cwebp.sh
##
## Simple test to validate encoding of source images using the cwebp
## example utility.
##
## This file distributed under the same terms as libwebp. See the libwebp
## COPYING file for more information.
##
self=$0
usage() {
cat <<EOT
Usage: $self [options] <source files to test>
Options:
--exec=</path/to/cwebp>
--md5exec=</path/to/md5sum/replacement>
--loop=<count>
--nocheck
--mt
--noalpha
--lossless
--extra_args=<cwebp args>
EOT
exit 1
}
run() {
# simple means for a batch speed test
${executable} $file
}
check() {
# test the optimized vs. unoptimized versions. this is a bit
# fragile, but good enough for optimization testing.
md5=$({ ${executable} -o - $file || echo "fail1"; } | ${md5exec})
md5_noasm=$( { ${executable} -noasm -o - $file || echo "fail2"; } | ${md5exec})
printf "$file:\t"
if [ "$md5" = "$md5_noasm" ]; then
printf "OK\n"
else
printf "FAILED\n"
exit 1
fi
}
check="true"
noalpha=""
lossless=""
mt=""
md5exec="md5sum"
extra_args=""
n=1
for opt; do
optval=${opt#*=}
case ${opt} in
--exec=*) executable="${optval}";;
--md5exec=*) md5exec="${optval}";;
--loop=*) n="${optval}";;
--mt) mt="-mt";;
--lossless) lossless="-lossless";;
--noalpha) noalpha="-noalpha";;
--nocheck) check="";;
--extra_args=*) extra_args="${optval}";;
-*) usage;;
*) break;;
esac
shift
done
[ $# -gt 0 ] || usage
[ "$n" -gt 0 ] || usage
executable=${executable:-cwebp}
${executable} 2>/dev/null | grep -q Usage || usage
executable="${executable} -quiet ${mt} ${lossless} ${noalpha} ${extra_args}"
set +e
if [ "$check" = "true" ]; then
TEST=check
else
TEST=run
fi
N=$n
while [ $n -gt 0 ]; do
for file; do
$TEST
done
n=$((n - 1))
printf "DONE (%d of %d)\n" $(($N - $n)) $N
done