xref: /freebsd/usr.bin/mkimg/tests/Makefile (revision 3ac62888fc211e92785751c9bb6e73868101f65c)
1cd0b4a3cSMarcel Moolenaar# $FreeBSD$
2cd0b4a3cSMarcel Moolenaar
3605b213eSEnji Cooper.PATH:	${.CURDIR}
4605b213eSEnji Cooper
543faedc1SGlen BarberPACKAGE=	tests
643faedc1SGlen Barber
7301441dcSEnji Cooper_REBASE_SCRIPT=	mkimg_test
8301441dcSEnji CooperATF_TESTS_SH=	${_REBASE_SCRIPT}
9cd0b4a3cSMarcel Moolenaar
10370d612fSMarcel MoolenaarSOURCES!=	cd ${.CURDIR}; echo *.hex
11370d612fSMarcel Moolenaar${PACKAGE}FILES+=		${SOURCES:S,.hex,,g}
12cd0b4a3cSMarcel Moolenaar
13605b213eSEnji Cooper.for f in ${${PACKAGE}FILES}
14370d612fSMarcel Moolenaar$f: $f.hex
15370d612fSMarcel Moolenaar	sed -e '/^#.*/D' < ${.ALLSRC} > ${.TARGET}
16605b213eSEnji Cooper.endfor
17cd0b4a3cSMarcel Moolenaar
18*3ac62888SAlex Richardson# Note: Pre-generating this test file saves a lot of time when building on
19*3ac62888SAlex Richardson# emulated platforms such as QEMU. It can take about 2-5 seconds to generate
20*3ac62888SAlex Richardson# the test file using jot (depending on the emulated architecture) and this
21*3ac62888SAlex Richardson# is done for each of the 168 test configurations.
22*3ac62888SAlex Richardson# The effect is even more pronounced on CHERI-RISCV QEMU (emulating CHERI inside
23*3ac62888SAlex Richardson# QEMU adds additional run-time overhead): Running the apm_1x1_512_raw without
24*3ac62888SAlex Richardson# the pre-generated file takes about 108 seconds of which 102 seconds (over 95%)
25*3ac62888SAlex Richardson# were spent running jot -b. It's even worse on CHERI-MIPS QEMU: 187 seconds
26*3ac62888SAlex Richardson# for jot -b P 2097152 > /dev/null. By using a pre-generated 4MB file, the
27*3ac62888SAlex Richardson# slowest test variant (vtoc8_63x255_4096_vhdx) now only takes 29 seconds (of
28*3ac62888SAlex Richardson# which 26s are spent in hexdump -C) instead of previously 2min30s.
29*3ac62888SAlex Richardson${PACKAGE}FILES+=	partition_data_4M.bin
30*3ac62888SAlex Richardsonpartition_data_4M.bin: Makefile
31*3ac62888SAlex Richardson	jot -b P 2097152 > ${.TARGET} || rm -f ${.TARGET}
32*3ac62888SAlex Richardson
33430f7286SEnji CooperCLEANFILES+=	${${PACKAGE}FILES}}
34d60351dfSMarcel Moolenaar
35*3ac62888SAlex Richardsonrebase: partition_data_4M.bin ${_REBASE_SCRIPT} .PHONY
36*3ac62888SAlex Richardson	cd ${.CURDIR}; PATH=${.OBJDIR}/..:$${PATH}:/usr/bin:/bin \
37*3ac62888SAlex Richardson	    /usr/libexec/atf-sh ${.OBJDIR}/${_REBASE_SCRIPT} -s ${.OBJDIR} rebase
38cd0b4a3cSMarcel Moolenaar
39cd0b4a3cSMarcel Moolenaar.include <bsd.test.mk>
40