Skip to content

Commit 6a5a14e

Browse files
committed
update unit tests
1 parent 4b992bd commit 6a5a14e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/unit-test/test_memory.c

Lines changed: 20 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,16 @@ static const memory_interface_functions_t _ifs = {
117118

118119
static void _expect_reset(uint8_t* empty_chunk1, uint8_t* empty_chunk2)
119120
{
121+
EMPTYCHUNK(chunk7);
122+
// set "reset hww" flag in chunk 7
123+
expect_value(__wrap_memory_read_chunk_fake, chunk_num, 7);
124+
will_return(__wrap_memory_read_chunk_fake, chunk7);
125+
126+
expect_value(__wrap_memory_write_chunk_fake, chunk_num, 7);
127+
chunk7[1] = sectrue_u8;
128+
expect_memory(__wrap_memory_write_chunk_fake, chunk, chunk7, CHUNK_SIZE);
129+
will_return(__wrap_memory_write_chunk_fake, true);
130+
120131
// Reset all except first and last chunk.
121132
for (uint32_t write_calls = 0; write_calls < FLASH_APP_DATA_LEN / CHUNK_SIZE - 2;
122133
write_calls++) {
@@ -136,6 +147,15 @@ static void _expect_reset(uint8_t* empty_chunk1, uint8_t* empty_chunk2)
136147
memcpy(&empty_chunk2[_addr_salt_root], _salt_root, 32);
137148
expect_memory(__wrap_memory_write_chunk_fake, chunk, empty_chunk2, CHUNK_SIZE);
138149
will_return(__wrap_memory_write_chunk_fake, true);
150+
151+
// clear "reset hww" flag in chunk 7
152+
expect_value(__wrap_memory_read_chunk_fake, chunk_num, 7);
153+
will_return(__wrap_memory_read_chunk_fake, chunk7);
154+
155+
expect_value(__wrap_memory_write_chunk_fake, chunk_num, 7);
156+
chunk7[1] = secfalse_u8;
157+
expect_memory(__wrap_memory_write_chunk_fake, chunk, chunk7, CHUNK_SIZE);
158+
will_return(__wrap_memory_write_chunk_fake, true);
139159
}
140160

141161
#define EXPECT_RESET \

0 commit comments

Comments
 (0)