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