From 4c0ddd34b4419140c5b33d59e7717fcfcd24283a Mon Sep 17 00:00:00 2001 From: morris Date: Tue, 15 Jun 2021 17:11:50 +0800 Subject: [PATCH] ci: added script to check api violations --- .gitlab/ci/pre_check.yml | 2 +- components/nvs_flash/mock/int/crc.h | 2 +- tools/ci/{check_rom_apis.sh => check_api_violation.sh} | 10 +++++++++- tools/ci/executable-list.txt | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) rename tools/ci/{check_rom_apis.sh => check_api_violation.sh} (69%) diff --git a/.gitlab/ci/pre_check.yml b/.gitlab/ci/pre_check.yml index 3569ba593b..47eb36f826 100644 --- a/.gitlab/ci/pre_check.yml +++ b/.gitlab/ci/pre_check.yml @@ -50,7 +50,7 @@ check_rom_api_header: extends: .pre_check_job_template script: - tools/ci/check_examples_rom_header.sh - - tools/ci/check_rom_apis.sh + - tools/ci/check_api_violation.sh check_python_style: extends: diff --git a/components/nvs_flash/mock/int/crc.h b/components/nvs_flash/mock/int/crc.h index f675da3271..bbb581f436 100644 --- a/components/nvs_flash/mock/int/crc.h +++ b/components/nvs_flash/mock/int/crc.h @@ -22,7 +22,7 @@ extern "C" { /** * Mock function to replace ESP ROM function used in IDF with a Linux implementation. - * Note: the name MUST have the prefix esp_rom_* since tools/ci/check_rom_apis.sh checks and complains otherwise. + * Note: the name MUST have the prefix esp_rom_* since tools/ci/check_api_violation.sh checks and complains otherwise. */ uint32_t esp_rom_crc32_le(uint32_t crc, const uint8_t* buf, size_t len); diff --git a/tools/ci/check_rom_apis.sh b/tools/ci/check_api_violation.sh similarity index 69% rename from tools/ci/check_rom_apis.sh rename to tools/ci/check_api_violation.sh index 2e1ecead4c..589b7c839d 100755 --- a/tools/ci/check_rom_apis.sh +++ b/tools/ci/check_api_violation.sh @@ -3,7 +3,6 @@ set -uo pipefail # ESP-IDF should only use the ROM API that has a prefix "esp_rom_" - cd ${IDF_PATH} # git ls-files operates on working directory only, make sure we're at the top directory deprecated_rom_apis=$(cat ${IDF_PATH}/components/esp_rom/esp32/ld/esp32.rom.api.ld | grep "esp_rom_" | cut -d "=" -f 2 | cut -d " " -f 2) files_to_search=$(git ls-files --full-name '*.c' ':!:components/esp_rom/') @@ -21,3 +20,12 @@ if [ $count -gt 0 ]; then echo "Please try to use the APIs listed in esp_rom/include/esp_rom_xxx.h" exit 1 fi + +# ESP-IDF `hal` component shouldn't call "assert()" directlly +files_to_search=$(git ls-files --full-name 'components/hal/*') +found_libc_assert=$(grep -E '\W+assert\(' $files_to_search) +if [ -n "$found_libc_assert" ]; then + echo "hal assert violation" + echo $found_libc_assert + echo "Please use HAL_ASSERT() instead of assert() in hal component" +fi diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index a94b5cde5f..044ea4fa33 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -38,6 +38,7 @@ install.sh tools/build_apps.py tools/check_python_dependencies.py tools/ci/build_template_app.sh +tools/ci/check_api_violation.sh tools/ci/check_build_warnings.py tools/ci/check_callgraph.py tools/ci/check_codeowners.py @@ -48,7 +49,6 @@ tools/ci/check_executables.py tools/ci/check_idf_version.sh tools/ci/check_kconfigs.py tools/ci/check_readme_links.py -tools/ci/check_rom_apis.sh tools/ci/check_rules_yml.py tools/ci/check_tools_files_patterns.py tools/ci/check_type_comments.py