mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13908 from LDong-Arm/kvstore_libraries
Restructure KVStore to one library per store typepull/14036/head
commit
9f18c445ee
|
@ -25,6 +25,9 @@
|
|||
"system-storage",
|
||||
"SecureStore",
|
||||
"storage",
|
||||
"kvstore",
|
||||
"tdbstore",
|
||||
"filesystemstore",
|
||||
"kv-global-api",
|
||||
"direct-access-devicekey",
|
||||
"kv-config",
|
||||
|
|
|
@ -122,6 +122,9 @@ set(unittest-includes-base
|
|||
"${PROJECT_SOURCE_DIR}/../storage/kvstore/include"
|
||||
"${PROJECT_SOURCE_DIR}/../storage/kvstore/kv_config"
|
||||
"${PROJECT_SOURCE_DIR}/../storage/kvstore/kv_config/include"
|
||||
"${PROJECT_SOURCE_DIR}/../storage/kvstore/tdbstore/include"
|
||||
"${PROJECT_SOURCE_DIR}/../storage/kvstore/filesystemstore/include"
|
||||
"${PROJECT_SOURCE_DIR}/../storage/kvstore/kvstore_global_api/include"
|
||||
"${PROJECT_SOURCE_DIR}/../drivers"
|
||||
"${PROJECT_SOURCE_DIR}/../drivers/include"
|
||||
"${PROJECT_SOURCE_DIR}/../drivers/include/drivers"
|
||||
|
|
|
@ -17,4 +17,6 @@ target_sources(mbed-device_key
|
|||
target_link_libraries(mbed-device_key
|
||||
INTERFACE
|
||||
mbed-storage-kvstore
|
||||
mbed-storage-tdbstore
|
||||
mbed-storage-kv-global-api
|
||||
)
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "mbedtls/cmac.h"
|
||||
#include "mbedtls/platform.h"
|
||||
#include "kvstore/KVStore.h"
|
||||
#include "kvstore/TDBStore.h"
|
||||
#include "kvstore/KVMap.h"
|
||||
#include "tdbstore/TDBStore.h"
|
||||
#include "kvstore_global_api/KVMap.h"
|
||||
#include "kv_config/kv_config.h"
|
||||
#include "mbed_wait_api.h"
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -24,4 +24,7 @@ target_link_libraries(mbed-psa
|
|||
INTERFACE
|
||||
mbed-mbedtls
|
||||
mbed-storage-kvstore
|
||||
mbed-storage-tdbstore
|
||||
mbed-storage-kv-global-api
|
||||
mbed-device_key
|
||||
)
|
||||
|
|
|
@ -18,6 +18,12 @@ add_library(mbed-storage-littlefs INTERFACE)
|
|||
add_library(mbed-storage-fat INTERFACE)
|
||||
|
||||
add_library(mbed-storage-kvstore INTERFACE)
|
||||
add_library(mbed-storage-tdbstore INTERFACE)
|
||||
add_library(mbed-storage-filesystemstore INTERFACE)
|
||||
add_library(mbed-storage-securestore INTERFACE)
|
||||
add_library(mbed-storage-kv-config INTERFACE)
|
||||
add_library(mbed-storage-direct-access-devicekey INTERFACE)
|
||||
add_library(mbed-storage-kv-global-api INTERFACE)
|
||||
|
||||
|
||||
add_subdirectory(blockdevice)
|
||||
|
@ -29,8 +35,3 @@ target_include_directories(mbed-storage
|
|||
INTERFACE
|
||||
.
|
||||
)
|
||||
|
||||
target_compile_definitions(mbed-storage
|
||||
INTERFACE
|
||||
MBED_CONF_FILESYSTEM_PRESENT=1
|
||||
)
|
||||
|
|
|
@ -18,3 +18,8 @@ target_sources(mbed-storage-filesystem
|
|||
source/File.cpp
|
||||
source/FileSystem.cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(mbed-storage
|
||||
INTERFACE
|
||||
MBED_CONF_FILESYSTEM_PRESENT=1
|
||||
)
|
||||
|
|
|
@ -1,32 +1,16 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
add_subdirectory(direct_access_devicekey)
|
||||
add_subdirectory(kv_config)
|
||||
add_subdirectory(tdbstore)
|
||||
add_subdirectory(filesystemstore)
|
||||
add_subdirectory(securestore)
|
||||
add_subdirectory(kv_config)
|
||||
add_subdirectory(direct_access_devicekey)
|
||||
add_subdirectory(kvstore_global_api)
|
||||
|
||||
target_include_directories(mbed-storage-kvstore
|
||||
INTERFACE
|
||||
.
|
||||
./include
|
||||
./include/kvstore
|
||||
)
|
||||
|
||||
target_sources(mbed-storage-kvstore
|
||||
INTERFACE
|
||||
source/FileSystemStore.cpp
|
||||
source/KVMap.cpp
|
||||
source/TDBStore.cpp
|
||||
source/kvstore_global_api.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(mbed-storage-kvstore
|
||||
INTERFACE
|
||||
mbed-device_key
|
||||
mbed-storage-blockdevice
|
||||
mbed-storage-filesystem
|
||||
mbed-storage-fat
|
||||
mbed-storage-littlefs
|
||||
mbed-storage-flashiap
|
||||
mbed-storage-sd
|
||||
include
|
||||
include/kvstore
|
||||
)
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
target_include_directories(mbed-storage-kvstore
|
||||
target_include_directories(mbed-storage-direct-access-devicekey
|
||||
INTERFACE
|
||||
.
|
||||
./include
|
||||
./include/direct_access_devicekey
|
||||
include
|
||||
include/direct_access_devicekey
|
||||
)
|
||||
|
||||
target_sources(mbed-storage-kvstore
|
||||
target_sources(mbed-storage-direct-access-devicekey
|
||||
INTERFACE
|
||||
source/DirectAccessDevicekey.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(mbed-storage-direct-access-devicekey
|
||||
INTERFACE
|
||||
mbed-storage-kvstore
|
||||
mbed-storage-kv-config
|
||||
)
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
#include <string.h>
|
||||
#include "DeviceKey.h"
|
||||
#include "kvstore/KVStore.h"
|
||||
#include "kvstore/KVMap.h"
|
||||
#include "kvstore_global_api/KVMap.h"
|
||||
#include "kv_config/kv_config.h"
|
||||
#include "kvstore/TDBStore.h"
|
||||
#include "tdbstore/TDBStore.h"
|
||||
#include "FlashIAP.h"
|
||||
#include "FlashIAPBlockDevice.h"
|
||||
#include "direct_access_devicekey/DirectAccessDevicekey.h"
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
target_include_directories(mbed-storage-filesystemstore
|
||||
INTERFACE
|
||||
.
|
||||
include
|
||||
include/filesystemstore
|
||||
)
|
||||
|
||||
target_sources(mbed-storage-filesystemstore
|
||||
INTERFACE
|
||||
source/FileSystemStore.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(mbed-storage-filesystemstore
|
||||
INTERFACE
|
||||
mbed-storage-kvstore
|
||||
mbed-storage-filesystem
|
||||
mbed-storage-kv-config
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"name": "filesystemstore"
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "kvstore/FileSystemStore.h"
|
||||
#include "filesystemstore/FileSystemStore.h"
|
||||
#include "kv_config/kv_config.h"
|
||||
#include "filesystem/Dir.h"
|
||||
#include "filesystem/File.h"
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "gtest/gtest.h"
|
||||
#include "blockdevice/HeapBlockDevice.h"
|
||||
#include "kvstore/FileSystemStore.h"
|
||||
#include "filesystemstore/FileSystemStore.h"
|
||||
#include "littlefs/LittleFileSystem.h"
|
||||
#include "mbed_error.h"
|
||||
#include <stdlib.h>
|
||||
|
@ -34,7 +34,7 @@ protected:
|
|||
virtual void SetUp()
|
||||
{
|
||||
fs = new LittleFileSystem("kvstore", &heap);
|
||||
if(fs->mount(&heap) != MBED_SUCCESS) {
|
||||
if (fs->mount(&heap) != MBED_SUCCESS) {
|
||||
EXPECT_EQ(fs->reformat(&heap), MBED_SUCCESS);
|
||||
}
|
||||
store = new FileSystemStore(fs);
|
|
@ -10,7 +10,7 @@ set(unittest-includes ${unittest-includes}
|
|||
|
||||
set(unittest-sources
|
||||
../storage/blockdevice/source/HeapBlockDevice.cpp
|
||||
../storage/kvstore/source/FileSystemStore.cpp
|
||||
../storage/kvstore/filesystemstore/source/FileSystemStore.cpp
|
||||
../storage/filesystem/littlefs/source/LittleFileSystem.cpp
|
||||
../storage/filesystem/source/Dir.cpp
|
||||
../storage/filesystem/source/File.cpp
|
|
@ -1,14 +1,27 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
target_include_directories(mbed-storage-kvstore
|
||||
target_include_directories(mbed-storage-kv-config
|
||||
INTERFACE
|
||||
.
|
||||
./include
|
||||
./include/kv_config
|
||||
include
|
||||
include/kv_config
|
||||
)
|
||||
|
||||
target_sources(mbed-storage-kvstore
|
||||
target_sources(mbed-storage-kv-config
|
||||
INTERFACE
|
||||
source/kv_config.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(mbed-storage-kv-config
|
||||
INTERFACE
|
||||
mbed-storage-kvstore
|
||||
mbed-storage-blockdevice
|
||||
mbed-storage-tdbstore
|
||||
mbed-storage-filesystemstore
|
||||
mbed-storage-securestore
|
||||
mbed-storage-littlefs
|
||||
mbed-storage-fat
|
||||
mbed-storage-flashiap
|
||||
mbed-storage-sd
|
||||
)
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
|
||||
#include "kv_config.h"
|
||||
#include "kvstore/KVStore.h"
|
||||
#include "kvstore/KVMap.h"
|
||||
#include "kvstore_global_api/KVMap.h"
|
||||
#include "blockdevice/BlockDevice.h"
|
||||
#include "filesystem/FileSystem.h"
|
||||
#include "kvstore/FileSystemStore.h"
|
||||
#include "filesystemstore/FileSystemStore.h"
|
||||
#include "blockdevice/SlicingBlockDevice.h"
|
||||
#include "fat/FATFileSystem.h"
|
||||
#include "littlefs/LittleFileSystem.h"
|
||||
#include "kvstore/TDBStore.h"
|
||||
#include "tdbstore/TDBStore.h"
|
||||
#include "mbed_error.h"
|
||||
#include "drivers/FlashIAP.h"
|
||||
#include "blockdevice/FlashSimBlockDevice.h"
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
target_include_directories(mbed-storage-kv-global-api
|
||||
INTERFACE
|
||||
.
|
||||
include
|
||||
include/kvstore_global_api
|
||||
)
|
||||
|
||||
target_sources(mbed-storage-kv-global-api
|
||||
INTERFACE
|
||||
source/KVMap.cpp
|
||||
source/kvstore_global_api.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(mbed-storage-kv-global-api
|
||||
INTERFACE
|
||||
mbed-storage-kvstore
|
||||
mbed-storage-kv-config
|
||||
mbed-storage-blockdevice
|
||||
mbed-storage-filesystem
|
||||
)
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "kv-global-api",
|
||||
"requires": ["kvstore"]
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
#include "kvstore/KVStore.h"
|
||||
#include "kvstore/KVMap.h"
|
||||
#include "kvstore_global_api/KVMap.h"
|
||||
#include "kv_config/kv_config.h"
|
||||
#include <stdlib.h>
|
||||
#include "string.h"
|
|
@ -13,10 +13,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "kvstore_global_api.h"
|
||||
#include "kvstore_global_api/kvstore_global_api.h"
|
||||
|
||||
#include "kv_config/kv_config.h"
|
||||
#include "kvstore/KVMap.h"
|
||||
#include "kvstore_global_api/KVMap.h"
|
||||
#include "kvstore/KVStore.h"
|
||||
#include "mbed_error.h"
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"name": "kv-global-api"
|
||||
"name": "kvstore"
|
||||
}
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
target_include_directories(mbed-storage-kvstore
|
||||
target_include_directories(mbed-storage-securestore
|
||||
INTERFACE
|
||||
.
|
||||
./include
|
||||
./include/securestore
|
||||
include
|
||||
include/securestore
|
||||
)
|
||||
|
||||
target_sources(mbed-storage-kvstore
|
||||
target_sources(mbed-storage-securestore
|
||||
INTERFACE
|
||||
source/SecureStore.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(mbed-storage-securestore
|
||||
INTERFACE
|
||||
mbed-storage-kvstore
|
||||
mbed-device_key
|
||||
)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "securestore/SecureStore.h"
|
||||
#include "kvstore/TDBStore.h"
|
||||
#include "tdbstore/TDBStore.h"
|
||||
#ifdef MBED_CONF_RTOS_PRESENT
|
||||
#include "Thread.h"
|
||||
#endif
|
|
@ -0,0 +1,20 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
target_include_directories(mbed-storage-tdbstore
|
||||
INTERFACE
|
||||
.
|
||||
include
|
||||
include/tdbstore
|
||||
)
|
||||
|
||||
target_sources(mbed-storage-tdbstore
|
||||
INTERFACE
|
||||
source/TDBStore.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(mbed-storage-tdbstore
|
||||
INTERFACE
|
||||
mbed-storage-kvstore
|
||||
mbed-storage-blockdevice
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"name": "tdbstore"
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
// ----------------------------------------------------------- Includes -----------------------------------------------------------
|
||||
|
||||
#include "kvstore/TDBStore.h"
|
||||
#include "tdbstore/TDBStore.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
|
@ -0,0 +1 @@
|
|||
*
|
|
@ -17,7 +17,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "blockdevice/HeapBlockDevice.h"
|
||||
#include "blockdevice/FlashSimBlockDevice.h"
|
||||
#include "kvstore/TDBStore.h"
|
||||
#include "tdbstore/TDBStore.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define BLOCK_SIZE (256)
|
||||
|
@ -104,7 +104,7 @@ TEST_F(TDBStoreModuleTest, corrupted_set_deinit_init_get)
|
|||
for (int i = 0; i < 100; ++i) {
|
||||
EXPECT_EQ(tdb.deinit(), MBED_SUCCESS);
|
||||
// Corrupt the first part of the storage
|
||||
for (int j = 0; j < heap.size()/BLOCK_SIZE/2; j++) {
|
||||
for (int j = 0; j < heap.size() / BLOCK_SIZE / 2; j++) {
|
||||
for (int k = 0; k < BLOCK_SIZE; k++) {
|
||||
block[k] = rand();
|
||||
}
|
||||
|
@ -113,12 +113,12 @@ TEST_F(TDBStoreModuleTest, corrupted_set_deinit_init_get)
|
|||
EXPECT_EQ(tdb.init(), MBED_SUCCESS);
|
||||
for (int j = 0; j < 100; ++j) {
|
||||
// Use random data, so the data has to be updated
|
||||
EXPECT_EQ(tdb.set("key", block+j, 50, 0), MBED_SUCCESS);
|
||||
EXPECT_EQ(tdb.set("key", block + j, 50, 0), MBED_SUCCESS);
|
||||
EXPECT_EQ(tdb.deinit(), MBED_SUCCESS);
|
||||
EXPECT_EQ(tdb.init(), MBED_SUCCESS);
|
||||
EXPECT_EQ(tdb.get("key", buf, 100, &size), MBED_SUCCESS);
|
||||
EXPECT_EQ(size, 50);
|
||||
EXPECT_EQ(0, memcmp(buf, block+j, size));
|
||||
EXPECT_EQ(0, memcmp(buf, block + j, size));
|
||||
}
|
||||
EXPECT_EQ(tdb.remove("key"), MBED_SUCCESS);
|
||||
}
|
|
@ -13,7 +13,7 @@ set(unittest-sources
|
|||
../storage/blockdevice/source/FlashSimBlockDevice.cpp
|
||||
../storage/blockdevice/source/HeapBlockDevice.cpp
|
||||
../storage/blockdevice/source/BufferedBlockDevice.cpp
|
||||
../storage/kvstore/source/TDBStore.cpp
|
||||
../storage/kvstore/tdbstore/source/TDBStore.cpp
|
||||
../platform/mbed-trace/source/mbed_trace.c
|
||||
stubs/mbed_atomic_stub.c
|
||||
stubs/mbed_assert_stub.cpp
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "securestore/SecureStore.h"
|
||||
#include "kvstore/TDBStore.h"
|
||||
#include "tdbstore/TDBStore.h"
|
||||
#ifdef MBED_CONF_RTOS_PRESENT
|
||||
#include "Thread.h"
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "securestore/SecureStore.h"
|
||||
#include "kvstore/TDBStore.h"
|
||||
#include "tdbstore/TDBStore.h"
|
||||
#include "mbed_error.h"
|
||||
#include "FlashSimBlockDevice.h"
|
||||
#include "SlicingBlockDevice.h"
|
||||
|
|
Loading…
Reference in New Issue