blob: e3da22b58712f731f7209e78526b4b00c4c19c4f (
plain) (
blame)
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
|
#!/usr/bin/env bash
# (c) Wiimm, 2012-10-26
export LC_ALL=POSIX
szsmode=0
logfile=
SZS=wszst
[[ -x ./wszst ]] && SZS=./wszst
SZS0="$SZS -q"
SZS="$SZS0"
echo "SZS=$SZS"
DIFF="diff -q"
echo "DIFF=$DIFF"
HAVE_DCC=0
which -q dcc &>/dev/null && HAVE_DCC=1
function error()
{
echo "!! Test failed: $*" >&2
exit 1
}
let count=0
for src in "$@"
do
if [[ $src = -n || $src = --new ]]
then
echo ">> enabled: --NEW"
SZS="$SZS0 --NEW"
continue
fi
if [[ $src = -o || $src = --old ]]
then
echo ">> enabled: --OLD"
SZS="$SZS0 --OLD"
continue
fi
if [[ $src = -s || $src = --szs ]]
then
echo ">> enabled: SZS mode"
szsmode=1
continue
fi
if [[ $src = -l || $src = --log ]]
then
szsmode=1
logfile=./wu8-size.log
echo ">> SZS mode enabled, log to: $logfile"
{
echo
date +'--- %F %T ---'
echo
} >>"$logfile"
continue
fi
let count++
printf "%5u. %s\n" $count "$src"
temp="$(mktemp -ut test-wu8-XXXXXXXX).tmp" || exit 1
#echo "TEMP=$temp"
$SZS decompress "$src" -D "$temp/11.u8" || error 11 decompress
$SZS norm "$temp/11.u8" || error 11 norm
$SZS norm --wu8 "$temp/11.u8" -D "$temp/12.wu8" || error 12 decode WU8
$SZS norm --u8 "$temp/12.wu8" -D "$temp/13.u8" || error 13 encode WU8
$DIFF "$temp/11.u8" "$temp/13.u8" || error raw diff 11.u8 13.u8
if ((szsmode))
then
$SZS norm "$src" -D "$temp/21.szs" || error 11 norm
$SZS norm --wu8 "$temp/21.szs" -D "$temp/22.wu8" || error 12 decode WU8
$SZS norm --u8 "$temp/22.wu8" -D "$temp/23.szs" || error 13 encode WU8
$DIFF "$temp/21.szs" "$temp/23.szs" || error raw diff 21.szs 23.szs
if [[ $logfile != "" ]]
then
s1=$(stat -c%s "$temp/21.szs")
s2=$(stat -c%s "$temp/22.wu8")
if ((HAVE_DCC))
then
printf "%8u %8u %6.2f%% %s\n" $s1 $s2 $(dcc "100.0*$s2/$s1") "$src" >>"$logfile"
else
printf "%8u %8u %3d%% %s\n" $s1 $s2 $((100*s2/s1)) "$src" >>"$logfile"
fi
fi
fi
rm -rf "$temp"
done
echo "**OK**"
|