Skip to content

Commit e42c319

Browse files
committed
test.mk: don't use a temporary random.bin
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 <pjones@redhat.com>
1 parent 98173f0 commit e42c319

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

include/test.mk

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ libefi-test.a :
7676
clean
7777

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

8286
$(wildcard test-*.c) :: %.c : test-random.h
8387
$(patsubst %.c,%,$(wildcard test-*.c)) :: | test-random.h
@@ -119,14 +123,13 @@ test-coverage : CFLAGS_GCOV+=--coverage
119123
test-coverage : $(tests)
120124

121125
test-clean :
122-
@rm -vf test-random.h random.bin libefi-test.a
126+
@rm -vf test-random.h libefi-test.a
123127
@rm -vf *.gcda *.gcno *.gcov vgcore.*
124128

125129
clean : test-clean
126130

127131
all : test-clean test
128132

129133
.PHONY: $(tests) all test clean
130-
.SECONDARY: random.bin
131134

132135
# vim:ft=make

0 commit comments

Comments
 (0)