Skip to content

Commit e6fa0fb

Browse files
committed
unix/main: Add coverage test for mounting ROMFS filesystem at startup.
Signed-off-by: Damien George <damien@micropython.org>
1 parent a3f73e4 commit e6fa0fb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ports/unix/main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,21 @@ void nlr_jump_fail(void *val) {
805805
exit(1);
806806
}
807807

808+
#if defined(MICROPY_UNIX_COVERAGE)
809+
static uint8_t romfs_buf[4] = { 0xd2, 0xcd, 0x31, 0x00 }; // empty ROMFS
810+
static const MP_DEFINE_MEMORYVIEW_OBJ(romfs_obj, 'B', 0, sizeof(romfs_buf), romfs_buf);
811+
#endif
812+
808813
mp_obj_t mp_vfs_rom_ioctl(size_t n_args, const mp_obj_t *args) {
814+
#if defined(MICROPY_UNIX_COVERAGE)
815+
switch (mp_obj_get_int(args[0])) {
816+
case MP_VFS_ROM_IOCTL_GET_NUMBER_OF_SEGMENTS:
817+
return MP_OBJ_NEW_SMALL_INT(1);
818+
819+
case MP_VFS_ROM_IOCTL_GET_SEGMENT:
820+
return MP_OBJ_FROM_PTR(&romfs_obj);
821+
}
822+
#endif
823+
809824
return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL);
810825
}

0 commit comments

Comments
 (0)