Reactivate some tests and functionality that had accidentally been disabled due to incorrect checks (#372)

* Start on fixing some unintentionally skipped tests

* Reactivate stats tests

* CI fixes

* Include cinttypes

* Fault & crash data RAM working on STM32H7!
pull/15530/head
Jamie Smith 2024-10-14 09:56:11 -07:00 committed by GitHub
parent edf13ff1a1
commit b2d11fcf6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 90 additions and 44 deletions

View File

@ -146,12 +146,12 @@ jobs:
# Note: We have to set a wifi network name and password so that the test will compile on devices that use wifi
run: |
rm -rf __build
cmake -S . -B __build -GNinja -DUPLOAD_METHOD=NONE -DMBED_GREENTEA_WIFI_SECURE_SSID=SomeNetwork -DMBED_GREENTEA_WIFI_SECURE_PASSWORD=SomePassword -DCMAKE_CTEST_ARGUMENTS="--output-on-failure;-V" -DMBED_BUILD_GREENTEA_TESTS=ON -DMBED_GREENTEA_TEST_BAREMETAL=ON -DMBED_GREENTEA_SERIAL_PORT=/dev/ttyDUMMY -DMBED_TARGET=${{ matrix.target }} -DMBED_APP_JSON_PATH=TESTS/configs/baremetal.json
cmake -S . -B __build -GNinja -DUPLOAD_METHOD=NONE -DMBED_GREENTEA_WIFI_SECURE_SSID=SomeNetwork -DMBED_GREENTEA_WIFI_SECURE_PASSWORD=SomePassword -DCMAKE_CTEST_ARGUMENTS="--output-on-failure;-V" -DMBED_BUILD_GREENTEA_TESTS=ON -DMBED_GREENTEA_TEST_BAREMETAL=ON -DMBED_GREENTEA_SERIAL_PORT=/dev/ttyDUMMY -DMBED_TARGET=${{ matrix.target }} -DMBED_APP_JSON_PATH=TESTS/configs/greentea_baremetal.json5
cmake --build __build
- name: Build ${{ matrix.target }} with full profile
if: ${{ matrix.profile == 'full' }}
run: |
rm -rf __build
cmake -S . -B __build -GNinja -DUPLOAD_METHOD=NONE -DMBED_GREENTEA_WIFI_SECURE_SSID=SomeNetwork -DMBED_GREENTEA_WIFI_SECURE_PASSWORD=SomePassword -DCMAKE_CTEST_ARGUMENTS="--output-on-failure;-V" -DMBED_BUILD_GREENTEA_TESTS=ON -DMBED_GREENTEA_SERIAL_PORT=/dev/ttyDUMMY -DMBED_TARGET=${{ matrix.target }}
cmake -S . -B __build -GNinja -DUPLOAD_METHOD=NONE -DMBED_GREENTEA_WIFI_SECURE_SSID=SomeNetwork -DMBED_GREENTEA_WIFI_SECURE_PASSWORD=SomePassword -DCMAKE_CTEST_ARGUMENTS="--output-on-failure;-V" -DMBED_BUILD_GREENTEA_TESTS=ON -DMBED_GREENTEA_SERIAL_PORT=/dev/ttyDUMMY -DMBED_TARGET=${{ matrix.target }} -DMBED_APP_JSON_PATH=TESTS/configs/greentea_full.json5
cmake --build __build

View File

@ -0,0 +1,14 @@
{
"target_overrides": {
"*": {
"target.c_lib": "small"
}
},
"overrides": {
// Enable Mbed Stats tests
"platform.all-stats-enabled": 1,
// Enable auto reboot on error, required for crash reporting test
"platform.fatal-error-auto-reboot-enabled": true
}
}

View File

@ -0,0 +1,9 @@
{
"overrides": {
// Enable Mbed Stats tests
"platform.all-stats-enabled": 1,
// Enable auto reboot on error, required for crash reporting test
"platform.fatal-error-auto-reboot-enabled": true
}
}

View File

@ -34,7 +34,7 @@
#elif COMPONENT_NUSD
#define TEST_BLOCK_DEVICE_TYPE "NUSD"
#define TEST_USE_FILESYSTEM FS_FAT
#elif COMPONENT_FLASHIAP && MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE
#elif DEVICE_FLASH && MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE
#define TEST_BLOCK_DEVICE_TYPE "FLASHIAP"
#else
#define TEST_BLOCK_DEVICE_TYPE "UNKNOWN"

View File

@ -25,7 +25,7 @@
// Whole class is not supported if entropy is not enabled
// Flash device is required as Device Key is currently depending on it
#if !DEVICE_FLASH || !defined(COMPONENT_FLASHIAP)
#if !DEVICE_FLASH
#undef DEVICEKEY_ENABLED
#define DEVICEKEY_ENABLED 0
#endif

View File

@ -5,7 +5,7 @@ if(NOT "DEVICE_TRNG=1" IN_LIST MBED_TARGET_DEFINITIONS)
set(TEST_SKIPPED "True RNG is not supported for this target so device key cannot be used")
endif()
if(NOT ("DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS AND "COMPONENT_FLASHIAP=1" IN_LIST MBED_TARGET_DEFINITIONS))
if(NOT "DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS)
set(TEST_SKIPPED "Flash IAP is not supported for this target so device key cannot be used")
endif()

View File

@ -220,7 +220,7 @@ utest::v1::status_t case_its_setup_handler(const Case *const source, const size_
Case cases[] = {
Case("PSA prot internal storage - Basic", case_its_setup_handler<its>, pits_ps_test<its>, case_its_teardown_handler),
Case("PSA prot internal storage - Write-once", case_its_setup_handler<its>, pits_ps_write_once_test<its>, case_its_teardown_handler),
#if COMPONENT_FLASHIAP
#if DEVICE_FLASH
Case("PSA protected storage - Basic", case_its_setup_handler<ps>, pits_ps_test<ps>),
Case("PSA protected storage - Write-once", case_its_setup_handler<ps>, pits_ps_write_once_test<ps>)
#endif

View File

@ -320,6 +320,13 @@ WEAK MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_stat
//Protect report_error_ctx while we update it
core_util_critical_section_enter();
report_error_ctx = last_error_ctx;
// If the MCU has a data cache, ensure that the fault data is flushed to main memory
// before reboot
#if __DCACHE_PRESENT
SCB_CleanDCache_by_Addr(&report_error_ctx, sizeof(mbed_crash_data_t));
#endif
core_util_critical_section_exit();
//We need not call delete_mbed_crc(crc_obj) here as we are going to reset the system anyway, and calling delete while handling a fatal error may cause nested exception
#if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED && (MBED_CONF_PLATFORM_ERROR_REBOOT_MAX > 0)

View File

@ -1,10 +1,8 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
include(mbed_greentea)
if(NOT DEFINED MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED)
set(TEST_SKIPPED "crash_reporting test not supported.")
if(NOT "MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS)
set(TEST_SKIPPED "CRC is not supported for this target")
endif()
mbed_greentea_add_test(

View File

@ -3,11 +3,14 @@
include(mbed_greentea)
if(NOT DEFINED MBED_CPU_STATS_ENABLED OR NOT "DEVICE_LPTICKER=1" IN_LIST MBED_TARGET_DEFINITIONS
OR NOT "DEVICE_SLEEP=1" IN_LIST MBED_TARGET_DEFINITIONS)
if(NOT "DEVICE_LPTICKER=1" IN_LIST MBED_TARGET_DEFINITIONS OR NOT "DEVICE_SLEEP=1" IN_LIST MBED_TARGET_DEFINITIONS)
set(TEST_SKIPPED "Stats cpu test not supported.")
endif()
if((NOT "MBED_CPU_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) AND (NOT "MBED_ALL_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS))
set(TEST_SKIPPED "CPU stats not enabled")
endif()
mbed_greentea_add_test(
TEST_NAME
mbed-platform-stats-cpu

View File

@ -39,8 +39,8 @@ DigitalOut led1(LED1);
#define MAX_THREAD_STACK 384
#endif
#define SAMPLE_TIME 1000 // msec
#define LOOP_TIME 2000 // msec
#define SAMPLE_TIME 1s
#define LOOP_TIME 2s
static int32_t wait_time = 5000;
@ -64,7 +64,7 @@ void get_cpu_usage()
while (1) {
mbed_stats_cpu_get(&stats);
uint64_t diff = (stats.idle_time - prev_idle_time);
uint8_t usage = 100 - ((diff * 100) / (SAMPLE_TIME * 1000));
uint8_t usage = 100 - ((diff * 100) / std::chrono::duration_cast<std::chrono::milliseconds>(SAMPLE_TIME).count());
prev_idle_time = stats.idle_time;
TEST_ASSERT_NOT_EQUAL(0, usage);
ThisThread::sleep_for(SAMPLE_TIME);
@ -76,7 +76,7 @@ void test_cpu_info(void)
mbed_stats_cpu_t stats;
// Additional read to make sure timer is initialized
mbed_stats_cpu_get(&stats);
ThisThread::sleep_for(3);
ThisThread::sleep_for(3ms);
mbed_stats_cpu_get(&stats);
TEST_ASSERT_NOT_EQUAL(0, stats.uptime);
TEST_ASSERT_NOT_EQUAL(0, stats.idle_time);

View File

@ -3,10 +3,11 @@
include(mbed_greentea)
if(NOT DEFINED MBED_HEAP_STATS_ENABLED)
set(TEST_SKIPPED "Stats heap test not supported.")
if((NOT "MBED_HEAP_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) AND (NOT "MBED_ALL_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS))
set(TEST_SKIPPED "heap stats not enabled")
endif()
mbed_greentea_add_test(
TEST_NAME
mbed-platform-stats-heap

View File

@ -3,8 +3,8 @@
include(mbed_greentea)
if(NOT DEFINED MBED_SYS_STATS_ENABLED)
set(TEST_SKIPPED "System stats test not supported.")
if((NOT "MBED_SYS_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) AND (NOT "MBED_ALL_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS))
set(TEST_SKIPPED "System stats not enabled")
endif()
mbed_greentea_add_test(

View File

@ -22,6 +22,8 @@
#include "mbed.h"
#include <cinttypes>
#if !defined(MBED_SYS_STATS_ENABLED)
#error [NOT_SUPPORTED] test not supported
#else
@ -33,6 +35,15 @@ void test_sys_info()
mbed_stats_sys_t stats;
mbed_stats_sys_get(&stats);
// Print a summary of the stats, just for debug purposes
printf("Dump of Mbed System Stats: -------------------------------------\n");
printf("- OS Version: %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n",
stats.os_version / 10000,
(stats.os_version % 10000) / 100,
((stats.os_version % 10000) % 100));
printf("- CPUID Register: 0x%" PRIx32 "\n", stats.cpu_id);
printf("- Compiler Version: %" PRIu32 "\n", stats.compiler_version);
TEST_ASSERT_NOT_EQUAL(0, stats.os_version);
#if defined(__CORTEX_M)
TEST_ASSERT_NOT_EQUAL(0, stats.cpu_id);

View File

@ -3,8 +3,8 @@
include(mbed_greentea)
if(NOT DEFINED MBED_THREAD_STATS_ENABLED)
set(TEST_SKIPPED "Thread stats test not supported.")
if((NOT "MBED_THREAD_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS) AND (NOT "MBED_ALL_STATS_ENABLED=1" IN_LIST MBED_CONFIG_DEFINITIONS))
set(TEST_SKIPPED "Thread stats not enabled")
endif()
mbed_greentea_add_test(

View File

@ -47,7 +47,7 @@ void increment_with_delay()
{
while (1) {
counter++;
ThisThread::sleep_for(500);
ThisThread::sleep_for(500ms);
}
}
@ -112,7 +112,7 @@ void test_case_multi_threads_blocked()
uint32_t ret = ef.set(FLAG_SIGNAL_DEC);
TEST_ASSERT_FALSE(ret & osFlagsError);
ThisThread::sleep_for(100);
ThisThread::sleep_for(100ms);
count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS);
TEST_ASSERT_EQUAL(1, (count - old_count));

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
#ifndef COMPONENT_FLASHIAP
#ifndef DEVICE_FLASH
#error [NOT_SUPPORTED] Target must have internal FlashIAP for this test
#else
@ -323,4 +323,4 @@ int main()
return !Harness::run(specification);
}
#endif // COMPONENT_FLASHIAP
#endif // DEVICE_FLASH

View File

@ -26,3 +26,7 @@ target_link_libraries(mbed-storage-kv-config
mbed-storage-littlefs-v2
mbed-storage-fat
)
if("DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS)
target_link_libraries(mbed-storage-kv-config PUBLIC mbed-storage-flashiap)
endif()

View File

@ -30,7 +30,7 @@
#include "securestore/SecureStore.h"
#define TRACE_GROUP "KVCFG"
#if COMPONENT_FLASHIAP
#if DEVICE_FLASH
#include "FlashIAPBlockDevice.h"
#endif
@ -284,7 +284,7 @@ FileSystem *_get_filesystem_default(const char *mount)
BlockDevice *_get_blockdevice_FLASHIAP(bd_addr_t start_address, bd_size_t size)
{
#if COMPONENT_FLASHIAP
#if DEVICE_FLASH
int ret = kv_get_flash_bounds_from_config(&start_address, &size);
if (ret != 0) {
tr_error("KV Config: Determination of internal block device bounds failed. The configured start address/size is likely invalid.");
@ -677,7 +677,7 @@ int _create_internal_tdb(BlockDevice **internal_bd, KVStore **internal_tdb, bd_s
int _storage_config_TDB_INTERNAL()
{
#if COMPONENT_FLASHIAP
#if DEVICE_FLASH
bd_size_t internal_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE;
bd_addr_t internal_start_address = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS;
@ -999,7 +999,7 @@ MBED_WEAK int kv_init_storage_config()
int ret = MBED_SUCCESS;
// We currently have no supported configuration without internal storage
#ifndef COMPONENT_FLASHIAP
#ifndef DEVICE_FLASH
return MBED_ERROR_UNSUPPORTED;
#endif
@ -1026,7 +1026,7 @@ int kv_get_default_flash_addresses(bd_addr_t *start_address, bd_size_t *size)
{
int ret = MBED_SUCCESS;
#if COMPONENT_FLASHIAP
#if DEVICE_FLASH
FlashIAP flash;
if (flash.init() != 0) {
return MBED_ERROR_INITIALIZATION_FAILED;
@ -1072,7 +1072,7 @@ int kv_get_default_flash_addresses(bd_addr_t *start_address, bd_size_t *size)
int kv_get_flash_bounds_from_config(bd_addr_t *start_address, bd_size_t *size)
{
#if COMPONENT_FLASHIAP
#if DEVICE_FLASH
bd_addr_t flash_end_address;
bd_addr_t flash_start_address;

View File

@ -1490,7 +1490,6 @@ int TDBStore::check_erase_before_write(uint8_t area, uint32_t offset, uint32_t s
uint32_t end_offset;
while (size) {
uint32_t dist, offset_from_start;
int ret;
offset_in_erase_unit(area, offset, offset_from_start, dist);
uint32_t chunk = std::min(size, dist);

View File

@ -99,7 +99,7 @@ static void kvstore_init()
TEST_ASSERT_EQUAL_ERROR_CODE(0, res);
if (kv_setup == TDBStoreSet) {
#if COMPONENT_FLASHIAP && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD
#if DEVICE_FLASH && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD
// TDBStore requires two areas of equal size, do the check for FlashIAP
TEST_SKIP_UNLESS(MBED_CONF_TARGET_INTERNAL_FLASH_UNIFORM_SECTORS ||
(MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE != 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS != 0xFFFFFFFF))

View File

@ -95,7 +95,7 @@ static void kvstore_init()
TEST_ASSERT_EQUAL_ERROR_CODE(0, res);
if (kv_setup == TDBStoreSet) {
#if COMPONENT_FLASHIAP && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD
#if DEVICE_FLASH && !COMPONENT_SPIF && !COMPONENT_QSPIF && !COMPONENT_DATAFLASH && !COMPONENT_SD
// TDBStore requires two areas of equal size
TEST_SKIP_UNLESS(MBED_CONF_TARGET_INTERNAL_FLASH_UNIFORM_SECTORS ||
(MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE != 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS != 0xFFFFFFFF))

View File

@ -14,27 +14,27 @@ list(APPEND mbed-storage-libs
mbed-storage-littlefs-v2
)
if("DATAFLASH" IN_LIST MBED_TARGET_LABELS)
if("COMPONENT_DATAFLASH=1" IN_LIST MBED_TARGET_DEFINITIONS)
list(APPEND mbed-storage-libs mbed-storage-dataflash)
endif()
if("FLASHIAP" IN_LIST MBED_TARGET_LABELS)
if("DEVICE_FLASH=1" IN_LIST MBED_TARGET_DEFINITIONS)
list(APPEND mbed-storage-libs mbed-storage-flashiap)
endif()
if("QSPIF" IN_LIST MBED_TARGET_LABELS)
if("COMPONENT_QSPIF=1" IN_LIST MBED_TARGET_DEFINITIONS)
list(APPEND mbed-storage-libs mbed-storage-qspif)
endif()
if("OSPIF" IN_LIST MBED_TARGET_LABELS)
if("COMPONENT_OSPIF=1" IN_LIST MBED_TARGET_DEFINITIONS)
list(APPEND mbed-storage-libs mbed-storage-ospif)
endif()
if("SD" IN_LIST MBED_TARGET_LABELS)
if("COMPONENT_SD=1" IN_LIST MBED_TARGET_DEFINITIONS)
list(APPEND mbed-storage-libs mbed-storage-sd)
endif()
if("SPIF" IN_LIST MBED_TARGET_LABELS)
if("COMPONENT_SPIF=1" IN_LIST MBED_TARGET_DEFINITIONS)
list(APPEND mbed-storage-libs mbed-storage-spif)
endif()

View File

@ -44,7 +44,7 @@ const spi_pinmap_t static_spi_pinmap = get_spi_pinmap(MBED_CONF_SD_SPI_MOSI, MBE
#endif
#endif
#if COMPONENT_FLASHIAP
#if DEVICE_FLASH
#include "FlashIAPBlockDevice.h"
#endif
@ -104,7 +104,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
return &default_bd;
#elif COMPONENT_FLASHIAP
#elif DEVICE_FLASH
#if (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE == 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS == 0xFFFFFFFF)
@ -164,7 +164,7 @@ MBED_WEAK FileSystem *FileSystem::get_default_instance()
return &sdcard;
#elif COMPONENT_FLASHIAP
#elif DEVICE_FLASH
// To avoid alignment issues, initialize a filesystem if all sectors have the same size
// OR the user has specified an address range