-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtest_munge.sh
executable file
·150 lines (132 loc) · 3.58 KB
/
test_munge.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
#
# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
#
# SPDX-License-Identifier: BSD-2-Clause
#
set -e
function usage () {
cat <<EOF 1>&2
USAGE: test_munge.sh [-h|-d|-v] <git-ref> [git-ref]
-d Preserve files
-a AST check
-v Verbose
-c Colorized output
-p Path to th repo collection
-h Print help
EOF
}
# Argument parsing
while getopts ":hadvcp:" opts
do
case $opts in
h)
usage
exit 0
;;
d)
DUMP=true
;;
v)
VERBOSE=true
;;
a) AST=true
AST_OPTS="-a"
;;
c) COLOR=''
;;
p) REPO_DIR="${OPTARG}"
if ! [ -d "${REPO_DIR}" ]
then
echo >&2 "-p: ${REPO_DIR} is not a directory (cwd: $(pwd))"
exit 1
fi
DIR_OPTS="-p ${REPO_DIR}"
;;
*)
echo "Invalid option: -${OPTARG}" >&2
;;
esac
done
#color
RED=${COLOR+'\033[0;31m'}
YEL=${COLOR+'\033[0;33m'}
GRE=${COLOR+'\033[0;32m'}
NC=${COLOR+'\033[0m'}
shift $((OPTIND - 1))
REF1=$1
REF2=$2
[ -z ${DUMP+x} ] && trap "rm -f ckernel_*.txt" EXIT
[ -z ${REF1} ] && (echo >&2 "At least 1 ref is required"; exit 1)
[ $# -gt 2 ] && echo "Ignoring ${@:3}"
# Find the script directory
SCRIPT_DIR=$(cd $(dirname "$0") && pwd)
[ -d "${SCRIPT_DIR}" ] || (echo >&2 "no script dir"; exit 1)
MAKE_MUNGE=${SCRIPT_DIR}/make_munge.sh
echo -e "${YEL}REF1=seL4@${REF1}"
echo "REF2=seL4@${REF2}"
echo "L4V_ARCH=${L4V_ARCH}"
echo -e "WORKING...${NC}"
if [ -z ${VERBOSE} ]
then
${MAKE_MUNGE} ${DIR_OPTS} ${AST_OPTS} ${REF1} >/dev/null
else
${MAKE_MUNGE} ${DIR_OPTS} ${AST_OPTS} ${REF1}
fi
sort -o ckernel_names_1.txt ckernel_names.txt
rm ckernel_names.txt
mv kernel_all.txt kernel_all_1.txt
[ -z ${AST+x} ] || mv ckernel_ast.txt ckernel_ast_1.txt
if [ -z ${VERBOSE} ]
then
${MAKE_MUNGE} ${DIR_OPTS} ${AST_OPTS} ${REF2} >/dev/null
else
${MAKE_MUNGE} ${DIR_OPTS} ${AST_OPTS} ${REF2}
fi
sort -o ckernel_names_2.txt ckernel_names.txt
rm ckernel_names.txt
mv kernel_all.txt kernel_all_2.txt
[ -z ${AST+x} ] || mv ckernel_ast.txt ckernel_ast_2.txt
ERRORS=false
# Check for differences in
echo -en "${RED}"
if ! diff -q ckernel_names_1.txt ckernel_names_2.txt >/dev/null
then
echo -e "${RED}"
echo "#################################"
echo "# Some symbols have changed #"
echo -e "#################################\n"
echo -e "\n${YEL}Symbols diff:${NC}"
diff -uw ckernel_names_1.txt ckernel_names_2.txt || true
ERRORS=true
fi
echo -en "${RED}"
if ! ([ -z ${AST+x} ] || diff -q ckernel_ast_1.txt ckernel_ast_2.txt >/dev/null)
then
echo -e "${RED}"
echo "#################################"
echo "# The ASTs differ #"
echo -e "#################################\n"
echo -e "${NC}${YEL}"
ERRORS=true
fi
echo -en "${NC}"
if ! ${ERRORS}
then echo -e "${GRE}Clean diff, test PASSED for L4V_ARCH=${L4V_ARCH}.${NC}"
else
echo -en "${RED}"
if ! diff -q kernel_all_1.txt kernel_all_2.txt
then
echo -e "${RED}"
echo "#################################"
echo "# Something has changed #"
echo -e "#################################\n"
echo -e "\n${NC}${YEL}kernel_all diff:${NC}"
grep -v "/tmp/munge-" kernel_all_1.txt > clean_kernel_all_1.txt
grep -v "/tmp/munge-" kernel_all_2.txt > clean_kernel_all_2.txt
diff -uw clean_kernel_all_1.txt clean_kernel_all_2.txt || true
fi
echo
echo -e "${RED}Preprocess test FAILED.${NC}"
exit 1
fi