From: Denis Mukhin <dmukhin@ford.com>
There can be multiple test harnesses per one test target. Fix that by
iterating over all prerequisites in emit-harness-nested-rule().
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
tools/tests/domid/Makefile | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tools/tests/domid/Makefile b/tools/tests/domid/Makefile
index 753129029ed9..1a2129d20655 100644
--- a/tools/tests/domid/Makefile
+++ b/tools/tests/domid/Makefile
@@ -14,16 +14,18 @@ $(shell sed -n \
's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null)
endef
-# NB: $1 cannot be a list
+# $1 target
+# $2 list of test harnesses
define emit-harness-nested-rule
-$(1): $(CURDIR)/harness.h
- mkdir -p $$(@D);
- ln -sf $$< $$@;
+$(1): $(2)
+ mkdir -p $$(@D); \
+ for i in $$<; do ln -sf $$$$i $$@; done
endef
define emit-harness-rules
-$(foreach x,$(2),$(call emit-harness-nested-rule,$(CURDIR)/generated/$(x)))
+$(foreach x,$(2),$(call \
+ emit-harness-nested-rule,$(CURDIR)/generated/$(x),$(CURDIR)/harness.h))
$(1:.c=.o): $(addprefix $(CURDIR)/generated/,$(2))
endef
--
2.52.0
On Thu, Dec 04, 2025 at 04:37:11AM -0800, dmukhin@xen.org wrote: > diff --git a/tools/tests/domid/Makefile b/tools/tests/domid/Makefile > index 753129029ed9..1a2129d20655 100644 > --- a/tools/tests/domid/Makefile > +++ b/tools/tests/domid/Makefile > @@ -14,16 +14,18 @@ $(shell sed -n \ > 's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null) > endef > > -# NB: $1 cannot be a list > +# $1 target > +# $2 list of test harnesses > define emit-harness-nested-rule > -$(1): $(CURDIR)/harness.h > - mkdir -p $$(@D); > - ln -sf $$< $$@; > +$(1): $(2) > + mkdir -p $$(@D); \ > + for i in $$<; do ln -sf $$$$i $$@; done This doesn't work. First, on the first line, the introduction of the backslash mean that error from `mkdir` are ignored, Make will execute both line in the same shell instead of 2 separate shell. You would need to add `set -e` if executing all lines of the recipe in the same shell is useful. Second, $< only refer to the first prerequisite. So only a single symlink is created, even if $(2) list multiple files. Third, if we fix to loop through all the dependencies, the loop will still only create a single symlink, the last iteration will overwrite the previous one. Thanks, -- Anthony PERARD
On 04.12.2025 13:37, dmukhin@xen.org wrote:
> From: Denis Mukhin <dmukhin@ford.com>
>
> There can be multiple test harnesses per one test target. Fix that by
> iterating over all prerequisites in emit-harness-nested-rule().
This reads as if previously there was no iterating, and you add some.
What you do it further parameterize the existing macro. That anomaly
actually looks to reflect itself ...
> Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> ---
> tools/tests/domid/Makefile | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/tools/tests/domid/Makefile b/tools/tests/domid/Makefile
> index 753129029ed9..1a2129d20655 100644
> --- a/tools/tests/domid/Makefile
> +++ b/tools/tests/domid/Makefile
> @@ -14,16 +14,18 @@ $(shell sed -n \
> 's/^[ \t]*# *include[ \t]*[<"]\([^">]*\)[">].*/\1/p' $(1) 2>/dev/null)
> endef
>
> -# NB: $1 cannot be a list
> +# $1 target
> +# $2 list of test harnesses
... in this comment. According to ...
> define emit-harness-nested-rule
> -$(1): $(CURDIR)/harness.h
> - mkdir -p $$(@D);
> - ln -sf $$< $$@;
> +$(1): $(2)
... the use of the parameter, this is the list of dependencies.
And then, how does this make any difference at all when ...
> + mkdir -p $$(@D); \
> + for i in $$<; do ln -sf $$$$i $$@; done
>
> endef
>
> define emit-harness-rules
> -$(foreach x,$(2),$(call emit-harness-nested-rule,$(CURDIR)/generated/$(x)))
> +$(foreach x,$(2),$(call \
> + emit-harness-nested-rule,$(CURDIR)/generated/$(x),$(CURDIR)/harness.h))
... you still hardcode the exact same file here?
As an aside, imo this would better be wrapped as
$(foreach x,$(2),$(call emit-harness-nested-rule, \
$(CURDIR)/generated/$(x),$(CURDIR)/harness.h))
or even
$(foreach x,$(2),$(call emit-harness-nested-rule, \
$(CURDIR)/generated/$(x), \
$(CURDIR)/harness.h))
Jan
© 2016 - 2025 Red Hat, Inc.