Merge branch 'feature/check_wifi_lib_md5_on_host' into 'master'

esp_wifi: check header files MD5 on host

See merge request espressif/esp-idf!6656
This commit is contained in:
Jiang Jiang Jian 2019-11-28 16:48:53 +08:00
commit e2e2de95b4
9 changed files with 85 additions and 130 deletions

@ -1 +1 @@
Subproject commit 057749197b1cebb2da34e2c2a81096149eb6ecca
Subproject commit a374dbe1a8dad21af8db3642cd3c89ea63c48afc

View File

@ -7,31 +7,3 @@ idf_component_register(SRC_DIRS ${srcdirs}
INCLUDE_DIRS . ${CMAKE_CURRENT_BINARY_DIR}
REQUIRES unity test_utils nvs_flash ulp esp_common
)
idf_component_get_property(esp_wifi_dir esp_wifi COMPONENT_DIR)
# Calculate MD5 value of header file esp_wifi_os_adapter.h
file(MD5 ${esp_wifi_dir}/include/esp_private/wifi_os_adapter.h WIFI_OS_ADAPTER_MD5)
string(SUBSTRING "${WIFI_OS_ADAPTER_MD5}" 0 7 WIFI_OS_ADAPTER_MD5)
# Calculate MD5 value of header file esp_wifi_crypto_types.h
file(MD5 ${esp_wifi_dir}/include/esp_wifi_crypto_types.h WIFI_CRYPTO_MD5)
string(SUBSTRING "${WIFI_CRYPTO_MD5}" 0 7 WIFI_CRYPTO_MD5)
# Calculate MD5 value of header file esp_coexist_adapter.h
file(MD5 ${esp_wifi_dir}/include/esp_coexist_adapter.h COEX_ADAPTER_MD5)
string(SUBSTRING "${COEX_ADAPTER_MD5}" 0 7 COEX_ADAPTER_MD5)
# Calculate MD5 value of header file esp_wifi_types.h
file(MD5 ${esp_wifi_dir}/include/esp_wifi_types.h WIFI_TYPE_MD5)
string(SUBSTRING "${WIFI_TYPE_MD5}" 0 7 WIFI_TYPE_MD5)
# Calculate MD5 value of header file esp_wifi.h
file(MD5 ${esp_wifi_dir}/include/esp_wifi.h WIFI_ESP_WIFI_MD5)
string(SUBSTRING "${WIFI_ESP_WIFI_MD5}" 0 7 WIFI_ESP_WIFI_MD5)
add_definitions(-DWIFI_OS_ADAPTER_MD5=\"${WIFI_OS_ADAPTER_MD5}\")
add_definitions(-DWIFI_CRYPTO_MD5=\"${WIFI_CRYPTO_MD5}\")
add_definitions(-DCOEX_ADAPTER_MD5=\"${COEX_ADAPTER_MD5}\")
add_definitions(-DWIFI_TYPE_MD5=\"${WIFI_TYPE_MD5}\")
add_definitions(-DWIFI_ESP_WIFI_MD5=\"${WIFI_ESP_WIFI_MD5}\")

View File

@ -6,23 +6,3 @@ COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-a
COMPONENT_SRCDIRS := .
COMPONENT_SRCDIRS += esp32
# Calculate MD5 value of header file esp_wifi_os_adapter.h
WIFI_OS_ADAPTER_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp_wifi/include/esp_private/wifi_os_adapter.h | cut -c 1-7)\"
CFLAGS+=-DWIFI_OS_ADAPTER_MD5=$(WIFI_OS_ADAPTER_MD5_VAL)
# Calculate MD5 value of header file esp_wifi_crypto_types.h
WIFI_CRYPTO_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp_wifi/include/esp_wifi_crypto_types.h | cut -c 1-7)\"
CFLAGS+=-DWIFI_CRYPTO_MD5=$(WIFI_CRYPTO_MD5_VAL)
# Calculate MD5 value of header file esp_coexist_adapter.h
COEX_ADAPTER_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp_wifi/include/esp_coexist_adapter.h | cut -c 1-7)\"
CFLAGS+=-DCOEX_ADAPTER_MD5=$(COEX_ADAPTER_MD5_VAL)
# Calculate MD5 value of header file esp_wifi_types.h
WIFI_TYPE_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp_wifi/include/esp_wifi_types.h | cut -c 1-7)\"
CFLAGS+=-DWIFI_TYPE_MD5=$(WIFI_TYPE_MD5_VAL)
# Calculate MD5 value of header file esp_wifi.h
WIFI_ESP_WIFI_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp_wifi/include/esp_wifi.h | cut -c 1-7)\"
CFLAGS+=-DWIFI_ESP_WIFI_MD5=$(WIFI_ESP_WIFI_MD5_VAL)

