From 264f8da32bec3e5b7657d85c2ecc1be13728e336 Mon Sep 17 00:00:00 2001 From: Rajkumar Kanagaraj Date: Thu, 22 Jul 2021 06:48:00 -0700 Subject: [PATCH] CMake: Refactor storage greentea test CMake Initially, every library greentea test has its project() creation in their CMake. As running greentea using CTest move all greentea test suite under one global project mbed-os and MBED_CONFIG_PATH set at the root mbed os CMake under the condition BUILD_GREENTEA_TESTS check so refactored storage greentea CMake accordingly. --- .../buffered_block_device/CMakeLists.txt | 11 ++--------- .../flashsim_block_device/CMakeLists.txt | 11 ++--------- .../general_block_device/CMakeLists.txt | 14 ++++---------- .../blockdevice/heap_block_device/CMakeLists.txt | 11 ++--------- .../blockdevice/mbr_block_device/CMakeLists.txt | 13 +++---------- .../blockdevice/util_block_device/CMakeLists.txt | 11 ++--------- 6 files changed, 15 insertions(+), 56 deletions(-) diff --git a/storage/blockdevice/tests/TESTS/blockdevice/buffered_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/buffered_block_device/CMakeLists.txt index 6d147575cf..39dec419af 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/buffered_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/buffered_block_device/CMakeLists.txt @@ -1,18 +1,11 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) - -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.. CACHE INTERNAL "") -set(TEST_TARGET mbed-storage-blockdevice-buffered_block_device) - -include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) - -project(${TEST_TARGET}) +include(mbed_greentea) mbed_greentea_add_test( TEST_NAME - ${TEST_TARGET} + mbed-storage-blockdevice-buffered_block_device TEST_SOURCES main.cpp TEST_REQUIRED_LIBS diff --git a/storage/blockdevice/tests/TESTS/blockdevice/flashsim_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/flashsim_block_device/CMakeLists.txt index a4399b61a5..680675916a 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/flashsim_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/flashsim_block_device/CMakeLists.txt @@ -1,18 +1,11 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) - -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.. CACHE INTERNAL "") -set(TEST_TARGET mbed-storage-blockdevice-flashsim_block_device) - -include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) - -project(${TEST_TARGET}) +include(mbed_greentea) mbed_greentea_add_test( TEST_NAME - ${TEST_TARGET} + mbed-storage-blockdevice-flashsim_block_device TEST_SOURCES main.cpp TEST_REQUIRED_LIBS diff --git a/storage/blockdevice/tests/TESTS/blockdevice/general_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/general_block_device/CMakeLists.txt index 29a242abb9..3efffd5150 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/general_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/general_block_device/CMakeLists.txt @@ -1,14 +1,7 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) - -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.. CACHE INTERNAL "") -set(TEST_TARGET mbed-storage-blockdevice-general_block_device) - -include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) - -project(${TEST_TARGET}) +include(mbed_greentea) if("DATAFLASH" IN_LIST MBED_TARGET_LABELS) list(APPEND mbed_blockdevice_libs mbed-storage-dataflash) @@ -40,11 +33,12 @@ endif() mbed_greentea_add_test( TEST_NAME - ${TEST_TARGET} + mbed-storage-blockdevice-general_block_device TEST_SOURCES main.cpp TEST_REQUIRED_LIBS - mbed-storage-blockdevice mbed-storage + mbed-storage-blockdevice + mbed-storage-filesystem ${mbed_blockdevice_libs} ) diff --git a/storage/blockdevice/tests/TESTS/blockdevice/heap_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/heap_block_device/CMakeLists.txt index 6f23861244..9782f7c52e 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/heap_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/heap_block_device/CMakeLists.txt @@ -1,18 +1,11 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) - -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.. CACHE INTERNAL "") -set(TEST_TARGET mbed-storage-blockdevice-heap_block_device) - -include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) - -project(${TEST_TARGET}) +include(mbed_greentea) mbed_greentea_add_test( TEST_NAME - ${TEST_TARGET} + mbed-storage-blockdevice-heap_block_device TEST_SOURCES main.cpp TEST_REQUIRED_LIBS diff --git a/storage/blockdevice/tests/TESTS/blockdevice/mbr_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/mbr_block_device/CMakeLists.txt index a5f58d388c..b41130bd86 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/mbr_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/mbr_block_device/CMakeLists.txt @@ -1,18 +1,11 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) - -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.. CACHE INTERNAL "") -set(TEST_TARGET mbed-storage-blockdevice-mbr_block_device) - -include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) - -project(${TEST_TARGET}) +include(mbed_greentea) mbed_greentea_add_test( - TEST_NAME - ${TEST_TARGET} + TEST_NAME + mbed-storage-blockdevice-mbr_block_device TEST_SOURCES main.cpp TEST_REQUIRED_LIBS diff --git a/storage/blockdevice/tests/TESTS/blockdevice/util_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/util_block_device/CMakeLists.txt index 464dbba6d2..7f860bc0b0 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/util_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/util_block_device/CMakeLists.txt @@ -1,18 +1,11 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) - -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.. CACHE INTERNAL "") -set(TEST_TARGET mbed-storage-blockdevice-util_block_device) - -include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) - -project(${TEST_TARGET}) +include(mbed_greentea) mbed_greentea_add_test( TEST_NAME - ${TEST_TARGET} + mbed-storage-blockdevice-util_block_device TEST_SOURCES main.cpp TEST_REQUIRED_LIBS