Skip to content

Commit

Permalink
test.mk: don't use a temporary random.bin
Browse files Browse the repository at this point in the history
Sometimes using a temp file to make test-random.h breaks builds because
clean and test get made in parallel.

Since debugging parallel make is anything but easy, it's better to just
not use the intermediate file.  This patch makes it use a pipe instead.
Because we live in the worst possible world, we have to support RHEL 9,
in which xxd does not support "-n prefix", and so we have to build the
header variable definition lines in shell.

Signed-off-by: Peter Jones <[email protected]>
  • Loading branch information
vathpela committed Jan 22, 2025
1 parent 98173f0 commit f2196f6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions include/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ libefi-test.a :
clean

test-random.h:
dd if=/dev/urandom bs=512 count=17 of=random.bin
xxd -i random.bin test-random.h
dd if=/dev/urandom bs=512 count=17 status=none | ( \
echo "unsigned char random_bin[] = {" ; \
xxd -i - ; \
echo "};" ; \
echo "unsigned int random_bin_len = 8704;" ; \
) > test-random.h

$(wildcard test-*.c) :: %.c : test-random.h
$(patsubst %.c,%,$(wildcard test-*.c)) :: | test-random.h
Expand Down Expand Up @@ -119,14 +123,13 @@ test-coverage : CFLAGS_GCOV+=--coverage
test-coverage : $(tests)

test-clean :
@rm -vf test-random.h random.bin libefi-test.a
@rm -vf test-random.h libefi-test.a
@rm -vf *.gcda *.gcno *.gcov vgcore.*

clean : test-clean

all : test-clean test

.PHONY: $(tests) all test clean
.SECONDARY: random.bin

# vim:ft=make

0 comments on commit f2196f6

Please sign in to comment.