nightly_image_diff.sh
3.47 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/sh -f
SIM="all"
USE_BB_FILES=""
##################################################
#
# Usage message
#
##################################################
usage()
{
echo "Usage: nightly_image_diff.sh <-s> simulator"
echo " Simulator: cio, ccv, cvio, all, default = all"
exit 0
}
##################################################
#
# Compare .rgb, .cov, and .z files
#
# $1 = file prefix
# $2 = compare type
#
##################################################
compare_function()
{
fprefix=$1
if [ "$USE_BB_FILES" = "TRUE" ]
then
if [ $2 = "cio" ]
then
t1="bb_c"
t2="bb_io"
elif [ $2 = "ccv" ]
then
t1="bb_c"
t2="bb_cv"
elif [ $2 = "cvio" ]
then
t1="bb_cv"
t2="bb_io"
fi
else
if [ $2 = "cio" ]
then
t1="c"
t2="io"
elif [ $2 = "ccv" ]
then
t1="c"
t2="cv"
elif [ $2 = "cvio" ]
then
t1="cv"
t2="io"
fi
fi
t3=""
for sufx in rgb cov z
do
echo " /* $sufx */"
f1=OutData/${fprefix}_${t1}${t3}_0.${sufx}
f2=OutData/${fprefix}_${t2}${t3}_0.${sufx}
df=${fprefix}_idf_${t1}_${t2}.${sufx}
if [ -r $f1 -a -r $f2 ]
then
../../tools/iclr $f1
../../tools/iclr $f2
if cmp -s $f1 $f2
then
echo "INFO: Image files $f1 and $f2 equate."
else
echo "ERROR: Image files $f1 and $f2 differ."
echo " Difference file generated as $df."
$ROOT/usr/sbin/idf -d $f1 $f2 $df
if [ $? -eq 0 ]
then
echo " Differences probably SOLELY due to dithering."
fi
fi
else
if [ ! -r $f1 ]
then
echo "ERROR: $f1 not present or not readable."
fi
if [ ! -r $f2 ]
then
echo "ERROR: $f2 not present or not readable."
fi
fi
done
}
##################################################
#
# Parse options
#
##################################################
while getopts "s:b" a
do
case $a in
s) SIM=$OPTARG;;
b) USE_BB_FILES=TRUE;;
\?) usage ;;
esac
done
shift `expr $OPTIND - 1`
###############################################################################
#
# For each incoming arg, generate file names by appending appropriate suffixes,
# use iclr to strip out garbage from the image file header, then use cmp to
# compare the resulting binary data. If a difference is detected, use idf -d
# to generate a viewable difference file, and to determine whether or not the
# differences are == 0x08, which are usually attributable to dithering.
#
###############################################################################
# echo "\n"
echo; echo
for fprefix do
echo "============== $fprefix =============="
#
# C/CV compares
#
if [ $SIM = "ccv" -o $SIM = "all" ]
then
compare_function $fprefix "ccv"
fi
#
# C/IO compares
#
if [ $SIM = "cio" -o $SIM = "all" ]
then
compare_function $fprefix "cio"
fi
#
# CV/IO compares
#
if [ $SIM = "cvio" -o $SIM = "all" ]
then
compare_function $fprefix "cvio"
fi
echo "\n"
done