1
2.PATH:	${.CURDIR}
3
4PACKAGE=	tests
5
6_REBASE_SCRIPT=	mkimg_test
7ATF_TESTS_SH=	${_REBASE_SCRIPT}
8
9SOURCES!=	cd ${.CURDIR}; echo *.hex
10${PACKAGE}FILES+=		${SOURCES:S,.hex,,g}
11
12.for f in ${${PACKAGE}FILES}
13$f: $f.hex
14	sed -e '/^#.*/D' < ${.ALLSRC} > ${.TARGET}
15.endfor
16
17# Note: Pre-generating this test file saves a lot of time when building on
18# emulated platforms such as QEMU. It can take about 2-5 seconds to generate
19# the test file using jot (depending on the emulated architecture) and this
20# is done for each of the 168 test configurations.
21# The effect is even more pronounced on CHERI-RISCV QEMU (emulating CHERI inside
22# QEMU adds additional run-time overhead): Running the apm_1x1_512_raw without
23# the pre-generated file takes about 108 seconds of which 102 seconds (over 95%)
24# were spent running jot -b. It's even worse on CHERI-MIPS QEMU: 187 seconds
25# for jot -b P 2097152 > /dev/null. By using a pre-generated 4MB file, the
26# slowest test variant (vtoc8_63x255_4096_vhdx) now only takes 29 seconds (of
27# which 26s are spent in hexdump -C) instead of previously 2min30s.
28${PACKAGE}FILES+=	partition_data_4M.bin
29partition_data_4M.bin: Makefile
30	jot -b P 2097152 > ${.TARGET} || rm -f ${.TARGET}
31
32CLEANFILES+=	${${PACKAGE}FILES}}
33
34rebase: partition_data_4M.bin ${_REBASE_SCRIPT} .PHONY
35	cd ${.CURDIR}; PATH=${.OBJDIR}/..:$${PATH}:/usr/bin:/bin \
36	    /usr/libexec/atf-sh ${.OBJDIR}/${_REBASE_SCRIPT} -s ${.OBJDIR} rebase
37
38.include <bsd.test.mk>
39