-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathtest_files.sh
executable file
·85 lines (73 loc) · 1.77 KB
/
test_files.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
#!/bin/bash
SRC=
CONTINUE_ON_ERROR=0
VERBOSE=0
usage() {
echo "checks md5s generated from make_test_files_basis.sh"
echo ""
echo "$0 usage:"
echo ""
echo " $0 -i file [-c]"
echo ""
echo " -c continue on error"
exit 0;
}
[ $# -eq 0 ] && usage
while getopts "i:chv" arg; do
case $arg in
i)
SRC="${OPTARG}"
;;
c)
CONTINUE_ON_ERROR=1
;;
v)
VERBOSE=1
;;
h | *) # Display help.
usage
exit 0
;;
esac
done
if [ "${SRC}" = "" ] ; then
usage
fi
if [ ! -f "${SRC}" ]; then
echo "File not found: ${SRC}"
exit 1
fi
OLDIFS=$IFS
IFS=","
TMP=$(mktemp /tmp/ge_test_files.XXXXXX)
while read MD5 SECTION FILE
do
if [ ! -f "${SRC}" ]; then
echo "File not found: ${SRC}"
continue
fi
if [ -f $FILE ]; then
mips-linux-gnu-objcopy -j "${SECTION}" -O binary "${FILE}" "${TMP}"
ACTUAL=$(md5sum -b "${TMP}" | cut -c -32 | tr '[:upper:]' '[:lower:]')
EXPECTED=$(echo "${MD5}" | tr '[:upper:]' '[:lower:]')
if [ "${ACTUAL}" != "${EXPECTED}" ] ; then
if [ $VERBOSE -eq 1 ]; then
echo "checksums differ, section'${SECTION}', file: '${FILE}'. Actual=[${ACTUAL}], expected=[${EXPECTED}]"
else
echo -e "Mis-Match in $(echo $FILE | sed -E -e 's/build\/[uje]\/src\//src\//g;' -e 's/\.o/\.c/g')"
fi
if [ ${CONTINUE_ON_ERROR} -eq 0 ] ; then
IFS=$OLDIFS
rm -f "${TMP}"
exit 1
fi
else
if [ ${VERBOSE} -eq 1 ]; then
echo "pass: section'${SECTION}' ${FILE}"
fi
fi
fi
done < "${SRC}"
IFS=$OLDIFS
rm -f "${TMP}"
exit 0