CMake: Refactor storage blockdevice and SFDP unittests cmake

- Add CMake configuration file
- Fix the header inclusion in blockdevice unittests
pull/14426/head
Rajkumar Kanagaraj 2021-02-22 03:56:15 -08:00
parent c0a8fe62f5
commit 4536fff63a
21 changed files with 342 additions and 9 deletions

View File

@ -0,0 +1,5 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_subdirectory(blockdevice)
add_subdirectory(SFDP)

View File

@ -0,0 +1,28 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME sfdp-unittest)
add_executable(${TEST_NAME})
target_compile_definitions(${TEST_NAME}
PRIVATE
DEVICE_SPI
)
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/SFDP.cpp
test_sfdp.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

View File

@ -0,0 +1,24 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME buffered-blockdevice-unittest)
add_executable(${TEST_NAME})
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/BufferedBlockDevice.cpp
test_BufferedBlockDevice.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

View File

@ -16,7 +16,7 @@
#include "gtest/gtest.h"
#include "blockdevice/BufferedBlockDevice.h"
#include "stubs/BlockDevice_mock.h"
#include "BlockDevice_mock.h"
using ::testing::_;
using ::testing::Return;

View File

@ -0,0 +1,13 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
add_subdirectory(ChainingBlockDevice)
add_subdirectory(BufferedBlockDevice)
add_subdirectory(SlicingBlockDevice)
add_subdirectory(ReadOnlyBlockDevice)
add_subdirectory(ProfilingBlockDevice)
add_subdirectory(ObservingBlockDevice)
add_subdirectory(MBRBlockDevice)
add_subdirectory(HeapBlockDevice)
add_subdirectory(FlashSimBlockDevice)
add_subdirectory(ExhaustibleBlockDevice)

View File

@ -0,0 +1,25 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME chaining-blockdevice-unittest)
add_executable(${TEST_NAME})
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/ChainingBlockDevice.cpp
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/HeapBlockDevice.cpp
test_ChainingBlockDevice.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

View File

@ -15,8 +15,8 @@
*/
#include "gtest/gtest.h"
#include "ChainingBlockDevice.cpp"
#include "stubs/BlockDevice_mock.h"
#include "blockdevice/ChainingBlockDevice.h"
#include "BlockDevice_mock.h"
using ::testing::_;
using ::testing::Return;

View File

@ -0,0 +1,24 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME exhaustible-blockdevice-unittest)
add_executable(${TEST_NAME})
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/ExhaustibleBlockDevice.cpp
test_ExhaustibleBlockDevice.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

View File

@ -16,7 +16,7 @@
#include "gtest/gtest.h"
#include "blockdevice/ExhaustibleBlockDevice.h"
#include "stubs/BlockDevice_mock.h"
#include "BlockDevice_mock.h"
#define BLOCK_SIZE (512)
#define DEVICE_SIZE (BLOCK_SIZE*10)

View File

@ -0,0 +1,24 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME flash-sim-blockdevice-unittest)
add_executable(${TEST_NAME})
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/FlashSimBlockDevice.cpp
test_FlashSimBlockDevice.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

View File

@ -16,7 +16,7 @@
#include "gtest/gtest.h"
#include "blockdevice/FlashSimBlockDevice.h"
#include "stubs/BlockDevice_mock.h"
#include "BlockDevice_mock.h"
#define BLOCK_SIZE (512)
#define DEVICE_SIZE (BLOCK_SIZE*10)

View File

