]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/bpf: Remove xxd util dependency
authorMykyta Yatsenko <yatsenko@meta.com>
Wed, 28 Jan 2026 19:05:51 +0000 (19:05 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 28 Jan 2026 21:23:51 +0000 (13:23 -0800)
The verification signature header generation requires converting a
binary certificate to a C array. Previously this only worked with
xxd (part of vim-common package).
As xxd may not be available on some systems building selftests, it makes
sense to substitute it with more common utils: hexdump, wc, sed to
generate equivalent C array output.

Tested by generating header with both xxd and hexdump and comparing
them.

Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/bpf/20260128190552.242335-1-mykyta.yatsenko5@gmail.com
tools/testing/selftests/bpf/.gitignore
tools/testing/selftests/bpf/Makefile

index b8bf51b7a0b0b104de717f21947abc1211fd0f46..a3ea98211ea6281c650256a09af120ccdddbd5c6 100644 (file)
@@ -23,7 +23,6 @@ test_tcpnotify_user
 test_libbpf
 xdping
 test_cpp
-test_progs_verification_cert
 *.d
 *.subskel.h
 *.skel.h
index 2c2f68a171ed0035d6c9d29dc50b8fed5dce1727..c6bf4dfb1495507706f1d1b8675242b4ad543628 100644 (file)
@@ -720,9 +720,12 @@ $(VERIFICATION_CERT) $(PRIVATE_KEY): $(VERIFY_SIG_SETUP)
        $(Q)mkdir -p $(BUILD_DIR)
        $(Q)$(VERIFY_SIG_SETUP) genkey $(BUILD_DIR)
 
+# Generates a header with C array declaration, containing test_progs_verification_cert bytes
 $(VERIFY_SIG_HDR): $(VERIFICATION_CERT)
-       $(Q)ln -fs $< test_progs_verification_cert && \
-       xxd -i test_progs_verification_cert > $@
+       $(Q)(echo "unsigned char test_progs_verification_cert[] = {"; \
+        hexdump -v -e '12/1 "  0x%02x," "\n"' $< | sed 's/0x  ,//g; $$s/,$$//'; \
+        echo "};"; \
+        echo "unsigned int test_progs_verification_cert_len = $$(wc -c < $<);") > $@
 
 # Define test_progs test runner.
 TRUNNER_TESTS_DIR := prog_tests
@@ -898,8 +901,7 @@ EXTRA_CLEAN := $(SCRATCH_DIR) $(HOST_SCRATCH_DIR)                   \
                               *.BTF *.BTF_ids *.BTF.base               \
                               no_alu32 cpuv4 bpf_gcc                   \
                               liburandom_read.so)                      \
-       $(OUTPUT)/FEATURE-DUMP.selftests                                \
-       test_progs_verification_cert
+       $(OUTPUT)/FEATURE-DUMP.selftests
 
 .PHONY: docs docs-clean