From b0c0fc9f660d0a00d1173e0c8ea0752418215b25 Mon Sep 17 00:00:00 2001 From: Robert Walton Date: Wed, 21 Jul 2021 23:11:48 +0100 Subject: [PATCH] unittests: Reduce runtime of TDBStoreModuleTest.corrupted_set_deinit_init_get Instead of performing 10,000 "set, deinit, get" operations, let's just perform 100. This reduces test time from 4.8s to 0.02s. --- .../kvstore/tdbstore/tests/UNITTESTS/TDBStore/moduletest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/kvstore/tdbstore/tests/UNITTESTS/TDBStore/moduletest.cpp b/storage/kvstore/tdbstore/tests/UNITTESTS/TDBStore/moduletest.cpp index b0a4e9925c..c6365c8afa 100644 --- a/storage/kvstore/tdbstore/tests/UNITTESTS/TDBStore/moduletest.cpp +++ b/storage/kvstore/tdbstore/tests/UNITTESTS/TDBStore/moduletest.cpp @@ -99,7 +99,7 @@ TEST_F(TDBStoreModuleTest, corrupted_set_deinit_init_get) srand(0); // Prefer to have always the same pattern - for (int i = 0; i < 100; ++i) { + for (int i = 0; i < 10; ++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++) { @@ -109,7 +109,7 @@ TEST_F(TDBStoreModuleTest, corrupted_set_deinit_init_get) EXPECT_EQ(heap.program(block, BLOCK_SIZE * j, BLOCK_SIZE), MBED_SUCCESS); } EXPECT_EQ(tdb.init(), MBED_SUCCESS); - for (int j = 0; j < 100; ++j) { + for (int j = 0; j < 10; ++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.deinit(), MBED_SUCCESS);