diff --git a/components/driver/test/test_adc2_with_wifi.c b/components/driver/test/test_adc2_with_wifi.c deleted file mode 100644 index a889592bb9..0000000000 --- a/components/driver/test/test_adc2_with_wifi.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -/* - Tests for the adc2 device driver -*/ -#include "esp_system.h" -#include "unity.h" -#include "esp_system.h" -#include "esp_event.h" -#include "esp_wifi.h" -#include "esp_log.h" -#include "nvs_flash.h" -#include "test_utils.h" -#include "driver/gpio.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "driver/gpio.h" -#define CONFIG_ADC_SUPPRESS_DEPRECATE_WARN 1 -#include "driver/adc.h" - -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C3, ESP32C2) - -static const char* TAG = "test_adc2"; - -#define DEFAULT_SSID "TEST_SSID" -#define DEFAULT_PWD "TEST_PASS" - -#if CONFIG_IDF_TARGET_ESP32 -#define ADC2_CHAN1 ADC2_CHANNEL_9 -#define ADC_WIDTH ADC_WIDTH_BIT_12 -#define ADC_HIGH 4095 -#define ADC_ERROR_THRES 20 -#elif CONFIG_IDF_TARGET_ESP32S2 -#define ADC2_CHAN1 ADC2_CHANNEL_7 -#define ADC_WIDTH ADC_WIDTH_BIT_13 -#define ADC_HIGH 8191 -#define ADC_ERROR_THRES 100 -#elif CONFIG_IDF_TARGET_ESP32C3 -#define ADC2_CHAN1 ADC2_CHANNEL_0 -#define ADC_WIDTH ADC_WIDTH_BIT_12 -#define ADC_HIGH 4095 -#define ADC_ERROR_THRES 100 -#elif CONFIG_IDF_TARGET_ESP32S3 -#define ADC2_CHAN1 ADC2_CHANNEL_0 -#define ADC_WIDTH ADC_WIDTH_BIT_12 -#define ADC_HIGH 4095 -#define ADC_ERROR_THRES 100 -#endif - -#define ADC_LOW 0 -#define TEST_NUM 8 - -#define MINUS_UNTIL_ZERO(a, b) ( ((a) > (b)) ? ((a)-(b)): 0) -#define TIME_REMAIN(start, now, timeout) ((start) >= (now) ? MINUS_UNTIL_ZERO((timeout), (now)-(start)) : -1) - - -static void wifi_event_handler(void* arg, esp_event_base_t event_base, - int32_t event_id, void* event_data) -{ - printf("ev_handle_called.\n"); - switch(event_id) { - case WIFI_EVENT_STA_START: - ESP_LOGI(TAG, "WIFI_EVENT_STA_START"); - //do not actually connect in test case - //; - break; - case WIFI_EVENT_STA_DISCONNECTED: - ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED"); - TEST_ESP_OK(esp_wifi_connect()); - break; - default: - break; - } - return ; -} - -static void ip_event_handler(void* arg, esp_event_base_t event_base, - int32_t event_id, void* event_data) -{ - ip_event_got_ip_t *event; - printf("ev_handle_called.\n"); - switch(event_id) { - case IP_EVENT_STA_GOT_IP: - event = (ip_event_got_ip_t*)event_data; - ESP_LOGI(TAG, "IP_EVENT_STA_GOT_IP"); - ESP_LOGI(TAG, "got ip:" IPSTR "\n", IP2STR(&event->ip_info.ip)); - break; - default: - break; - } - - return ; -} - -static int event_init(void) -{ - TEST_ESP_OK(esp_event_loop_create_default()); - ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL)); - ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &ip_event_handler, NULL)); - return ESP_OK; -} - -static int event_deinit(void) -{ - ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler)); - ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, ESP_EVENT_ANY_ID, &ip_event_handler)); - return ESP_OK; -} - -TEST_CASE("adc2 work with wifi","[adc]") -{ - test_case_uses_tcpip(); - - //---------------------------------WiFi init-----------------------------------// - printf("nvs init\n"); - esp_err_t r = nvs_flash_init(); - if (r == ESP_ERR_NVS_NO_FREE_PAGES || r == ESP_ERR_NVS_NEW_VERSION_FOUND) { - printf("no free pages or nvs version mismatch, erase..\n"); - TEST_ESP_OK(nvs_flash_erase()); - r = nvs_flash_init(); - } - TEST_ESP_OK( r); - esp_netif_init(); - event_init(); - esp_netif_create_default_wifi_sta(); - - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); - - /* Restrict the number of buffers to allocate to account for limited memory when running large number of tests */ - cfg.static_rx_buf_num = 2; - cfg.static_tx_buf_num = 2; - - TEST_ESP_OK(esp_wifi_init(&cfg)); - wifi_config_t wifi_config = { - .sta = { - .ssid = DEFAULT_SSID, - .password = DEFAULT_PWD - }, - }; - TEST_ESP_OK(esp_wifi_set_mode(WIFI_MODE_STA)); - TEST_ESP_OK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); - - //---------------------------------ADC init-----------------------------------// - int read_raw; - int target_value; - gpio_num_t test_adc_io; - bool test_list[TEST_NUM] ={1, 1, 0, 0, 1, 0, 1, 0}; - - adc2_pad_get_io_num(ADC2_CHAN1, &test_adc_io); - TEST_ESP_OK(adc2_config_channel_atten(ADC2_CHAN1, ADC_ATTEN_DB_0)); - printf("test_adc_io is %d\n", test_adc_io); - - //---------------------------------GPIO init-----------------------------------// - gpio_config_t gpio_cfg = { - .pin_bit_mask = BIT64(test_adc_io), - .mode = GPIO_MODE_OUTPUT, - //for powersave reasons, the GPIO should not be floating, select pullup - .pull_up_en = true, - .pull_down_en = false, - .intr_type = GPIO_INTR_DISABLE, - }; - gpio_config(&gpio_cfg); - - for (int i = 0; i < TEST_NUM; i++) { - TEST_ESP_OK(gpio_set_level(test_adc_io, test_list[i])); - target_value = test_list[i] ? ADC_HIGH : ADC_LOW; - - /* ADC2 single read before WIFI start */ - TEST_ESP_OK(adc2_get_raw(ADC2_CHAN1, ADC_WIDTH, &read_raw)); - printf("Before WiFi starts, ADC read: %d (target_value: %d)\n", read_raw, target_value); - TEST_ASSERT_INT_WITHIN(ADC_ERROR_THRES, target_value, read_raw); - - /* ADC2 single read when WIFI is on */ - TEST_ESP_OK(esp_wifi_start()); - #if CONFIG_IDF_TARGET_ESP32 - TEST_ASSERT_EQUAL(adc2_get_raw(ADC2_CHAN1, ADC_WIDTH, &read_raw), ESP_ERR_TIMEOUT); - #elif SOC_ADC_ARBITER_SUPPORTED - esp_err_t ret; - int32_t start = xTaskGetTickCount(); - int32_t now; - int32_t remain_wait_ms = 0; - int32_t timeout = pdMS_TO_TICKS(10); - - do { - now = xTaskGetTickCount(); - remain_wait_ms = pdTICKS_TO_MS(TIME_REMAIN(start, now, timeout)); - - ret = adc2_get_raw(ADC2_CHAN1, ADC_WIDTH, &read_raw); - if (ret == ESP_OK) { - printf("When WiFi is ON, ADC read: %d (target_value: %d)\n", read_raw, target_value); - TEST_ASSERT_INT_WITHIN(ADC_ERROR_THRES, target_value, read_raw); - break; - } else if (ret == ESP_ERR_INVALID_STATE) { - continue; - } else { - TEST_ESP_OK(ret); - } - } while (remain_wait_ms); - #endif - - /* ADC2 single read after WIFI is off */ - TEST_ESP_OK(esp_wifi_stop()); - TEST_ESP_OK(adc2_get_raw(ADC2_CHAN1, ADC_WIDTH, &read_raw)); - printf("After WiFi is OFF, ADC read: %d (target_value: %d)\n", read_raw, target_value); - TEST_ASSERT_INT_WITHIN(ADC_ERROR_THRES, target_value, read_raw); - } - - TEST_ESP_OK(esp_wifi_deinit()); - event_deinit(); - nvs_flash_deinit(); - - TEST_IGNORE_MESSAGE("this test case is ignored due to the critical memory leak of esp_netif and event_loop."); -} - -#endif //#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C3, ESP32S3) - - -#ifdef CONFIG_IDF_TARGET_ESP32 - -#include "driver/adc.h" - -#define ADC1_CHANNEL_4_IO (32) -#define ADC_SAMPLE_RATE (36000) -#define ADC_TEST_CHANNEL ADC1_CHANNEL_4 - -static void adc_dma_init(void) -{ - adc_digi_init_config_t adc_dma_config = { - .max_store_buf_size = 1024, - .conv_num_each_intr = 256, - .adc1_chan_mask = 1 << ADC_TEST_CHANNEL, - .adc2_chan_mask = 0, - }; - TEST_ESP_OK(adc_digi_initialize(&adc_dma_config)); - - adc_digi_pattern_config_t adc_pattern = { - .atten = ADC_ATTEN_DB_0, - .channel = ADC_TEST_CHANNEL, - .unit = 0, - .bit_width = SOC_ADC_DIGI_MAX_BITWIDTH - }; - adc_digi_configuration_t dig_cfg = { - .conv_limit_en = 1, - .conv_limit_num = 250, - .sample_freq_hz = ADC_SAMPLE_RATE, - .conv_mode = ADC_CONV_SINGLE_UNIT_1, - .format = ADC_DIGI_OUTPUT_FORMAT_TYPE1, - .pattern_num = 1, - .adc_pattern = &adc_pattern - }; - TEST_ESP_OK(adc_digi_controller_configure(&dig_cfg)); - TEST_ESP_OK(adc_digi_start()); -} - -static void continuous_adc_test(void) -{ - uint16_t *adcReadBuffer = (uint16_t *)calloc(1024, sizeof(uint16_t)); - uint32_t bytesRead; - for (int loop = 0; loop < 10; loop++) { - for (int level = 0; level <= 1; level++) { - if (level == 0) { - gpio_set_pull_mode(ADC1_CHANNEL_4_IO, GPIO_PULLDOWN_ONLY); - } else { - gpio_set_pull_mode(ADC1_CHANNEL_4_IO, GPIO_PULLUP_ONLY); - } - vTaskDelay(200 / portTICK_PERIOD_MS); - // read data from adc, will block until buffer is full - adc_digi_read_bytes((uint8_t *)adcReadBuffer, 1024 * sizeof(uint16_t), &bytesRead, ADC_MAX_DELAY); - // calc average - int64_t adcSumValue = 0; - for (size_t i = 0; i < 1024; i++) { - adcSumValue += adcReadBuffer[i] & 0xfff; - } - int adcAvgValue = adcSumValue / 1024; - printf("adc average val: %d\n", adcAvgValue); - - if (level == 0) { - TEST_ASSERT_LESS_THAN(100, adcAvgValue); - } else { - TEST_ASSERT_GREATER_THAN(4000, adcAvgValue); - } - } - } - free(adcReadBuffer); -} - -static void adc_deinit(void) -{ - adc_digi_stop(); - TEST_ESP_OK(adc_digi_deinitialize()); -} - -TEST_CASE("adc1 and i2s work with wifi","[adc][ignore]") -{ - - adc_dma_init(); - //init wifi - printf("nvs init\n"); - esp_err_t r = nvs_flash_init(); - if (r == ESP_ERR_NVS_NO_FREE_PAGES || r == ESP_ERR_NVS_NEW_VERSION_FOUND) { - printf("no free pages or nvs version mismatch, erase..\n"); - TEST_ESP_OK(nvs_flash_erase()); - r = nvs_flash_init(); - } - TEST_ESP_OK(r); - esp_netif_init(); - event_init(); - esp_netif_create_default_wifi_sta(); - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); - TEST_ESP_OK(esp_wifi_init(&cfg)); - wifi_config_t wifi_config = { - .sta = { - .ssid = DEFAULT_SSID, - .password = DEFAULT_PWD - }, - }; - TEST_ESP_OK(esp_wifi_set_mode(WIFI_MODE_STA)); - TEST_ESP_OK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); - continuous_adc_test(); - //now start wifi - printf("wifi start...\n"); - TEST_ESP_OK(esp_wifi_start()); - //test reading during wifi on - continuous_adc_test(); - //wifi stop again - printf("wifi stop...\n"); - - TEST_ESP_OK( esp_wifi_stop() ); - - TEST_ESP_OK(esp_wifi_deinit()); - - event_deinit(); - - nvs_flash_deinit(); - continuous_adc_test(); - adc_deinit(); - printf("test passed...\n"); - TEST_IGNORE_MESSAGE("this test case is ignored due to the critical memory leak of esp_netif and event_loop."); -} -#endif diff --git a/components/esp_adc/test_apps/adc/main/CMakeLists.txt b/components/esp_adc/test_apps/adc/main/CMakeLists.txt index e599f6328a..05d6d96d93 100644 --- a/components/esp_adc/test_apps/adc/main/CMakeLists.txt +++ b/components/esp_adc/test_apps/adc/main/CMakeLists.txt @@ -3,6 +3,7 @@ set(srcs "test_app_main.c" "test_adc_performance.c" "test_adc_driver.c" "test_adc_driver_iram.c" + "test_adc2_wifi.c" "test_common_adc.c") # In order for the cases defined by `TEST_CASE` to be linked into the final elf, diff --git a/components/esp_adc/test_apps/adc/main/test_adc.c b/components/esp_adc/test_apps/adc/main/test_adc.c index 31fcd2d849..8180dc22e1 100644 --- a/components/esp_adc/test_apps/adc/main/test_adc.c +++ b/components/esp_adc/test_apps/adc/main/test_adc.c @@ -6,7 +6,6 @@ #include #include #include -#include "unity.h" #include "esp_log.h" #include "soc/adc_periph.h" #include "esp_adc/adc_oneshot.h" diff --git a/components/esp_adc/test_apps/adc/main/test_adc2_wifi.c b/components/esp_adc/test_apps/adc/main/test_adc2_wifi.c new file mode 100644 index 0000000000..ae1fa35f82 --- /dev/null +++ b/components/esp_adc/test_apps/adc/main/test_adc2_wifi.c @@ -0,0 +1,210 @@ +/* + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include "esp_log.h" +#include "soc/adc_periph.h" +#include "esp_adc/adc_oneshot.h" +#include "driver/gpio.h" +#include "driver/rtc_io.h" +#include "nvs_flash.h" +#include "esp_event.h" +#include "esp_wifi.h" +#include "test_common_adc.h" +#include "test_utils.h" + +#if (SOC_ADC_PERIPH_NUM > 1) + +static const char* TAG = "test_adc2"; + +#define DEFAULT_SSID "TEST_SSID" +#define DEFAULT_PWD "TEST_PASS" + +#if CONFIG_IDF_TARGET_ESP32 +#define TEST_ADC2_CHAN0 ADC_CHANNEL_9 +#elif CONFIG_IDF_TARGET_ESP32S2 +#define TEST_ADC2_CHAN0 ADC_CHANNEL_0 +#elif CONFIG_IDF_TARGET_ESP32C3 +#define TEST_ADC2_CHAN0 ADC_CHANNEL_0 +#elif CONFIG_IDF_TARGET_ESP32S3 +#define TEST_ADC2_CHAN0 ADC_CHANNEL_0 +#endif + +#define ADC_ERROR_THRES 100 +#define TEST_NUM 8 + +#define MINUS_UNTIL_ZERO(a, b) ( ((a) > (b)) ? ((a)-(b)): 0) +#define TIME_REMAIN(start, now, timeout) ((now) >= (start) ? MINUS_UNTIL_ZERO((timeout), (now)-(start)) : -1) + + +static void wifi_event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) +{ + printf("ev_handle_called.\n"); + switch(event_id) { + case WIFI_EVENT_STA_START: + ESP_LOGI(TAG, "WIFI_EVENT_STA_START"); + //do not actually connect in test case + //; + break; + case WIFI_EVENT_STA_DISCONNECTED: + ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED"); + TEST_ESP_OK(esp_wifi_connect()); + break; + default: + break; + } + return ; +} + +static void ip_event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) +{ + ip_event_got_ip_t *event; + printf("ev_handle_called.\n"); + switch(event_id) { + case IP_EVENT_STA_GOT_IP: + event = (ip_event_got_ip_t*)event_data; + ESP_LOGI(TAG, "IP_EVENT_STA_GOT_IP"); + ESP_LOGI(TAG, "got ip:" IPSTR "\n", IP2STR(&event->ip_info.ip)); + break; + default: + break; + } + + return ; +} + +static int event_init(void) +{ + TEST_ESP_OK(esp_event_loop_create_default()); + ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL)); + ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &ip_event_handler, NULL)); + return ESP_OK; +} + +static int event_deinit(void) +{ + ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler)); + ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, ESP_EVENT_ANY_ID, &ip_event_handler)); + return ESP_OK; +} + +TEST_CASE("adc2 work with wifi","[adc]") +{ + test_case_uses_tcpip(); + + //---------------------------------WiFi init-----------------------------------// + printf("nvs init\n"); + esp_err_t r = nvs_flash_init(); + if (r == ESP_ERR_NVS_NO_FREE_PAGES || r == ESP_ERR_NVS_NEW_VERSION_FOUND) { + printf("no free pages or nvs version mismatch, erase..\n"); + TEST_ESP_OK(nvs_flash_erase()); + r = nvs_flash_init(); + } + TEST_ESP_OK( r); + esp_netif_init(); + event_init(); + esp_netif_create_default_wifi_sta(); + + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + + /* Restrict the number of buffers to allocate to account for limited memory when running large number of tests */ + cfg.static_rx_buf_num = 2; + cfg.static_tx_buf_num = 2; + + TEST_ESP_OK(esp_wifi_init(&cfg)); + wifi_config_t wifi_config = { + .sta = { + .ssid = DEFAULT_SSID, + .password = DEFAULT_PWD + }, + }; + TEST_ESP_OK(esp_wifi_set_mode(WIFI_MODE_STA)); + TEST_ESP_OK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); + + //---------------------------------ADC init-----------------------------------// + int read_raw; + int target_value; + int test_adc_io; + bool test_list[TEST_NUM] = {1, 1, 0, 0, 1, 0, 1, 0}; + + TEST_ESP_OK(adc_oneshot_channel_to_io(ADC_UNIT_2, TEST_ADC2_CHAN0, &test_adc_io)); + printf("test_adc_io is %d\n", test_adc_io); + + //-------------ADC2 Init---------------// + adc_oneshot_unit_handle_t adc2_handle; + adc_oneshot_unit_init_cfg_t init_config2 = { + .unit_id = ADC_UNIT_2, + .ulp_mode = ADC_ULP_MODE_DISABLE, + }; + TEST_ESP_OK(adc_oneshot_new_unit(&init_config2, &adc2_handle)); + + //-------------ADC2 TEST Channel 0 Config---------------// + adc_oneshot_chan_cfg_t config = { + .bitwidth = ADC_BITWIDTH_DEFAULT, + .atten = ADC_ATTEN_DB_11, + }; + TEST_ESP_OK(adc_oneshot_config_channel(adc2_handle, TEST_ADC2_CHAN0, &config)); + + for (int i = 0; i < TEST_NUM; i++) { + /* Tune test ADC channel level */ + test_adc_set_io_level(ADC_UNIT_2, TEST_ADC2_CHAN0, test_list[i]); + target_value = test_list[i] ? ADC_TEST_HIGH_VAL : ADC_TEST_LOW_VAL; + + + /* ADC2 single read before WIFI start */ + TEST_ESP_OK(adc_oneshot_read(adc2_handle, TEST_ADC2_CHAN0, &read_raw)); + printf("Before WiFi starts, ADC read: %d (target_value: %d)\n", read_raw, target_value); + TEST_ASSERT_INT_WITHIN(ADC_ERROR_THRES, target_value, read_raw); + + + /* ADC2 single read when WIFI is on */ + TEST_ESP_OK(esp_wifi_start()); +#if CONFIG_IDF_TARGET_ESP32 + TEST_ASSERT_EQUAL(ESP_ERR_TIMEOUT, adc_oneshot_read(adc2_handle, TEST_ADC2_CHAN0, &read_raw)); +#else + esp_err_t ret = ESP_FAIL; + int32_t start = xTaskGetTickCount(); + int32_t now; + int32_t remain_wait_ms = 0; + int32_t timeout = pdMS_TO_TICKS(10); + + do { + now = xTaskGetTickCount(); + remain_wait_ms = pdTICKS_TO_MS(TIME_REMAIN(start, now, timeout)); + ret = adc_oneshot_read(adc2_handle, TEST_ADC2_CHAN0, &read_raw); + if (ret == ESP_OK) { + printf("When WiFi is ON, ADC read: %d (target_value: %d)\n", read_raw, target_value); + TEST_ASSERT_INT_WITHIN(ADC_ERROR_THRES, target_value, read_raw); + break; + } else if (ret == ESP_ERR_TIMEOUT) { + continue; + } else { + TEST_ESP_OK(ret); + } + } while (remain_wait_ms); +#endif + + + /* ADC2 single read after WIFI is off */ + TEST_ESP_OK(esp_wifi_stop()); + TEST_ESP_OK(adc_oneshot_read(adc2_handle, TEST_ADC2_CHAN0, &read_raw)); + printf("After WiFi is OFF, ADC read: %d (target_value: %d)\n\n", read_raw, target_value); + TEST_ASSERT_INT_WITHIN(ADC_ERROR_THRES, target_value, read_raw); + } + + TEST_ESP_OK(esp_wifi_deinit()); + event_deinit(); + nvs_flash_deinit(); + TEST_ESP_OK(adc_oneshot_del_unit(adc2_handle)); + + TEST_IGNORE_MESSAGE("this test case is ignored due to the critical memory leak of esp_netif and event_loop."); +} + +#endif //#if (SOC_ADC_PERIPH_NUM > 1) diff --git a/components/esp_adc/test_apps/adc/main/test_common_adc.h b/components/esp_adc/test_apps/adc/main/test_common_adc.h index 05a270bf1d..740c1093cc 100644 --- a/components/esp_adc/test_apps/adc/main/test_common_adc.h +++ b/components/esp_adc/test_apps/adc/main/test_common_adc.h @@ -10,6 +10,7 @@ #include #include #include "sdkconfig.h" +#include "unity.h" #include "esp_log.h" #include "soc/soc_caps.h" #include "esp_private/adc_private.h" diff --git a/tools/ci/check_build_warnings.py b/tools/ci/check_build_warnings.py deleted file mode 100755 index 7e6eafd3fa..0000000000 --- a/tools/ci/check_build_warnings.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: Apache-2.0 -# coding=utf-8 -# -# CI script to check build logs for warnings. -# Reads the list of builds, in the format produced by find_apps.py or build_apps.py, and finds warnings in the -# log files for every build. -# Exits with a non-zero exit code if any warning is found. - -import argparse -import logging -import os -import re -import sys - -try: - from find_build_apps import BuildItem, setup_logging -except ImportError: - sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) - from find_build_apps import BuildItem, setup_logging - -WARNING_REGEX = re.compile(r'(?:error|warning)[^\w]', re.MULTILINE | re.IGNORECASE) - -IGNORE_WARNS = [ - re.compile(r_str) for r_str in [ - r'library/error\.o', - r'/.*error\S*\.o', - r'.*error.*\.c\.obj', - r'.*error.*\.c', - r'.*error.*\.cpp\.obj', - r'.*error.*\.cxx\.obj', - r'.*error.*\.cc\.obj', - r'-Werror', - r'error\.d', - r'/.*error\S*.d', - r'reassigning to symbol', - r'changes choice state', - r'crosstool_version_check\.cmake', - r'CryptographyDeprecationWarning', - r'Warning: \d+/\d+ app partitions are too small for binary', - ] -] - - -def line_has_warnings(line): # type: (str) -> bool - if not WARNING_REGEX.search(line): - return False - - has_warnings = True - for ignored in IGNORE_WARNS: - if re.search(ignored, line): - has_warnings = False - break - - return has_warnings - - -def main(): # type: () -> None - parser = argparse.ArgumentParser(description='ESP-IDF app builder') - parser.add_argument( - '-v', - '--verbose', - action='count', - help='Increase the logging level of the script. Can be specified multiple times.', - ) - parser.add_argument( - '--log-file', - type=argparse.FileType('w'), - help='Write the script log to the specified file, instead of stderr', - ) - parser.add_argument( - 'build_list', - type=argparse.FileType('r'), - nargs='?', - default=sys.stdin, - help='Name of the file to read the list of builds from. If not specified, read from stdin.', - ) - args = parser.parse_args() - setup_logging(args) - - build_items = [BuildItem.from_json(line) for line in args.build_list] - if not build_items: - logging.warning('Empty build list') - SystemExit(0) - - found_warnings = 0 - for build_item in build_items: - if not build_item.build_log_path: - logging.debug('No log file for {}'.format(build_item.work_dir)) - continue - with open(build_item.build_log_path, 'r') as log_file: - for line_no, line in enumerate(log_file): - if line_has_warnings(line): - logging.error('Issue in app {}, config {}:'.format(build_item.app_dir, build_item.config_name)) - logging.error(line.rstrip('\n')) - logging.error('See {}:{} for details'.format(os.path.basename(build_item.build_log_path), - line_no + 1)) - found_warnings += 1 - break - - if found_warnings: - logging.error('Checked {} builds, found {} warnings'.format(len(build_items), found_warnings)) - raise SystemExit(1) - - logging.info('No warnings found') - - -if __name__ == '__main__': - main() diff --git a/tools/ci/ignore_build_warnings.txt b/tools/ci/ignore_build_warnings.txt index fe3f6c1623..92233a00aa 100644 --- a/tools/ci/ignore_build_warnings.txt +++ b/tools/ci/ignore_build_warnings.txt @@ -14,3 +14,4 @@ crosstool_version_check\.cmake CryptographyDeprecationWarning Warning: \d+/\d+ app partitions are too small for binary CMake Deprecation Warning at main/lib/tinyxml2/CMakeLists\.txt:11 \(cmake_policy\) +The smallest .+ partition is nearly full \(\d+% free space left\)!