Skip to content

Commit

Permalink
unittests: Reduce runtime of TDBStoreModuleTest.corrupted_set_deinit_…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
rwalton-arm committed Jul 22, 2021
1 parent 6a39daa commit 9b7d1f0
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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);
Expand Down

0 comments on commit 9b7d1f0

Please sign in to comment.