This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
run-tests.sh
executable file
·226 lines (185 loc) · 6.14 KB
/
run-tests.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash
error () {
echo "ERROR: $1"
exit 1
}
# ====================================================================
TOOLCHAIN_DIR=$(cd "`dirname \"$0\"`"; pwd)
TOP=$(cd ${TOOLCHAIN_DIR}/..; pwd)
# ====================================================================
WITH_TARGET=riscv32-unknown-elf
BUILD_DIR=${TOP}/build
RESULTS_DIR=${TOP}/results
INSTALL_DIR=${TOP}/install
TARGET_BOARD=riscv-sim
TARGET_SUBSET=
TOOL=gcc
COMMENT="none"
# ====================================================================
until
opt=$1
case ${opt} in
--build-dir)
shift
BUILD_DIR=$(realpath -m $1)
;;
--install-dir)
shift
INSTALL_DIR=$(realpath -m $1)
;;
--results-dir)
shift
RESULTS_DIR=$(realpath -m $1)
;;
--with-target)
shift
WITH_TARGET=$1
;;
--with-board)
shift
TARGET_BOARD=$1
;;
--test-subset)
shift
TEST_SUBSET=$1
;;
--tool)
shift
TOOL=$1
;;
--comment)
shift
COMMENT=$1
;;
--help)
echo "Usage: ./run-tests.sh [--build-dir <dir>]"
echo " [--install-dir <dir>]"
echo " [--results-dir <dir>]"
echo " [--with-target <triplet>]"
echo " [--with-board <board>]"
echo " [--test-subset <string>]"
echo " [--tool gcc | gdb]"
echo " [--comment <text>]"
echo " [--help]"
echo ""
echo "The default --with-target is 'riscv32-unknown-elf'."
echo ""
echo "The default for --with-board is 'riscv-sim', other"
echo "options are 'riscv-picorv32' or 'riscv-ri5cy'."
echo ""
exit 1
;;
?*)
error "Unknown argument '$1' (try --help)"
;;
*)
;;
esac
[ "x${opt}" = "x" ]
do
shift
done
# ====================================================================
[ ! -z "${RESULTS_DIR}" ] || error "no results directory"
mkdir -p "${RESULTS_DIR}" || error "failed to create results directory"
TMP_RESULTS_DIR=`mktemp -d -p ${RESULTS_DIR} "results-$(date +%F-%H%M)-XXXX" 2>/dev/null`
[ ! -z "${TMP_RESULTS_DIR}" ] || error "no run-specific results directory"
[ -d "${TMP_RESULTS_DIR}" ] || error "no run-specific results directory found"
rm -f ${TMP_RESULTS_DIR}/*
RESULTS_DIR=${TMP_RESULTS_DIR}
# ====================================================================
GCC_STAGE_2_BUILD_DIR=${BUILD_DIR}/gcc-stage-2
GDB_BUILD_DIR=${BUILD_DIR}/gdb
# ====================================================================
# So that spike, riscv32-unknown-elf-run, etc. can be found
export PATH=${INSTALL_DIR}/bin:$PATH
# ====================================================================
# So that dejagnu can find the correct baseboard file (e.g. riscv-spike.exp)
export DEJAGNULIBS=${TOP}/dejagnu
export DEJAGNU=${TOOLCHAIN_DIR}/site.exp
# ====================================================================
# Start gdbserver
GDBSERVER_PID=
case "${TARGET_BOARD}" in
riscv-picorv32|riscv-ri5cy)
# Set up and export any board parameters.
export RISCV_NETPORT=51235
# We only start one gdbserver, so only run one test at a time.
PARALLEL=1
# Select the -c option to pass when starting gdbserver.
case "${TARGET_BOARD}" in
riscv-picorv32)
C_OPT="picorv32"
;;
riscv-ri5cy)
C_OPT="RI5CY"
;;
*)
esac
# Select common board name to select the dejagnu config file.
ORIGINAL_TARGET_BOARD=${TARGET_BOARD}
TARGET_BOARD=riscv-gdbserver
echo ${INSTALL_DIR}/bin/riscv-gdbserver -c ${C_OPT} ${RISCV_NETPORT}
${INSTALL_DIR}/bin/riscv-gdbserver -c ${C_OPT} ${RISCV_NETPORT} & pid=$!
echo "Started GDB server on port ${RISCV_NETPORT} (process ${pid})"
GDBSERVER_PID=$pid
;;
*)
PARALLEL=8
;;
esac
TARGET_XLEN=
case "${WITH_TARGET}" in
riscv32-unknown-elf)
TARGET_XLEN=32
;;
riscv64-unknown-elf)
TARGET_XLEN=64
;;
esac
if [ -z "${TARGET_XLEN}" ]
then
echo "Couldn't figure out XLEN value"
exit 1
fi
export RISCV_TIMEOUT=10
export RISCV_GDB_TIMEOUT=10
export RISCV_STACK_SIZE="4096"
export RISCV_TEXT_SIZE="65536"
export RISCV_XLEN=${TARGET_XLEN}
# ====================================================================
# Create a README with info about the test
readme=${RESULTS_DIR}/README
echo "Test of risc-v tool chain" > ${readme}
echo "=========================" >> ${readme}
echo "" >> ${readme}
echo "Start time: $(date -u +%d\ %b\ %Y\ at\ %H:%M)" >> ${readme}
echo "Target: ${WITH_TARGET}" >> ${readme}
echo "Test board: ${ORIGINAL_TARGET_BOARD}" >> ${readme}
echo "Test subset: ${TEST_SUBSET}" >> ${readme}
echo "Comment: ${COMMENT}" >> ${readme}
echo "Tool: ${TOOL}" >> ${readme}
case "${TOOL}" in
gcc)
cd ${GCC_STAGE_2_BUILD_DIR}
make -j $PARALLEL check-gcc-c RUNTESTFLAGS="${TEST_SUBSET} --target=${WITH_TARGET} --target_board=${TARGET_BOARD}"
cp ${GCC_STAGE_2_BUILD_DIR}/gcc/testsuite/gcc/gcc.log ${RESULTS_DIR}/gcc.log
cp ${GCC_STAGE_2_BUILD_DIR}/gcc/testsuite/gcc/gcc.sum ${RESULTS_DIR}/gcc.sum
;;
gdb)
cd ${GDB_BUILD_DIR}
make -j $PARALLEL check-gdb RUNTESTFLAGS="${TEST_SUBSET} --target=${WITH_TARGET} --target_board=${TARGET_BOARD}"
cp ${GDB_BUILD_DIR}/gdb/testsuite/gdb.log ${RESULTS_DIR}/gdb.log
cp ${GDB_BUILD_DIR}/gdb/testsuite/gdb.sum ${RESULTS_DIR}/gdb.sum
;;
*)
error "unknown tool ${TOOL}"
;;
esac
# ====================================================================
if [ ! -z "${GDBSERVER_PID}" ]
then
echo "Killing off gdbserver (process ${GDBSERVER_PID})"
kill -9 ${GDBSERVER_PID} &>/dev/null
fi
# ====================================================================