Skip to content

Commit c895770

Browse files
agattidpgeorge
authored andcommitted
tests/ports/qemu: Add ROMFS tests to CI.
This commit adds a new test to make sure ROMFS files are mounted and read correctly, to be run as part of the CI process. The changes also include the source binary files that have been used to create the pre-baked ROMFS partition image used in the test, along with a Makefile to allow recreating said file. The CI test ROMFS image is mounted only if no other ROMFS partition is mounted in slot 0. The specific test is executed only if there actually is a ROMFS partition mounted and if the partition is identified as the one used to run tests on. This allows for user images to be mounted and for a successful test run if that is the case. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
1 parent 67de20a commit c895770

14 files changed

Lines changed: 113 additions & 2 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*.dxf binary
1515
*.mpy binary
1616
*.der binary
17+
*.bin binary
1718

1819
# These should also not be modified by git.
1920
tests/basics/string_cr_conversion.py -text

ports/qemu/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,16 @@ CFLAGS += $(SPECS_FRAGMENT)
220220
LDFLAGS += $(SPECS_FRAGMENT)
221221
endif
222222

223+
# Mount the ROMFS test image only if no other ROMFS partition has been mounted on slot 0.
224+
225+
ROMFS_TEST_IMAGE = assets/random_romfs.bin
226+
227+
ifneq ($(MICROPY_HW_ROMFS_PART0_START),)
228+
ifeq ($(QEMU_ROMFS_IMG0),)
229+
QEMU_ARGS += -device loader,file=$(ROMFS_TEST_IMAGE),addr=$(MICROPY_HW_ROMFS_PART0_START),force-raw=on
230+
endif
231+
endif
232+
223233
RUN_TESTS_FULL_ARGS = -t execpty:"$(QEMU_SYSTEM) $(QEMU_ARGS) -serial pty -kernel ../ports/qemu/$<" $(RUN_TESTS_ARGS)
224234

225235
################################################################################

tests/assets/Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
MPY_DIR = ../..
2+
3+
PYTHON := $(command -v python3 2> /dev/null)
4+
ifndef PYTHON
5+
PYTHON = python
6+
endif
7+
8+
# Files created with dd if=/dev/urandom ... - the file name is the CRC32
9+
# of the data contained in the file itself.
10+
11+
ROMFS_FILES = romfs_source/0x30d83fe5.bin \
12+
romfs_source/0x37bef0eb.bin \
13+
romfs_source/0x442f3b5f.bin \
14+
romfs_source/0x648793fb.bin \
15+
romfs_source/0x913837b6.bin \
16+
romfs_source/0xdb14aac7.bin \
17+
romfs_source/romfs_sentinel.txt
18+
19+
.PHONY: romfs
20+
romfs: all
21+
22+
.PHONY: clean
23+
clean:
24+
rm -f random_romfs.bin
25+
26+
all: random_romfs.bin
27+
28+
random_romfs.bin: $(ROMFS_FILES)
29+
$(PYTHON) $(MPY_DIR)/tools/mpremote/mpremote.py romfs --partition 0 --no-mpy --output $@ build romfs_source

tests/assets/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
This is a .mpy built against the current .mpy version that can be used to test
2-
freezing without a dependency on mpy-cross.
1+
This directory contains assets for other tests to use:
2+
3+
- A .mpy built against the current .mpy version that can be used to test
4+
freezing without a dependency on mpy-cross (`frozentest.py` and
5+
`frozentest.mpy`)
6+
- A ROMFS image containing random binary files for testing mounting and reading
7+
from the partition without having to generate a custom image
8+
(`random_romfs.bin`, the `romfs_source` directory, and `Makefile`)

tests/assets/random_romfs.bin

96.3 KB
Binary file not shown.
16 KB
Binary file not shown.
16 KB
Binary file not shown.
16 KB
Binary file not shown.
16 KB
Binary file not shown.
16 KB
Binary file not shown.

0 commit comments

Comments
 (0)