Skip to contentSkip to conversation

kselftest/arm64: signal: copy each test binary only once

PATCH In review Sasha Levin 3 participants 3 messages Oct 14 – Oct 15

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kselftest/arm64: signal: copy each test binary only once

The signal tests are built in testcases/ and then copied to the output directory. The copy rule lists every generated program as a target and copies all of them in each recipe:

  $(TEST_GEN_PROGS): $(PROGS)
          cp $(PROGS) $(OUTPUT)/

In a parallel build make runs that recipe once for each program, so several cp processes write the same destination files at the same time. cp then fails with "cannot create regular file ...: File exists", which fails the arm64 build even though every test compiled. A cross build of the arm64 signal tests at -j8 hit this in all of 8 runs.

Use a static pattern rule so that each output depends on, and copies, only its own binary.

Fixes f96bf4340316 ("kselftest: arm64: mangle_pstate_invalid_compat_toggle and common utils")
---
 tools/testing/selftests/arm64/signal/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/arm64/signal/Makefile +2 -2
index 1381039fb36f9..c4df4be41636c 100644
@@ -17,8 +17,8 @@ TEST_GEN_PROGS := $(notdir $(PROGS))
 # the toplevel makefile
 include ../../lib.mk
 
-$(TEST_GEN_PROGS): $(PROGS)
-	cp $(PROGS) $(OUTPUT)/
+$(TEST_GEN_PROGS): $(OUTPUT)/%: testcases/%
+	cp $< $@
 
 # Common test-unit targets to build common-layout test-cases executables
 # Needs secondary expansion to properly include the testcase c-file in pre-reqs

base-commit: 4eb2586bd40db27d77cc5b724ca9386ed0c71d53

Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 8 lines · Sasha Levin

The signal tests are built in testcases/ and then copied to the output directory. The copy rule lists every generated program as a target and copies all of them in each recipe:

  $(TEST_GEN_PROGS): $(PROGS)
          cp $(PROGS) $(OUTPUT)/

[...]

Applied to arm64 (for-next/kselftest), thanks!

[1/1] kselftest/arm64: signal: copy each test binary only once

      https://git.kernel.org/arm64/c/7b3b147c4104
Reviewed-by on v1 1/1
#2 lore raw
In reply to Sasha Levin
Quoted 3 lines · Sasha Levin

The signal tests are built in testcases/ and then copied to the output directory. The copy rule lists every generated program as a target and copies all of them in each recipe:

The build stuff for the signal testcases is a menance, it's being far too cute.

tools/testing/selftests/arm64/signal/Makefile TEST_GEN_PROGS := $(notdir $(PROGS)) · line 21

Quoted 4 lines

-$(TEST_GEN_PROGS): $(PROGS)

tools/testing/selftests/arm64/signal/Makefile +2 -1
-	cp $(PROGS) $(OUTPUT)/
+$(TEST_GEN_PROGS): $(OUTPUT)/%: testcases/%
+	cp $< $@

You'd have thought that'd be clearer with two separate rules but the obvious doesn't work and we're already being so clever I think this is fine: