Skip to content

Commit f50ac6c

Browse files
committed
Update integration tests to use Espressif's esp32s2 tests
We also now use the correct include files from the ESP-IDF when building the defines DB, correct for the cpu type we're testing with. (That also means the defines DB is built once per cpu type). That, together with some ESP32-S2 specific test cases from Espressif's esp32s2 assembler test-suite, make those test cases more interesting to run, compared to only assembling ESP32 examples with the esp32s2 cpu selected. Note: This change no longer runs the ulp_tool examples for the esp32s2 case, because those examples use contants (from the ESP-IDF include files), which no longer exist for the ESP32-S2, such as `RTC_IO_TOUCH_PAD*_HOLD_S`. Since the ulp_tool examples primarily test the preprocessor's ability to resolve constants from include files (via the defines DB), testing those examples only once with the ESP32 cpu should be enough.
1 parent d2cd792 commit f50ac6c

File tree

1 file changed

+48
-9
lines changed

1 file changed

+48
-9
lines changed

tests/02_compat_rtc_tests.sh

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,29 @@ fetch_binutils_esp32ulp_examples() {
3636
https://github.com/espressif/binutils-gdb.git 1>$log_file 2>&1
3737
}
3838

39+
REUSE_DEFINES_DB=0
40+
3941
build_defines_db() {
42+
local cpu=$1
4043
local defines_db=defines.db
44+
local defines_db_cpu=defines.$cpu.db
4145

42-
if [ "$1" = "-r" ] && [ -s "${defines_db}" ]; then
46+
if [ "$REUSE_DEFINES_DB" = 1 ] && [ -s "${defines_db_cpu}" ]; then
4347
# reuse existing defines.db
48+
echo "Reusing existing defines DB for cpu $cpu"
49+
cp ${defines_db_cpu} ${defines_db}
4450
return
4551
fi
4652

47-
echo "Building defines DB from include files"
48-
log_file=log/build_defines_db.log
53+
echo "Building defines DB from $cpu include files"
54+
log_file=log/build_defines_db.$cpu.log
4955
rm -f "${defines_db}"
5056
micropython -m esp32_ulp.parse_to_db \
51-
esp-idf/components/soc/esp32/include/soc/*.h \
57+
esp-idf/components/soc/$cpu/include/soc/*.h \
5258
esp-idf/components/esp_common/include/*.h 1>$log_file
59+
60+
# cache defines.db
61+
cp ${defines_db} ${defines_db_cpu}
5362
}
5463

5564
calc_file_hash() {
@@ -62,9 +71,9 @@ patch_test() {
6271
local test_name=$1
6372
local out_file="${test_name}.tmp"
6473

65-
if [ "${test_name}" = esp32ulp_jumpr ]; then
74+
if [[ "${test_name}" =~ ^(esp32ulp_jumpr|esp32s2ulp_jumpr|esp32s2ulp_jump)$ ]]; then
6675
(
67-
cd binutils-gdb/gas/testsuite/gas/esp32ulp/esp32
76+
cd binutils-gdb/gas/testsuite/gas/esp32ulp/$cpu
6877
cp ${test_name}.s ${out_file}
6978
echo -e "\tPatching test to work around binutils-esp32ulp .global bug"
7079
cat >> ${out_file} <<EOF
@@ -89,6 +98,14 @@ EOF
8998
EOF
9099
)
91100
return 0
101+
elif [ "${test_name}" = esp32s2ulp_ld ]; then
102+
(
103+
cd binutils-gdb/gas/testsuite/gas/esp32ulp/esp32s2
104+
echo -e "\tPatching test to work around binutils-esp32ulp .global bug"
105+
cp ${test_name}.s ${out_file}
106+
echo ".global offs_min" >> ${out_file}
107+
)
108+
return 0
92109
fi
93110

94111
return 1 # nothing was patched
@@ -98,13 +115,24 @@ make_log_dir
98115
fetch_esp_idf
99116
fetch_ulptool_examples
100117
fetch_binutils_esp32ulp_examples
101-
build_defines_db $1
102118

103119
run_tests_for_cpu() {
104120
local cpu=$1
105121
echo "Testing for CPU: $cpu"
122+
build_defines_db $cpu
123+
124+
LIST=$(echo binutils-gdb/gas/testsuite/gas/esp32ulp/$cpu/*.s)
125+
if [ $cpu = esp32 ]; then
126+
# append extra tests to test preprocessor
127+
# examples have constants specific to ESP32 (original)
128+
# so we only run these tests with cpu = esp32
129+
# these tests primarily test our preprocessor, which is
130+
# cpu independent, so we do not need to run them
131+
# per each cpu.
132+
LIST=$(echo ulptool/src/ulp_examples/*/*.s $LIST)
133+
fi
106134

107-
for src_file in ulptool/src/ulp_examples/*/*.s binutils-gdb/gas/testsuite/gas/esp32ulp/esp32/*.s; do
135+
for src_file in $LIST; do
108136

109137
src_name="${src_file%.s}"
110138
src_dir="${src_name%/*}"
@@ -121,6 +149,13 @@ run_tests_for_cpu() {
121149
fi
122150
done
123151

152+
if [ "$cpu" = esp32s2 ]; then
153+
if [ "${test_name}" = "hall_sensor" ]; then
154+
echo -e "\tSkipping... not supported on $cpu"
155+
continue 1
156+
fi
157+
fi
158+
124159
# BEGIN: work around known issues with binutils-gdb (esp32ulp)
125160
ulp_file="${src_name}.ulp"
126161

@@ -142,7 +177,7 @@ run_tests_for_cpu() {
142177
bin_file="${src_name}.bin"
143178

144179
echo -e "\tBuilding using binutils ($cpu)"
145-
gcc -I esp-idf/components/soc/esp32/include -I esp-idf/components/esp_common/include \
180+
gcc -I esp-idf/components/soc/$cpu/include -I esp-idf/components/esp_common/include \
146181
-x assembler-with-cpp \
147182
-E -o ${pre_file} $src_file
148183
esp32ulp-elf-as --mcpu=$cpu -o $obj_file ${pre_file}
@@ -167,5 +202,9 @@ run_tests_for_cpu() {
167202
echo ""
168203
}
169204

205+
if [ "$1" = -r ]; then
206+
REUSE_DEFINES_DB=1
207+
fi
208+
170209
run_tests_for_cpu esp32
171210
run_tests_for_cpu esp32s2

0 commit comments

Comments
 (0)