Skip to content

Commit 4536fff

Browse files
committed
CMake: Refactor storage blockdevice and SFDP unittests cmake
- Add CMake configuration file - Fix the header inclusion in blockdevice unittests
1 parent c0a8fe6 commit 4536fff

File tree

21 files changed

+342
-9
lines changed

21 files changed

+342
-9
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2021 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_subdirectory(blockdevice)
5+
add_subdirectory(SFDP)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2021 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
set(TEST_NAME sfdp-unittest)
5+
6+
add_executable(${TEST_NAME})
7+
8+
target_compile_definitions(${TEST_NAME}
9+
PRIVATE
10+
DEVICE_SPI
11+
)
12+
13+
target_sources(${TEST_NAME}
14+
PRIVATE
15+
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/SFDP.cpp
16+
test_sfdp.cpp
17+
)
18+
19+
target_link_libraries(${TEST_NAME}
20+
PRIVATE
21+
mbed-headers
22+
mbed-stubs-platform
23+
gmock_main
24+
)
25+
26+
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
27+
28+
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2021 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
set(TEST_NAME buffered-blockdevice-unittest)
5+
6+
add_executable(${TEST_NAME})
7+
8+
target_sources(${TEST_NAME}
9+
PRIVATE
10+
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/BufferedBlockDevice.cpp
11+
test_BufferedBlockDevice.cpp
12+
)
13+
14+
target_link_libraries(${TEST_NAME}
15+
PRIVATE
16+
mbed-headers
17+
mbed-stubs-headers
18+
mbed-stubs-platform
19+
gmock_main
20+
)
21+
22+
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
23+
24+
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

storage/blockdevice/tests/UNITTESTS/blockdevice/BufferedBlockDevice/test_BufferedBlockDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include "gtest/gtest.h"
1818
#include "blockdevice/BufferedBlockDevice.h"
19-
#include "stubs/BlockDevice_mock.h"
19+
#include "BlockDevice_mock.h"
2020

2121
using ::testing::_;
2222
using ::testing::Return;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2021 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_subdirectory(ChainingBlockDevice)
5+
add_subdirectory(BufferedBlockDevice)
6+
add_subdirectory(SlicingBlockDevice)
7+
add_subdirectory(ReadOnlyBlockDevice)
8+
add_subdirectory(ProfilingBlockDevice)
9+
add_subdirectory(ObservingBlockDevice)
10+
add_subdirectory(MBRBlockDevice)
11+
add_subdirectory(HeapBlockDevice)
12+
add_subdirectory(FlashSimBlockDevice)
13+
add_subdirectory(ExhaustibleBlockDevice)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2021 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
set(TEST_NAME chaining-blockdevice-unittest)
5+
6+
add_executable(${TEST_NAME})
7+
8+
target_sources(${TEST_NAME}
9+
PRIVATE
10+
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/ChainingBlockDevice.cpp
11+
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/HeapBlockDevice.cpp
12+
test_ChainingBlockDevice.cpp
13+
)
14+
15+
target_link_libraries(${TEST_NAME}
16+
PRIVATE
17+
mbed-headers
18+
mbed-stubs-headers
19+
mbed-stubs-platform
20+
gmock_main
21+
)
22+
23+
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
24+
25+
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

storage/blockdevice/tests/UNITTESTS/blockdevice/ChainingBlockDevice/test_ChainingBlockDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616

1717
#include "gtest/gtest.h"
18-
#include "ChainingBlockDevice.cpp"
19-
#include "stubs/BlockDevice_mock.h"
18+
#include "blockdevice/ChainingBlockDevice.h"
19+
#include "BlockDevice_mock.h"
2020

2121
using ::testing::_;
2222
using ::testing::Return;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2021 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
set(TEST_NAME exhaustible-blockdevice-unittest)
5+
6+
add_executable(${TEST_NAME})
7+
8+
target_sources(${TEST_NAME}
9+
PRIVATE
10+
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/ExhaustibleBlockDevice.cpp
11+
test_ExhaustibleBlockDevice.cpp
12+
)
13+
14+
target_link_libraries(${TEST_NAME}
15+
PRIVATE
16+
mbed-headers
17+
mbed-stubs-headers
18+
mbed-stubs-platform
19+
gmock_main
20+
)
21+
22+
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
23+
24+
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

storage/blockdevice/tests/UNITTESTS/blockdevice/ExhaustibleBlockDevice/test_ExhaustibleBlockDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include "gtest/gtest.h"
1818
#include "blockdevice/ExhaustibleBlockDevice.h"
19-
#include "stubs/BlockDevice_mock.h"
19+
#include "BlockDevice_mock.h"
2020

2121
#define BLOCK_SIZE (512)
2222
#define DEVICE_SIZE (BLOCK_SIZE*10)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2021 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
set(TEST_NAME flash-sim-blockdevice-unittest)
5+
6+
add_executable(${TEST_NAME})
7+
8+
target_sources(${TEST_NAME}
9+
PRIVATE
10+
${mbed-os_SOURCE_DIR}/storage/blockdevice/source/FlashSimBlockDevice.cpp
11+
test_FlashSimBlockDevice.cpp
12+
)
13+
14+
target_link_libraries(${TEST_NAME}
15+
PRIVATE
16+
mbed-headers
17+
mbed-stubs-headers
18+
mbed-stubs-platform
19+
gmock_main
20+
)
21+
22+
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
23+
24+
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "storage")

0 commit comments

Comments
 (0)