View File

@ -1,59 +0,0 @@
/*
Tests for the Wi-Fi
*/
#include "unity.h"
#include "esp_log.h"
#include "esp_private/wifi.h"
#include "esp_coexist_internal.h"
static const char* TAG = "test_header_files_md5";
TEST_CASE("wifi os adapter MD5","[wifi]")
{
const char *test_wifi_os_funcs_md5 = WIFI_OS_ADAPTER_MD5;
ESP_LOGI(TAG, "test esp_wifi_os_adapter.h MD5...");
TEST_ESP_OK(esp_wifi_internal_osi_funcs_md5_check(test_wifi_os_funcs_md5));
ESP_LOGI(TAG, "test passed...");
}
TEST_CASE("wifi crypto types MD5","[wifi]")
{
const char *test_wifi_crypto_funcs_md5 = WIFI_CRYPTO_MD5;
ESP_LOGI(TAG, "test esp_wifi_crypto_types.h MD5...");
TEST_ESP_OK(esp_wifi_internal_crypto_funcs_md5_check(test_wifi_crypto_funcs_md5));
ESP_LOGI(TAG, "test passed...");
}
TEST_CASE("coexist adapter MD5","[coex]")
{
const char *test_coex_adapter_funcs_md5 = COEX_ADAPTER_MD5;
ESP_LOGI(TAG, "test esp_coexist_adapter.h MD5...");
TEST_ESP_OK(esp_coex_adapter_funcs_md5_check(test_coex_adapter_funcs_md5));
ESP_LOGI(TAG, "test passed...");
}
TEST_CASE("wifi type MD5","[wifi]")
{
const char *test_wifi_type_md5 = WIFI_TYPE_MD5;
ESP_LOGI(TAG, "test esp_wifi_types.h MD5...");
TEST_ESP_OK(esp_wifi_internal_wifi_type_md5_check(test_wifi_type_md5));
ESP_LOGI(TAG, "test passed...");
}
TEST_CASE("esp wifi MD5","[wifi]")
{
const char *test_esp_wifi_md5 = WIFI_ESP_WIFI_MD5;
ESP_LOGI(TAG, "test esp_wifi.h MD5...");
TEST_ESP_OK(esp_wifi_internal_esp_wifi_md5_check(test_esp_wifi_md5));
ESP_LOGI(TAG, "test passed...");
}

View File

