Skip to content

Commit 3932327

Browse files
committed
update unit tests
1 parent 1dc5c6e commit 3932327

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/unit-test/test_memory.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <memory/memory.h>
2121
#include <memory/memory_shared.h>
22+
#include <util.h>
2223

2324
#include <stdint.h>
2425
#include <stdio.h>
@@ -117,6 +118,18 @@ static const memory_interface_functions_t _ifs = {
117118

118119
static void _expect_reset(uint8_t* empty_chunk1, uint8_t* empty_chunk2)
119120
{
121+
// set "reset hww" flag in chunk 7
122+
expect_value(__wrap_memory_read_chunk_fake, chunk_num, 7);
123+
will_return(__wrap_memory_read_chunk_fake, empty_chunk1);
124+
125+
expect_value(__wrap_memory_write_chunk_fake, chunk_num, 7);
126+
empty_chunk1[1] = sectrue_u8;
127+
expect_memory(__wrap_memory_write_chunk_fake, chunk, empty_chunk1, CHUNK_SIZE);
128+
will_return(__wrap_memory_write_chunk_fake, true);
129+
130+
// Reset empty_chunk1 to empty
131+
empty_chunk1[1] = 0xff;
132+
120133
// Reset all except first and last chunk.
121134
for (uint32_t write_calls = 0; write_calls < FLASH_APP_DATA_LEN / CHUNK_SIZE - 2;
122135
write_calls++) {
@@ -136,6 +149,15 @@ static void _expect_reset(uint8_t* empty_chunk1, uint8_t* empty_chunk2)
136149
memcpy(&empty_chunk2[_addr_salt_root], _salt_root, 32);
137150
expect_memory(__wrap_memory_write_chunk_fake, chunk, empty_chunk2, CHUNK_SIZE);
138151
will_return(__wrap_memory_write_chunk_fake, true);
152+
153+
// clear "reset hww" flag in chunk 7
154+
expect_value(__wrap_memory_read_chunk_fake, chunk_num, 7);
155+
will_return(__wrap_memory_read_chunk_fake, empty_chunk1);
156+
157+
expect_value(__wrap_memory_write_chunk_fake, chunk_num, 7);
158+
empty_chunk1[1] = secfalse_u8;
159+
expect_memory(__wrap_memory_write_chunk_fake, chunk, empty_chunk1, CHUNK_SIZE);
160+
will_return(__wrap_memory_write_chunk_fake, true);
139161
}
140162

141163
#define EXPECT_RESET \

0 commit comments

Comments
 (0)