From 6b0d93efd42f6ddafa8a023369d02c05f5d9952f Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Tue, 9 May 2023 10:24:43 +0800 Subject: [PATCH] ci: misc fixes for newlib test app Enabled additional tests for C2, added config for testing with newlib nano as well as cleaned up old configs --- .../test_apps/newlib/main/test_newlib.c | 38 +++++++++++-------- .../newlib/test_apps/newlib/main/test_time.c | 10 ++--- .../newlib/test_apps/newlib/pytest_newlib.py | 2 +- .../test_apps/newlib/sdkconfig.ci.default | 2 + .../test_apps/newlib/sdkconfig.ci.options | 2 + .../test_apps/newlib/sdkconfig.ci.psram_esp32 | 10 ----- .../newlib/sdkconfig.ci.single_core_esp32s2 | 4 -- 7 files changed, 33 insertions(+), 35 deletions(-) create mode 100644 components/newlib/test_apps/newlib/sdkconfig.ci.options delete mode 100644 components/newlib/test_apps/newlib/sdkconfig.ci.single_core_esp32s2 diff --git a/components/newlib/test_apps/newlib/main/test_newlib.c b/components/newlib/test_apps/newlib/main/test_newlib.c index b28c0de2d7..741af5c34c 100644 --- a/components/newlib/test_apps/newlib/main/test_newlib.c +++ b/components/newlib/test_apps/newlib/main/test_newlib.c @@ -123,43 +123,51 @@ TEST_CASE("test asctime", "[newlib]") TEST_ASSERT_EQUAL_STRING(buf, time_str); } -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32H2) static bool fn_in_rom(void *fn) { const int fnaddr = (int)fn; return (fnaddr >= SOC_IROM_MASK_LOW && fnaddr < SOC_IROM_MASK_HIGH); } +/* Older chips have newlib nano in rom as well, but this is not linked in due to us now using 64 bit time_t + and the ROM code was compiled for 32 bit. + */ +#define PRINTF_NANO_IN_ROM (CONFIG_NEWLIB_NANO_FORMAT && (CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32H2)) +#define SSCANF_NANO_IN_ROM (CONFIG_NEWLIB_NANO_FORMAT && CONFIG_IDF_TARGET_ESP32C2) TEST_CASE("check if ROM or Flash is used for functions", "[newlib]") { -#if CONFIG_NEWLIB_NANO_FORMAT || ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT +#if PRINTF_NANO_IN_ROM || (ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT && !CONFIG_NEWLIB_NANO_FORMAT) TEST_ASSERT(fn_in_rom(vfprintf)); #else TEST_ASSERT_FALSE(fn_in_rom(vfprintf)); -#endif // CONFIG_NEWLIB_NANO_FORMAT || ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT +#endif // PRINTF_NANO_IN_ROM || (ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT && !CONFIG_NEWLIB_NANO_FORMAT) -#if (CONFIG_NEWLIB_NANO_FORMAT && (CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C2)) || ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT +#if SSCANF_NANO_IN_ROM || (ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT && !CONFIG_NEWLIB_NANO_FORMAT) TEST_ASSERT(fn_in_rom(sscanf)); #else TEST_ASSERT_FALSE(fn_in_rom(sscanf)); -#endif // (CONFIG_NEWLIB_NANO_FORMAT && CONFIG_IDF_TARGET_x) || ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT +#endif // SSCANF_NANO_IN_ROM || (ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT && !CONFIG_NEWLIB_NANO_FORMAT) -#if defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_SPIRAM) - TEST_ASSERT(fn_in_rom(atoi)); - TEST_ASSERT(fn_in_rom(strtol)); -#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3) \ - || defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C6) - /* S3 and C3 always use these from ROM */ - TEST_ASSERT(fn_in_rom(atoi)); - TEST_ASSERT(fn_in_rom(strtol)); +#if defined(CONFIG_IDF_TARGET_ESP32) + +#if defined(CONFIG_SPIRAM_CACHE_WORKAROUND) + TEST_ASSERT_FALSE(fn_in_rom(atoi)); + TEST_ASSERT_FALSE(fn_in_rom(strtol)); #else + TEST_ASSERT(fn_in_rom(atoi)); + TEST_ASSERT(fn_in_rom(strtol)); +#endif //CONFIG_SPIRAM_CACHE_WORKAROUND + +#elif CONFIG_IDF_TARGET_ESP32S2 /* S2 do not have these in ROM */ TEST_ASSERT_FALSE(fn_in_rom(atoi)); TEST_ASSERT_FALSE(fn_in_rom(strtol)); -#endif // defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_SPIRAM) +#else + TEST_ASSERT(fn_in_rom(atoi)); + TEST_ASSERT(fn_in_rom(strtol)); +#endif // defined(CONFIG_IDF_TARGET_ESP32) } -#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32H2) #ifndef CONFIG_NEWLIB_NANO_FORMAT TEST_CASE("test 64bit int formats", "[newlib]") diff --git a/components/newlib/test_apps/newlib/main/test_time.c b/components/newlib/test_apps/newlib/main/test_time.c index 1c2ca098ff..b1fe10bea8 100644 --- a/components/newlib/test_apps/newlib/main/test_time.c +++ b/components/newlib/test_apps/newlib/main/test_time.c @@ -549,16 +549,14 @@ TEST_CASE("test time functions wide 64 bits", "[newlib]") #endif // !_USE_LONG_TIME_T -// IDF-6962 following test cases don't pass on C2 -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) #if defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) && defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER ) extern int64_t s_microseconds_offset; static const uint64_t s_start_timestamp = 1606838354; -static RTC_NOINIT_ATTR uint64_t s_saved_time; -static RTC_NOINIT_ATTR uint64_t s_time_in_reboot; +static __NOINIT_ATTR uint64_t s_saved_time; +static __NOINIT_ATTR uint64_t s_time_in_reboot; typedef enum { TYPE_REBOOT_ABORT = 0, @@ -579,6 +577,9 @@ static void print_counters(void) static void set_initial_condition(type_reboot_t type_reboot, int error_time) { + s_saved_time = 0; + s_time_in_reboot = 0; + print_counters(); struct timeval tv = { .tv_sec = s_start_timestamp, .tv_usec = 0, }; @@ -651,4 +652,3 @@ TEST_CASE_MULTIPLE_STAGES("Timestamp after abort is correct in case RTC & High-r TEST_CASE_MULTIPLE_STAGES("Timestamp after restart is correct in case RTC & High-res timer have + big error", "[newlib][reset=SW_CPU_RESET]", set_timestamp2, check_time); TEST_CASE_MULTIPLE_STAGES("Timestamp after restart is correct in case RTC & High-res timer have - big error", "[newlib][reset=SW_CPU_RESET]", set_timestamp3, check_time); #endif // CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER && CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER -#endif // !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) diff --git a/components/newlib/test_apps/newlib/pytest_newlib.py b/components/newlib/test_apps/newlib/pytest_newlib.py index dab6899ade..5fd6c062c5 100644 --- a/components/newlib/test_apps/newlib/pytest_newlib.py +++ b/components/newlib/test_apps/newlib/pytest_newlib.py @@ -10,8 +10,8 @@ from pytest_embedded import Dut 'config', [ pytest.param('default', marks=[pytest.mark.supported_targets]), + pytest.param('options', marks=[pytest.mark.supported_targets]), pytest.param('single_core_esp32', marks=[pytest.mark.esp32]), - pytest.param('single_core_esp32s2', marks=[pytest.mark.esp32s2]), pytest.param('psram_esp32', marks=[pytest.mark.esp32]), pytest.param('release_esp32', marks=[pytest.mark.esp32]), pytest.param('release_esp32c2', marks=[pytest.mark.esp32c2]), diff --git a/components/newlib/test_apps/newlib/sdkconfig.ci.default b/components/newlib/test_apps/newlib/sdkconfig.ci.default index e69de29bb2..21dc4813e2 100644 --- a/components/newlib/test_apps/newlib/sdkconfig.ci.default +++ b/components/newlib/test_apps/newlib/sdkconfig.ci.default @@ -0,0 +1,2 @@ +# Test all chips with nano off, nano on is tested in options config +CONFIG_NEWLIB_NANO_FORMAT=n diff --git a/components/newlib/test_apps/newlib/sdkconfig.ci.options b/components/newlib/test_apps/newlib/sdkconfig.ci.options new file mode 100644 index 0000000000..caf70fc890 --- /dev/null +++ b/components/newlib/test_apps/newlib/sdkconfig.ci.options @@ -0,0 +1,2 @@ +# Test with misc newlib config options turned on +CONFIG_NEWLIB_NANO_FORMAT=y diff --git a/components/newlib/test_apps/newlib/sdkconfig.ci.psram_esp32 b/components/newlib/test_apps/newlib/sdkconfig.ci.psram_esp32 index e53effec70..e712a20a6c 100644 --- a/components/newlib/test_apps/newlib/sdkconfig.ci.psram_esp32 +++ b/components/newlib/test_apps/newlib/sdkconfig.ci.psram_esp32 @@ -1,12 +1,2 @@ CONFIG_IDF_TARGET="esp32" CONFIG_SPIRAM=y - -# moved from old psram config -CONFIG_ESP_INT_WDT_TIMEOUT_MS=800 -CONFIG_SPIRAM_OCCUPY_NO_HOST=y -CONFIG_ESP_WIFI_RX_IRAM_OPT=n -CONFIG_ESP_WIFI_IRAM_OPT=n -# Disable encrypted flash reads/writes to save IRAM in this build configuration -CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=n -CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y -CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y diff --git a/components/newlib/test_apps/newlib/sdkconfig.ci.single_core_esp32s2 b/components/newlib/test_apps/newlib/sdkconfig.ci.single_core_esp32s2 deleted file mode 100644 index 00ca80c09c..0000000000 --- a/components/newlib/test_apps/newlib/sdkconfig.ci.single_core_esp32s2 +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG_IDF_TARGET="esp32s2" -CONFIG_FREERTOS_UNICORE=y -# IDF-6964 test nano format in this configuration (current tests are not passing, so keep disabled for now) -CONFIG_NEWLIB_NANO_FORMAT=n