@ -0,0 +1,71 @@
#!/bin/bash
set -euo pipefail
if [ -z "${IDF_PATH:-}" ]; then
echo "IDF_PATH must be set before running this script"
exit 1
fi
if [ -z "${IDF_TARGET:-}" ]; then
echo "IDF_TARGET must be set before running this script"
exit 1
fi
case $IDF_TARGET in
esp32)
PREFIX=xtensa-esp32-elf-
LIB_DIR=esp32
;;
esp32s2beta)
PREFIX=xtensa-esp32s2-elf-
LIB_DIR=esp32s2beta
;;
*)
echo "Invalid IDF_TARGET value: \"${IDF_TARGET}\""
exit 1
;;
esac
ELF_FILE=test.elf
${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${ELF_FILE} \
-u g_esp_wifi_md5 \
-u g_wifi_crypto_funcs_md5 \
-u g_wifi_type_md5 \
-u g_wifi_osi_funcs_md5 \
-u g_coex_adapter_funcs_md5 \
-u g_wifi_supplicant_funcs_md5 \
${IDF_PATH}/components/esp_wifi/lib/${LIB_DIR}/*.a
FAILURES=0
function check_md5()
{
FILENAME=$1
SYMBOL=$2
GDB_COMMAND="printf \"%s\\n\", (const char*) ${SYMBOL}"
MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${ELF_FILE} -ex "${GDB_COMMAND}")
MD5_FROM_HEADER=$(md5sum ${FILENAME} | cut -c 1-7)
echo "Checking ${FILENAME}:"
echo " ${MD5_FROM_HEADER} - from header file"
echo " ${MD5_FROM_LIB} - from library"
if [ "${MD5_FROM_LIB}" != "${MD5_FROM_HEADER}" ]; then
echo " error: MD5 mismatch!"
FAILURES=$(($FAILURES+1))
fi
}
echo "Checking libraries for target ${IDF_TARGET}..."
check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi.h g_esp_wifi_md5
check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_private/wifi_os_adapter.h g_wifi_osi_funcs_md5
check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_crypto_types.h g_wifi_crypto_funcs_md5
check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_wifi_types.h g_wifi_type_md5
check_md5 ${IDF_PATH}/components/esp_wifi/include/esp_coexist_adapter.h g_coex_adapter_funcs_md5
check_md5 ${IDF_PATH}/components/wpa_supplicant/src/esp_supplicant/esp_wifi_driver.h g_wifi_supplicant_funcs_md5
if [ $FAILURES -gt 0 ]; then
exit 1
fi

View File

@ -7,5 +7,4 @@ COMPONENT_SRCDIRS := .
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
WIFI_SUPPLICANT_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/wpa_supplicant/src/esp_supplicant/esp_wifi_driver.h | cut -c 1-7)\"
CFLAGS+=-DWIFI_SUPPLICANT_MD5=$(WIFI_SUPPLICANT_MD5_VAL) -DCONFIG_WPA3_SAE
CFLAGS+= -DCONFIG_WPA3_SAE

View File

@ -1,20 +0,0 @@
/*
Tests for the Wi-Fi
*/
#include "unity.h"
#include "esp_log.h"
#include "utils/common.h"
#include "esp_supplicant/esp_wifi_driver.h"
static const char* TAG = "test_header_files_md5";
TEST_CASE("wifi supplicant header files MD5","[wpa_supplicant]")
{
const char *test_wifi_supplicant_header_md5 = WIFI_SUPPLICANT_MD5;
ESP_LOGI(TAG, "test wifi supplicant MD5...");
TEST_ESP_OK(esp_wifi_internal_supplicant_header_md5_check(test_wifi_supplicant_header_md5));
ESP_LOGI(TAG, "test passed...");
}

View File

@ -114,6 +114,17 @@ check_submodule_sync:
- git submodule update --recursive
- echo "IDF was cloned from ${PUBLIC_IDF_URL} completely"
check_wifi_lib_md5:
extends: .check_job_template
tags:
- build
dependencies: []
script:
- tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)"
- git submodule update --init components/esp_wifi/lib
- IDF_TARGET=esp32 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh
- IDF_TARGET=esp32s2beta $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh
check_artifacts_expire_time:
extends: .check_job_template
script:

View File

@ -1,6 +1,7 @@
components/app_update/otatool.py
components/efuse/efuse_table_gen.py
components/efuse/test_efuse_host/efuse_tests.py
components/esp_wifi/test_md5/test_md5.sh
components/espcoredump/espcoredump.py
components/espcoredump/test/test_espcoredump.py
components/espcoredump/test/test_espcoredump.sh