Merge branch 'bugfix/ci_check_blobs' into 'master'

ci: improve checks for Wi-Fi/PHY libraries

See merge request espressif/esp-idf!16625
This commit is contained in:
Jiang Jiang Jian 2022-01-05 09:26:42 +00:00
commit 477cf09f45
5 changed files with 78 additions and 9 deletions

View File

@ -84,10 +84,6 @@ build_examples_pytest_esp32c3:
- export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS}
# Only do the default cmake build for each target, remaining part are done in the build_template_app job
- tools/ci/build_template_app.sh ${BUILD_COMMAND_ARGS}
# Check if there are any stray printf/ets_printf references in WiFi libs
- cd components/esp_wifi/lib
- for dir in esp32 esp32s2; do test $(xtensa-esp32-elf-nm $dir/*.a | grep -w printf | wc -l) -eq 0; done;
- for dir in esp32 esp32s2; do test $(xtensa-esp32-elf-nm $dir/*.a | grep -w ets_printf | wc -l) -eq 0; done;
# build-related-pre-check-jobs ------------------------------------------------
# Build at least one project for each target at earliest stage to reduce build cost for obvious failing commits

View File

@ -78,15 +78,20 @@ test_check_kconfigs:
script:
- python ${IDF_PATH}/tools/ci/test_check_kconfigs.py
check_wifi_lib_md5:
check_blobs:
extends: .pre_check_base_template
tags:
- build
variables:
SUBMODULES_TO_FETCH: "components/esp_wifi/lib"
SUBMODULES_TO_FETCH: "components/esp_wifi/lib;components/esp_phy/lib"
script:
# Check if Wi-Fi library header files match between IDF and the version used when compiling the libraries
- IDF_TARGET=esp32 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh
- IDF_TARGET=esp32s2 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh
- IDF_TARGET=esp32s3 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh
- IDF_TARGET=esp32c3 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh
# Check if Wi-Fi, PHY, BT blobs contain references to specific symbols
- bash $IDF_PATH/tools/ci/check_blobs.sh
check_fuzzer_compilation:
extends: .pre_check_base_template

@ -1 +1 @@
Subproject commit 2d89c532ccba0bb9988d1d1c6d719bbe1d8b65b8
Subproject commit 4779ddaaf29e1d6aa2d26980103a1c1bbaa29462

View File

@ -15,17 +15,22 @@ fi
case $IDF_TARGET in
esp32)
PREFIX=xtensa-esp32-elf-
LIB_DIR=esp32
;;
esp32s2)
PREFIX=xtensa-esp32s2-elf-
LIB_DIR=esp32s2
;;
esp32s3)
PREFIX=xtensa-esp32s3-elf-
;;
esp32c3)
PREFIX=riscv32-esp-elf-
;;
*)
echo "Invalid IDF_TARGET value: \"${IDF_TARGET}\""
exit 1
;;
esac
LIB_DIR=${IDF_TARGET}
ELF_FILE=test.elf

63
tools/ci/check_blobs.sh Normal file
View File

@ -0,0 +1,63 @@
#!/usr/bin/env bash
set -euo pipefail
if [ -z "${IDF_PATH:-}" ]; then
echo "IDF_PATH must be set before running this script"
exit 1
fi
failed=""
# check_lib_symbols <libraray path> <symbols to look for...>
#
# If the given library contains references to the listed symbols, prints
# a message and adds the library to "failed" list.
function check_lib_symbols {
lib="$1"
symbols="${@:2}"
syms_file="$(mktemp)"
# for symbols="foo bar" create grep search argument "foo\|bar"
symbols_args="${symbols// /\\|}"
errors=0
nm -A $lib 2>/dev/null | { grep -w "${symbols_args}" > ${syms_file} || true; }
if [ $(wc -l <${syms_file}) != 0 ]; then
echo "${lib}: found illegal symbol references:"
cat ${syms_file} | sed 's/^/\t/'
failed="${failed} ${lib}"
errors=1
fi
if [ $errors == 0 ]; then
echo "${lib}: OK"
fi
rm -f ${syms_file}
}
# Check Wi-Fi, PHY libraries for references to "printf"-like functions:
illegal_symbols="printf ets_printf"
pushd ${IDF_PATH}/components/esp_wifi/lib > /dev/null
wifi_targets=$(find . -type d -name 'esp*' -exec basename {} \; | sort)
for target in ${wifi_targets}; do
for library in ${target}/*.a; do
check_lib_symbols ${library} ${illegal_symbols}
done
done
popd > /dev/null
pushd ${IDF_PATH}/components/esp_phy/lib > /dev/null
phy_targets=$(find . -type d -name 'esp*' -exec basename {} \; | sort)
for target in ${phy_targets}; do
for library in ${target}/*.a; do
check_lib_symbols ${library} ${illegal_symbols}
done
done
popd > /dev/null
# Print summary
if [ -n "${failed}" ]; then
echo "Issues found in the following libraries:"
for lib in $failed; do
echo "- $lib"
done
exit 1
fi