Skip to content

Commit 8d25a7e

Browse files
committed
mock: Move wrap function to mocks from fakes
1 parent b94372e commit 8d25a7e

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

test/hardware-fakes/include/fake_memory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void memory_read_chunk_fake(uint32_t chunk_num, uint8_t* chunk_out);
2828
// Size: `FLASH_SHARED_DATA_LEN`.
2929
void memory_read_shared_bootdata_fake(uint8_t* chunk_out);
3030
void fake_memory_set_salt_root(const uint8_t* salt_root);
31+
const uint8_t* fake_memory_get_salt_root(void);
3132
void memory_bootloader_hash_fake(uint8_t* hash_out);
3233
void memory_set_bootloader_hash_fake(const uint8_t* fake_hash);
3334
#endif

test/hardware-fakes/src/fake_memory.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,14 @@ static uint8_t _salt_root[32] = {
225225
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
226226
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
227227
};
228+
228229
void fake_memory_set_salt_root(const uint8_t* salt_root)
229230
{
230231
memcpy(_salt_root, salt_root, 32);
231232
}
232-
bool __wrap_memory_get_salt_root(uint8_t* salt_root_out)
233+
const uint8_t* fake_memory_get_salt_root(void)
233234
{
234-
memcpy(salt_root_out, _salt_root, 32);
235-
return true;
235+
return _salt_root;
236236
}
237237

238238
// Arbitrary value.

test/unit-test/framework/src/mock_memory.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <stddef.h>
1919
#include <cmocka.h>
2020

21+
#include <fake_memory.h>
2122
#include <flags.h>
2223
#include <memory/memory.h>
2324
#include <stdio.h>
@@ -67,3 +68,9 @@ bool __wrap_memory_set_mnemonic_passphrase_enabled(bool enabled)
6768
check_expected(enabled);
6869
return mock();
6970
}
71+
72+
bool __wrap_memory_get_salt_root(uint8_t* salt_root_out)
73+
{
74+
memcpy(salt_root_out, fake_memory_get_salt_root(), 32);
75+
return true;
76+
}

0 commit comments

Comments
 (0)