@ -0,0 +1,67 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME heap-blockdevice-unittest)
add_executable(${TEST_NAME})
target_compile_definitions(${TEST_NAME}
PRIVATE
MBED_CONF_FAT_CHAN_FFS_DBG=0
MBED_CONF_FAT_CHAN_FF_FS_READONLY=0
MBED_CONF_FAT_CHAN_FF_FS_MINIMIZE=0
MBED_CONF_FAT_CHAN_FF_USE_STRFUNC=0
MBED_CONF_FAT_CHAN_FF_USE_FIND=0
MBED_CONF_FAT_CHAN_FF_USE_MKFS=1
MBED_CONF_FAT_CHAN_FF_USE_FASTSEEK=0
MBED_CONF_FAT_CHAN_FF_USE_EXPAND=0
MBED_CONF_FAT_CHAN_FF_USE_CHMOD=0
MBED_CONF_FAT_CHAN_FF_USE_LABEL=0
MBED_CONF_FAT_CHAN_FF_USE_FORWARD=0
MBED_CONF_FAT_CHAN_FF_CODE_PAGE=437
MBED_CONF_FAT_CHAN_FF_USE_LFN=3
MBED_CONF_FAT_CHAN_FF_MAX_LFN=255
MBED_CONF_FAT_CHAN_FF_LFN_UNICODE=0
MBED_CONF_FAT_CHAN_FF_LFN_BUF=255
MBED_CONF_FAT_CHAN_FF_SFN_BUF=12
MBED_CONF_FAT_CHAN_FF_STRF_ENCODE=3
MBED_CONF_FAT_CHAN_FF_FS_RPATH=1
MBED_CONF_FAT_CHAN_FF_VOLUMES=4
MBED_CONF_FAT_CHAN_FF_STR_VOLUME_ID=0
MBED_CONF_FAT_CHAN_FF_VOLUME_STRS=\"RAM\",\"NAND\",\"CF\",\"SD\",\"SD2\",\"USB\",\"USB2\",\"USB3\"
MBED_CONF_FAT_CHAN_FF_MULTI_PARTITION=0
MBED_CONF_FAT_CHAN_FF_MIN_SS=512
MBED_CONF_FAT_CHAN_FF_MAX_SS=4096
MBED_CONF_FAT_CHAN_FF_USE_TRIM=1
MBED_CONF_FAT_CHAN_FF_FS_NOFSINFO=0
MBED_CONF_FAT_CHAN_FF_FS_TINY=1
MBED_CONF_FAT_CHAN_FF_FS_EXFAT=0
MBED_CONF_FAT_CHAN_FF_FS_HEAPBUF=1
MBED_CONF_FAT_CHAN_FF_FS_NORTC=0
MBED_CONF_FAT_CHAN_FF_NORTC_MON=1
MBED_CONF_FAT_CHAN_FF_NORTC_MDAY=1
MBED_CONF_FAT_CHAN_FF_NORTC_YEAR=2017
MBED_CONF_FAT_CHAN_FF_FS_LOCK=0
MBED_CONF_FAT_CHAN_FF_FS_REENTRANT=0
MBED_CONF_FAT_CHAN_FF_FS_TIMEOUT=1000
MBED_CONF_FAT_CHAN_FF_SYNC_t=HANDLE
MBED_CONF_FAT_CHAN_FLUSH_ON_NEW_CLUSTER=0
MBED_CONF_FAT_CHAN_FLUSH_ON_NEW_SECTOR=1
)
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/HeapBlockDevice.cpp
test.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

View File

@ -0,0 +1,24 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME mbr-blockdevice-unittest)
add_executable(${TEST_NAME})
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/MBRBlockDevice.cpp
test_MBRBlockDevice.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

View File

@ -16,7 +16,7 @@
#include "gtest/gtest.h"
#include "blockdevice/MBRBlockDevice.h"
#include "stubs/BlockDevice_mock.h"
#include "BlockDevice_mock.h"
#define BLOCK_SIZE (512)
#define PART_DESC_SIZE (16)

View File

@ -0,0 +1,25 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME observing-blockdevice-unittest)
add_executable(${TEST_NAME})
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/ObservingBlockDevice.cpp
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/ReadOnlyBlockDevice.cpp
test_ObservingBlockDevice.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

View File

@ -17,7 +17,7 @@
#include "gtest/gtest.h"
#include "blockdevice/ObservingBlockDevice.h"
#include "blockdevice/ReadOnlyBlockDevice.h"
#include "stubs/BlockDevice_mock.h"
#include "BlockDevice_mock.h"
using ::testing::_;
using ::testing::Return;

View File

@ -0,0 +1,25 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME profiling-blockdevice-unittest)
add_executable(${TEST_NAME})
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/ProfilingBlockDevice.cpp
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/HeapBlockDevice.cpp
test_ProfilingBlockDevice.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

View File

@ -15,7 +15,7 @@
*/
#include "gtest/gtest.h"
#include "stubs/BlockDevice_mock.h"
#include "BlockDevice_mock.h"
#include "blockdevice/ProfilingBlockDevice.h"
#define BLOCK_SIZE (512)

View File

@ -0,0 +1,25 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME read-only-blockdevice-unittest)
add_executable(${TEST_NAME})
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/ReadOnlyBlockDevice.cpp
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/HeapBlockDevice.cpp
test_ReadOnlyBlockDevice.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

View File

@ -15,7 +15,7 @@
*/
#include "gtest/gtest.h"
#include "stubs/BlockDevice_mock.h"
#include "BlockDevice_mock.h"
#include "blockdevice/ReadOnlyBlockDevice.h"
#include "platform/mbed_error.h"

View File

@ -0,0 +1,24 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(TEST_NAME slicing-blockdevice-unittest)
add_executable(${TEST_NAME})
target_sources(${TEST_NAME}
PRIVATE
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/SlicingBlockDevice.cpp
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/HeapBlockDevice.cpp
moduletest.cpp
)
target_link_libraries(${TEST_NAME}
PRIVATE
mbed-headers
mbed-stubs-platform
gmock_main
)
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")