From 7c74d31c57d00ffbb620bf42ac9f7d3b44655611 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Fri, 2 Jul 2021 16:07:51 +0100 Subject: [PATCH] Unit tests: Create mbed-headers-filesystem Create a CMake target mbed-headers-filesystem to separate FileSystem headers from the generic mbed-headers-storage. Update tests to use it. --- UNITTESTS/stubs/CMakeLists.txt | 8 -------- .../framework/AT/at_cellularcontext/CMakeLists.txt | 1 + storage/CMakeLists.txt | 1 + storage/filesystem/CMakeLists.txt | 4 ++++ storage/filesystem/tests/UNITTESTS/.mbedignore | 1 + storage/filesystem/tests/UNITTESTS/CMakeLists.txt | 11 +++++++++++ .../tests/UNITTESTS/FileSystemStore/CMakeLists.txt | 1 + 7 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 storage/filesystem/tests/UNITTESTS/.mbedignore create mode 100644 storage/filesystem/tests/UNITTESTS/CMakeLists.txt diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt index 7090c2250c..154868a61b 100644 --- a/UNITTESTS/stubs/CMakeLists.txt +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -43,14 +43,6 @@ target_include_directories(mbed-headers-base target_include_directories(mbed-headers-storage INTERFACE - ${mbed-os_SOURCE_DIR}/storage/filesystem/fat/include - ${mbed-os_SOURCE_DIR}/storage/filesystem/fat/ChaN - ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs - ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs/include - ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefsv2/littlefs - ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefsv2/littlefs/bd - ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs/littlefs - ${mbed-os_SOURCE_DIR}/storage/filesystem/include ${mbed-os_SOURCE_DIR}/storage/kvstore/include ${mbed-os_SOURCE_DIR}/storage/kvstore/kv_config ${mbed-os_SOURCE_DIR}/storage/kvstore/kv_config/include diff --git a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt index b56698292a..17c73c0573 100644 --- a/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt +++ b/connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/CMakeLists.txt @@ -25,6 +25,7 @@ target_link_libraries(${TEST_NAME} PRIVATE mbed-headers mbed-headers-cellular + mbed-headers-filesystem mbed-stubs mbed-stubs-cellular mbed-stubs-headers diff --git a/storage/CMakeLists.txt b/storage/CMakeLists.txt index df4d8a2932..e27f47dd11 100644 --- a/storage/CMakeLists.txt +++ b/storage/CMakeLists.txt @@ -35,6 +35,7 @@ if(${CMAKE_CROSSCOMPILING}) else() # Add these subdirectories for the Unit test add_subdirectory(blockdevice) + add_subdirectory(filesystem) add_subdirectory(kvstore) endif() diff --git a/storage/filesystem/CMakeLists.txt b/storage/filesystem/CMakeLists.txt index c3ec4fbe64..cacd423208 100644 --- a/storage/filesystem/CMakeLists.txt +++ b/storage/filesystem/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) + add_subdirectory(tests/UNITTESTS) +endif() + add_subdirectory(fat) add_subdirectory(littlefs) add_subdirectory(littlefsv2) diff --git a/storage/filesystem/tests/UNITTESTS/.mbedignore b/storage/filesystem/tests/UNITTESTS/.mbedignore new file mode 100644 index 0000000000..72e8ffc0db --- /dev/null +++ b/storage/filesystem/tests/UNITTESTS/.mbedignore @@ -0,0 +1 @@ +* diff --git a/storage/filesystem/tests/UNITTESTS/CMakeLists.txt b/storage/filesystem/tests/UNITTESTS/CMakeLists.txt new file mode 100644 index 0000000000..ef65aa7f99 --- /dev/null +++ b/storage/filesystem/tests/UNITTESTS/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-headers-filesystem INTERFACE) + +target_include_directories(mbed-headers-filesystem + INTERFACE + ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs + ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs/include + ${mbed-os_SOURCE_DIR}/storage/filesystem/include +) diff --git a/storage/kvstore/filesystemstore/tests/UNITTESTS/FileSystemStore/CMakeLists.txt b/storage/kvstore/filesystemstore/tests/UNITTESTS/FileSystemStore/CMakeLists.txt index c2256548a7..b505e0c4cc 100644 --- a/storage/kvstore/filesystemstore/tests/UNITTESTS/FileSystemStore/CMakeLists.txt +++ b/storage/kvstore/filesystemstore/tests/UNITTESTS/FileSystemStore/CMakeLists.txt @@ -34,6 +34,7 @@ target_link_libraries(${TEST_NAME} PRIVATE mbed-headers mbed-headers-blockdevice + mbed-headers-filesystem mbed-stubs-platform mbed-stubs-filesystemstore gmock_main