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