diff mbox series

[RFC,3/3] tests/tcg: commit Makefile atrocities in the name of portability

Message ID 20210803110237.1051032-4-alex.bennee@linaro.org
State New
Headers show
Series check-tcg hacks for BSD | expand

Commit Message

Alex Bennée Aug. 3, 2021, 11:02 a.m. UTC
Not all of the multiarch tests are pure POSIX so elide over those
tests on a non-Linux system. This allows for at least some of the
tests to be nominally usable by *BSD user builds.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Cc: Warner Losh <imp@bsdimp.com>
---
 tests/tcg/multiarch/Makefile.target | 6 +++++-
 tests/tcg/x86_64/Makefile.target    | 4 ++++
 2 files changed, 9 insertions(+), 1 deletion(-)

-- 
2.30.2

Comments

Warner Losh Sept. 14, 2021, 4:03 p.m. UTC | #1
On Tue, Aug 3, 2021 at 5:02 AM Alex Bennée <alex.bennee@linaro.org> wrote:

> Not all of the multiarch tests are pure POSIX so elide over those

> tests on a non-Linux system. This allows for at least some of the

> tests to be nominally usable by *BSD user builds.

>

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> Cc: Warner Losh <imp@bsdimp.com>

> ---

>  tests/tcg/multiarch/Makefile.target | 6 +++++-

>  tests/tcg/x86_64/Makefile.target    | 4 ++++

>  2 files changed, 9 insertions(+), 1 deletion(-)

>


Acked-by: Warner Losh <imp@bsdimp.com>


To do this with gcc10, however, I had to add -Wno-error=overflow
otherwise I got a lot of warnings about constants being truncated to
0.

It also fails the sha1 test, but when I run it by hand it works. It turns
out that I have a sha1 in my path, and at least in the bsd-user edition
of qemu-i386 tries to run that and fails.

Also, the hello world program needed tweaking

So with this applied and the following patch

diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target
index 63cf1b2573..39420631a8 100644
--- a/tests/tcg/Makefile.target
+++ b/tests/tcg/Makefile.target
@@ -155,7 +155,7 @@ RUN_TESTS+=$(EXTRA_RUNS)

 ifdef CONFIG_USER_ONLY
 run-%: %
-       $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on
$(TARGET_NAME)")
+       $(call run-test, $<, $(QEMU) $(QEMU_OPTS) ./$<, "$< on
$(TARGET_NAME)")

 run-plugin-%:
        $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
@@ -168,7 +168,7 @@ run-%: %
        $(call run-test, $<, \
          $(QEMU) -monitor none -display none \
                  -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
-                 $(QEMU_OPTS) $<, \
+                 $(QEMU_OPTS) ./$<, \
          "$< on $(TARGET_NAME)")

 run-plugin-%:
diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
index a053ca3f15..ae258c47f0 100644
--- a/tests/tcg/i386/Makefile.target
+++ b/tests/tcg/i386/Makefile.target
@@ -21,6 +21,7 @@ run-plugin-test-i386-pcmpistri-%: QEMU_OPTS += -cpu max
 run-test-i386-bmi2: QEMU_OPTS += -cpu max
 run-plugin-test-i386-bmi2-%: QEMU_OPTS += -cpu max

+CFLAGS +=  -Wno-error=overflow
 #
 # hello-i386 is a barebones app
 #
diff --git a/tests/tcg/i386/hello-i386.c b/tests/tcg/i386/hello-i386.c
index 59196dd0b7..4a5a25211c 100644
--- a/tests/tcg/i386/hello-i386.c
+++ b/tests/tcg/i386/hello-i386.c
@@ -1,4 +1,10 @@
+#ifdef __FreeBSD__
+#include <sys/syscall.h>
+#define __NR_exit SYS_exit
+#define __NR_write SYS_write
+#else
 #include <asm/unistd.h>
+#endif

 static inline void exit(int status)
 {

I get down to a failure i the mmap test.... and that's all I have time to
plumb the depths
of this morning... Investigating the mmap test failure will have to wait
for another day.

Warner


> diff --git a/tests/tcg/multiarch/Makefile.target

> b/tests/tcg/multiarch/Makefile.target

> index 85a6fb7a2e..38ee0f1dec 100644

> --- a/tests/tcg/multiarch/Makefile.target

> +++ b/tests/tcg/multiarch/Makefile.target

> @@ -10,7 +10,11 @@ MULTIARCH_SRC=$(SRC_PATH)/tests/tcg/multiarch

>  # Set search path for all sources

>  VPATH          += $(MULTIARCH_SRC)

>  MULTIARCH_SRCS   =$(notdir $(wildcard $(MULTIARCH_SRC)/*.c))

> -MULTIARCH_TESTS  =$(filter-out float_helpers, $(MULTIARCH_SRCS:.c=))

> +MULTIARCH_SKIP=float_helpers

> +ifeq ($(CONFIG_LINUX),)

> +MULTIARCH_SKIP+=linux-test

> +endif

> +MULTIARCH_TESTS  =$(filter-out $(MULTIARCH_SKIP),$(MULTIARCH_SRCS:.c=))

>

>  #

>  # The following are any additional rules needed to build things

> diff --git a/tests/tcg/x86_64/Makefile.target

> b/tests/tcg/x86_64/Makefile.target

> index 2151ea6302..d7a7385583 100644

> --- a/tests/tcg/x86_64/Makefile.target

> +++ b/tests/tcg/x86_64/Makefile.target

> @@ -8,8 +8,12 @@

>

>  include $(SRC_PATH)/tests/tcg/i386/Makefile.target

>

> +ifneq ($(CONFIG_LINUX),)

>  X86_64_TESTS += vsyscall

>  TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64

> +else

> +TESTS=$(MULTIARCH_TESTS)

> +endif

>  QEMU_OPTS += -cpu max

>

>  test-x86_64: LDFLAGS+=-lm -lc

> --

> 2.30.2

>

>
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 3, 2021 at 5:02 AM Alex Bennée &lt;<a href="mailto:alex.bennee@linaro.org">alex.bennee@linaro.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Not all of the multiarch tests are pure POSIX so elide over those<br>
tests on a non-Linux system. This allows for at least some of the<br>
tests to be nominally usable by *BSD user builds.<br>
<br>
Signed-off-by: Alex Bennée &lt;<a href="mailto:alex.bennee@linaro.org" target="_blank">alex.bennee@linaro.org</a>&gt;<br>

Cc: Warner Losh &lt;<a href="mailto:imp@bsdimp.com">imp@bsdimp.com</a>&gt;<br>
---<br>
 tests/tcg/multiarch/Makefile.target | 6 +++++-<br>
 tests/tcg/x86_64/Makefile.target    | 4 ++++<br>
 2 files changed, 9 insertions(+), 1 deletion(-)<br></blockquote><div><br></div><div>Acked-by: Warner Losh &lt;<a href="mailto:imp@bsdimp.com">imp@bsdimp.com</a>&gt;</div><div><br></div><div>To do this with gcc10, however, I had to add -Wno-error=overflow</div><div>otherwise I got a lot of warnings about constants being truncated to</div><div>0.</div><div><br></div><div>It also fails the sha1 test, but when I run it by hand it works. It turns</div><div>out that I have a sha1 in my path, and at least in the bsd-user edition</div><div>of qemu-i386 tries to run that and fails.</div><div><br></div><div>Also, the hello world program needed tweaking</div><div><br></div><div>So with this applied and the following patch</div><div><br></div><div>diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target<br>index 63cf1b2573..39420631a8 100644<br>--- a/tests/tcg/Makefile.target<br>+++ b/tests/tcg/Makefile.target<br>@@ -155,7 +155,7 @@ RUN_TESTS+=$(EXTRA_RUNS)<br><br> ifdef CONFIG_USER_ONLY<br> run-%: %<br>-       $(call run-test, $&lt;, $(QEMU) $(QEMU_OPTS) $&lt;, &quot;$&lt; on $(TARGET_NAME)&quot;)<br>+       $(call run-test, $&lt;, $(QEMU) $(QEMU_OPTS) ./$&lt;, &quot;$&lt; on $(TARGET_NAME)&quot;)<br><br> run-plugin-%:<br>        $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \<br>@@ -168,7 +168,7 @@ run-%: %<br>        $(call run-test, $&lt;, \<br>          $(QEMU) -monitor none -display none \<br>                  -chardev file$(COMMA)path=$&lt;.out$(COMMA)id=output \<br>-                 $(QEMU_OPTS) $&lt;, \<br>+                 $(QEMU_OPTS) ./$&lt;, \<br>          &quot;$&lt; on $(TARGET_NAME)&quot;)<br><br> run-plugin-%:<br>diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target<br>index a053ca3f15..ae258c47f0 100644<br>--- a/tests/tcg/i386/Makefile.target<br>+++ b/tests/tcg/i386/Makefile.target<br>@@ -21,6 +21,7 @@ run-plugin-test-i386-pcmpistri-%: QEMU_OPTS += -cpu max<br> run-test-i386-bmi2: QEMU_OPTS += -cpu max<br> run-plugin-test-i386-bmi2-%: QEMU_OPTS += -cpu max<br><br>+CFLAGS +=  -Wno-error=overflow<br> #<br> # hello-i386 is a barebones app<br> #<br>diff --git a/tests/tcg/i386/hello-i386.c b/tests/tcg/i386/hello-i386.c<br>index 59196dd0b7..4a5a25211c 100644<br>--- a/tests/tcg/i386/hello-i386.c<br>+++ b/tests/tcg/i386/hello-i386.c<br>@@ -1,4 +1,10 @@<br>+#ifdef __FreeBSD__<br>+#include &lt;sys/syscall.h&gt;<br>+#define __NR_exit SYS_exit<br>+#define __NR_write SYS_write<br>+#else<br> #include &lt;asm/unistd.h&gt;<br>+#endif<br><br> static inline void exit(int status)<br> {<br></div><div><br></div><div>I get down to a failure i the mmap test.... and that&#39;s all I have time to plumb the depths</div><div>of this morning... Investigating the mmap test failure will have to wait for another day.</div><div><br></div><div>Warner</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target<br>
index 85a6fb7a2e..38ee0f1dec 100644<br>
--- a/tests/tcg/multiarch/Makefile.target<br>
+++ b/tests/tcg/multiarch/Makefile.target<br>
@@ -10,7 +10,11 @@ MULTIARCH_SRC=$(SRC_PATH)/tests/tcg/multiarch<br>
 # Set search path for all sources<br>
 VPATH          += $(MULTIARCH_SRC)<br>
 MULTIARCH_SRCS   =$(notdir $(wildcard $(MULTIARCH_SRC)/*.c))<br>
-MULTIARCH_TESTS  =$(filter-out float_helpers, $(MULTIARCH_SRCS:.c=))<br>
+MULTIARCH_SKIP=float_helpers<br>
+ifeq ($(CONFIG_LINUX),)<br>
+MULTIARCH_SKIP+=linux-test<br>
+endif<br>
+MULTIARCH_TESTS  =$(filter-out $(MULTIARCH_SKIP),$(MULTIARCH_SRCS:.c=))<br>
<br>
 #<br>
 # The following are any additional rules needed to build things<br>
diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target<br>
index 2151ea6302..d7a7385583 100644<br>
--- a/tests/tcg/x86_64/Makefile.target<br>
+++ b/tests/tcg/x86_64/Makefile.target<br>
@@ -8,8 +8,12 @@<br>
<br>
 include $(SRC_PATH)/tests/tcg/i386/Makefile.target<br>
<br>
+ifneq ($(CONFIG_LINUX),)<br>
 X86_64_TESTS += vsyscall<br>
 TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64<br>
+else<br>
+TESTS=$(MULTIARCH_TESTS)<br>
+endif<br>
 QEMU_OPTS += -cpu max<br>
<br>
 test-x86_64: LDFLAGS+=-lm -lc<br>
-- <br>
2.30.2<br>
<br>
</blockquote></div></div>
Alex Bennée Sept. 17, 2021, 2:34 p.m. UTC | #2
Warner Losh <imp@bsdimp.com> writes:

> On Tue, Aug 3, 2021 at 5:02 AM Alex Bennée <alex.bennee@linaro.org> wrote:

>

>  Not all of the multiarch tests are pure POSIX so elide over those

>  tests on a non-Linux system. This allows for at least some of the

>  tests to be nominally usable by *BSD user builds.

>

>  Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

>  Cc: Warner Losh <imp@bsdimp.com>

>  ---

>   tests/tcg/multiarch/Makefile.target | 6 +++++-

>   tests/tcg/x86_64/Makefile.target    | 4 ++++

>   2 files changed, 9 insertions(+), 1 deletion(-)

>

> Acked-by: Warner Losh <imp@bsdimp.com>

>

> To do this with gcc10, however, I had to add -Wno-error=overflow

> otherwise I got a lot of warnings about constants being truncated to

> 0.

>

> It also fails the sha1 test, but when I run it by hand it works. It turns

> out that I have a sha1 in my path, and at least in the bsd-user edition

> of qemu-i386 tries to run that and fails.

>

> Also, the hello world program needed tweaking

>

> So with this applied and the following patch

>

> diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target

> index 63cf1b2573..39420631a8 100644

> --- a/tests/tcg/Makefile.target

> +++ b/tests/tcg/Makefile.target

> @@ -155,7 +155,7 @@ RUN_TESTS+=$(EXTRA_RUNS)

>

>  ifdef CONFIG_USER_ONLY

>  run-%: %

> -       $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)")

> +       $(call run-test, $<, $(QEMU) $(QEMU_OPTS) ./$<, "$< on $(TARGET_NAME)")

>

>  run-plugin-%:

>         $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \

> @@ -168,7 +168,7 @@ run-%: %

>         $(call run-test, $<, \

>           $(QEMU) -monitor none -display none \

>                   -chardev file$(COMMA)path=$<.out$(COMMA)id=output \

> -                 $(QEMU_OPTS) $<, \

> +                 $(QEMU_OPTS) ./$<, \

>           "$< on $(TARGET_NAME)")


That's weird. I'm not super keen to merge this because it's incomplete
(we have a large number of manual run-FOO stanzas). AFAICT neither of
the loaders attempt to enumerate and search path so I wonder if this is
a function of the shell?

>

>  run-plugin-%:

> diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target

> index a053ca3f15..ae258c47f0 100644

> --- a/tests/tcg/i386/Makefile.target

> +++ b/tests/tcg/i386/Makefile.target

> @@ -21,6 +21,7 @@ run-plugin-test-i386-pcmpistri-%: QEMU_OPTS += -cpu max

>  run-test-i386-bmi2: QEMU_OPTS += -cpu max

>  run-plugin-test-i386-bmi2-%: QEMU_OPTS += -cpu max

>

> +CFLAGS +=  -Wno-error=overflow


I'd apply this direct to the test in question rather than a global change.

>  #

>  # hello-i386 is a barebones app

>  #

> diff --git a/tests/tcg/i386/hello-i386.c b/tests/tcg/i386/hello-i386.c

> index 59196dd0b7..4a5a25211c 100644

> --- a/tests/tcg/i386/hello-i386.c

> +++ b/tests/tcg/i386/hello-i386.c

> @@ -1,4 +1,10 @@

> +#ifdef __FreeBSD__

> +#include <sys/syscall.h>

> +#define __NR_exit SYS_exit

> +#define __NR_write SYS_write

> +#else

>  #include <asm/unistd.h>

> +#endif

>

>  static inline void exit(int status)

>  {

>

> I get down to a failure i the mmap test.... and that's all I have time to plumb the depths

> of this morning... Investigating the mmap test failure will have to wait for another day.

>

> Warner

>  

>  diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target

>  index 85a6fb7a2e..38ee0f1dec 100644

>  --- a/tests/tcg/multiarch/Makefile.target

>  +++ b/tests/tcg/multiarch/Makefile.target

>  @@ -10,7 +10,11 @@ MULTIARCH_SRC=$(SRC_PATH)/tests/tcg/multiarch

>   # Set search path for all sources

>   VPATH          += $(MULTIARCH_SRC)

>   MULTIARCH_SRCS   =$(notdir $(wildcard $(MULTIARCH_SRC)/*.c))

>  -MULTIARCH_TESTS  =$(filter-out float_helpers, $(MULTIARCH_SRCS:.c=))

>  +MULTIARCH_SKIP=float_helpers

>  +ifeq ($(CONFIG_LINUX),)

>  +MULTIARCH_SKIP+=linux-test

>  +endif

>  +MULTIARCH_TESTS  =$(filter-out $(MULTIARCH_SKIP),$(MULTIARCH_SRCS:.c=))

>

>   #

>   # The following are any additional rules needed to build things

>  diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target

>  index 2151ea6302..d7a7385583 100644

>  --- a/tests/tcg/x86_64/Makefile.target

>  +++ b/tests/tcg/x86_64/Makefile.target

>  @@ -8,8 +8,12 @@

>

>   include $(SRC_PATH)/tests/tcg/i386/Makefile.target

>

>  +ifneq ($(CONFIG_LINUX),)

>   X86_64_TESTS += vsyscall

>   TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64

>  +else

>  +TESTS=$(MULTIARCH_TESTS)

>  +endif

>   QEMU_OPTS += -cpu max

>

>   test-x86_64: LDFLAGS+=-lm -lc

>  -- 

>  2.30.2



-- 
Alex Bennée
Warner Losh Sept. 17, 2021, 3:08 p.m. UTC | #3
On Fri, Sep 17, 2021 at 8:39 AM Alex Bennée <alex.bennee@linaro.org> wrote:

>

> Warner Losh <imp@bsdimp.com> writes:

>

> > On Tue, Aug 3, 2021 at 5:02 AM Alex Bennée <alex.bennee@linaro.org>

> wrote:

> >

> >  Not all of the multiarch tests are pure POSIX so elide over those

> >  tests on a non-Linux system. This allows for at least some of the

> >  tests to be nominally usable by *BSD user builds.

> >

> >  Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> >  Cc: Warner Losh <imp@bsdimp.com>

> >  ---

> >   tests/tcg/multiarch/Makefile.target | 6 +++++-

> >   tests/tcg/x86_64/Makefile.target    | 4 ++++

> >   2 files changed, 9 insertions(+), 1 deletion(-)

> >

> > Acked-by: Warner Losh <imp@bsdimp.com>

> >

> > To do this with gcc10, however, I had to add -Wno-error=overflow

> > otherwise I got a lot of warnings about constants being truncated to

> > 0.

> >

> > It also fails the sha1 test, but when I run it by hand it works. It turns

> > out that I have a sha1 in my path, and at least in the bsd-user edition

> > of qemu-i386 tries to run that and fails.

> >

> > Also, the hello world program needed tweaking

> >

> > So with this applied and the following patch

> >

> > diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target

> > index 63cf1b2573..39420631a8 100644

> > --- a/tests/tcg/Makefile.target

> > +++ b/tests/tcg/Makefile.target

> > @@ -155,7 +155,7 @@ RUN_TESTS+=$(EXTRA_RUNS)

> >

> >  ifdef CONFIG_USER_ONLY

> >  run-%: %

> > -       $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on

> $(TARGET_NAME)")

> > +       $(call run-test, $<, $(QEMU) $(QEMU_OPTS) ./$<, "$< on

> $(TARGET_NAME)")

> >

> >  run-plugin-%:

> >         $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \

> > @@ -168,7 +168,7 @@ run-%: %

> >         $(call run-test, $<, \

> >           $(QEMU) -monitor none -display none \

> >                   -chardev file$(COMMA)path=$<.out$(COMMA)id=output \

> > -                 $(QEMU_OPTS) $<, \

> > +                 $(QEMU_OPTS) ./$<, \

> >           "$< on $(TARGET_NAME)")

>

> That's weird. I'm not super keen to merge this because it's incomplete

> (we have a large number of manual run-FOO stanzas). AFAICT neither of

> the loaders attempt to enumerate and search path so I wonder if this is

> a function of the shell?

>


bsd-user does, in fact, search the path. It does so in loader_exec. It does
this,
I believe, to support execing native binaries, but I'll need to check on
that.

It's fine if we don't merge this just yet.

>  run-plugin-%:

> > diff --git a/tests/tcg/i386/Makefile.target

> b/tests/tcg/i386/Makefile.target

> > index a053ca3f15..ae258c47f0 100644

> > --- a/tests/tcg/i386/Makefile.target

> > +++ b/tests/tcg/i386/Makefile.target

> > @@ -21,6 +21,7 @@ run-plugin-test-i386-pcmpistri-%: QEMU_OPTS += -cpu max

> >  run-test-i386-bmi2: QEMU_OPTS += -cpu max

> >  run-plugin-test-i386-bmi2-%: QEMU_OPTS += -cpu max

> >

> > +CFLAGS +=  -Wno-error=overflow

>

> I'd apply this direct to the test in question rather than a global change.

>


I think we should not apply it at all. I was so happy to get things
compiling
that I'd raced ahead of myself: when this is active, the tests fail to run.


> >  #

> >  # hello-i386 is a barebones app

> >  #

> > diff --git a/tests/tcg/i386/hello-i386.c b/tests/tcg/i386/hello-i386.c

> > index 59196dd0b7..4a5a25211c 100644

> > --- a/tests/tcg/i386/hello-i386.c

> > +++ b/tests/tcg/i386/hello-i386.c

> > @@ -1,4 +1,10 @@

> > +#ifdef __FreeBSD__

> > +#include <sys/syscall.h>

> > +#define __NR_exit SYS_exit

> > +#define __NR_write SYS_write

> > +#else

> >  #include <asm/unistd.h>

> > +#endif

> >

> >  static inline void exit(int status)

> >  {

>


I can submit this as a separate thing, but it's the only patch I'm
completely sure of.

Warner


> > I get down to a failure i the mmap test.... and that's all I have time

> to plumb the depths

> > of this morning... Investigating the mmap test failure will have to wait

> for another day.

> >

> > Warner

> >

> >  diff --git a/tests/tcg/multiarch/Makefile.target

> b/tests/tcg/multiarch/Makefile.target

> >  index 85a6fb7a2e..38ee0f1dec 100644

> >  --- a/tests/tcg/multiarch/Makefile.target

> >  +++ b/tests/tcg/multiarch/Makefile.target

> >  @@ -10,7 +10,11 @@ MULTIARCH_SRC=$(SRC_PATH)/tests/tcg/multiarch

> >   # Set search path for all sources

> >   VPATH          += $(MULTIARCH_SRC)

> >   MULTIARCH_SRCS   =$(notdir $(wildcard $(MULTIARCH_SRC)/*.c))

> >  -MULTIARCH_TESTS  =$(filter-out float_helpers, $(MULTIARCH_SRCS:.c=))

> >  +MULTIARCH_SKIP=float_helpers

> >  +ifeq ($(CONFIG_LINUX),)

> >  +MULTIARCH_SKIP+=linux-test

> >  +endif

> >  +MULTIARCH_TESTS  =$(filter-out $(MULTIARCH_SKIP),$(MULTIARCH_SRCS:.c=))

> >

> >   #

> >   # The following are any additional rules needed to build things

> >  diff --git a/tests/tcg/x86_64/Makefile.target

> b/tests/tcg/x86_64/Makefile.target

> >  index 2151ea6302..d7a7385583 100644

> >  --- a/tests/tcg/x86_64/Makefile.target

> >  +++ b/tests/tcg/x86_64/Makefile.target

> >  @@ -8,8 +8,12 @@

> >

> >   include $(SRC_PATH)/tests/tcg/i386/Makefile.target

> >

> >  +ifneq ($(CONFIG_LINUX),)

> >   X86_64_TESTS += vsyscall

> >   TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64

> >  +else

> >  +TESTS=$(MULTIARCH_TESTS)

> >  +endif

> >   QEMU_OPTS += -cpu max

> >

> >   test-x86_64: LDFLAGS+=-lm -lc

> >  --

> >  2.30.2

>

>

> --

> Alex Bennée

>
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 17, 2021 at 8:39 AM Alex Bennée &lt;<a href="mailto:alex.bennee@linaro.org">alex.bennee@linaro.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Warner Losh &lt;<a href="mailto:imp@bsdimp.com" target="_blank">imp@bsdimp.com</a>&gt; writes:<br>
<br>
&gt; On Tue, Aug 3, 2021 at 5:02 AM Alex Bennée &lt;<a href="mailto:alex.bennee@linaro.org" target="_blank">alex.bennee@linaro.org</a>&gt; wrote:<br>
&gt;<br>
&gt;  Not all of the multiarch tests are pure POSIX so elide over those<br>
&gt;  tests on a non-Linux system. This allows for at least some of the<br>
&gt;  tests to be nominally usable by *BSD user builds.<br>
&gt;<br>
&gt;  Signed-off-by: Alex Bennée &lt;<a href="mailto:alex.bennee@linaro.org" target="_blank">alex.bennee@linaro.org</a>&gt;<br>
&gt;  Cc: Warner Losh &lt;<a href="mailto:imp@bsdimp.com" target="_blank">imp@bsdimp.com</a>&gt;<br>
&gt;  ---<br>
&gt;   tests/tcg/multiarch/Makefile.target | 6 +++++-<br>
&gt;   tests/tcg/x86_64/Makefile.target    | 4 ++++<br>
&gt;   2 files changed, 9 insertions(+), 1 deletion(-)<br>
&gt;<br>
&gt; Acked-by: Warner Losh &lt;<a href="mailto:imp@bsdimp.com" target="_blank">imp@bsdimp.com</a>&gt;<br>
&gt;<br>
&gt; To do this with gcc10, however, I had to add -Wno-error=overflow<br>
&gt; otherwise I got a lot of warnings about constants being truncated to<br>
&gt; 0.<br>
&gt;<br>
&gt; It also fails the sha1 test, but when I run it by hand it works. It turns<br>
&gt; out that I have a sha1 in my path, and at least in the bsd-user edition<br>
&gt; of qemu-i386 tries to run that and fails.<br>
&gt;<br>
&gt; Also, the hello world program needed tweaking<br>
&gt;<br>
&gt; So with this applied and the following patch<br>
&gt;<br>
&gt; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target<br>
&gt; index 63cf1b2573..39420631a8 100644<br>
&gt; --- a/tests/tcg/Makefile.target<br>
&gt; +++ b/tests/tcg/Makefile.target<br>
&gt; @@ -155,7 +155,7 @@ RUN_TESTS+=$(EXTRA_RUNS)<br>
&gt;<br>
&gt;  ifdef CONFIG_USER_ONLY<br>
&gt;  run-%: %<br>
&gt; -       $(call run-test, $&lt;, $(QEMU) $(QEMU_OPTS) $&lt;, &quot;$&lt; on $(TARGET_NAME)&quot;)<br>
&gt; +       $(call run-test, $&lt;, $(QEMU) $(QEMU_OPTS) ./$&lt;, &quot;$&lt; on $(TARGET_NAME)&quot;)<br>
&gt;<br>
&gt;  run-plugin-%:<br>
&gt;         $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \<br>
&gt; @@ -168,7 +168,7 @@ run-%: %<br>
&gt;         $(call run-test, $&lt;, \<br>
&gt;           $(QEMU) -monitor none -display none \<br>
&gt;                   -chardev file$(COMMA)path=$&lt;.out$(COMMA)id=output \<br>
&gt; -                 $(QEMU_OPTS) $&lt;, \<br>
&gt; +                 $(QEMU_OPTS) ./$&lt;, \<br>
&gt;           &quot;$&lt; on $(TARGET_NAME)&quot;)<br>
<br>
That&#39;s weird. I&#39;m not super keen to merge this because it&#39;s incomplete<br>
(we have a large number of manual run-FOO stanzas). AFAICT neither of<br>
the loaders attempt to enumerate and search path so I wonder if this is<br>
a function of the shell?<br></blockquote><div><br></div><div>bsd-user does, in fact, search the path. It does so in loader_exec. It does this,</div><div>I believe, to support execing native binaries, but I&#39;ll need to check on that.</div><div><br></div><div>It&#39;s fine if we don&#39;t merge this just yet.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
&gt;  run-plugin-%:<br>
&gt; diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target<br>
&gt; index a053ca3f15..ae258c47f0 100644<br>
&gt; --- a/tests/tcg/i386/Makefile.target<br>
&gt; +++ b/tests/tcg/i386/Makefile.target<br>
&gt; @@ -21,6 +21,7 @@ run-plugin-test-i386-pcmpistri-%: QEMU_OPTS += -cpu max<br>
&gt;  run-test-i386-bmi2: QEMU_OPTS += -cpu max<br>
&gt;  run-plugin-test-i386-bmi2-%: QEMU_OPTS += -cpu max<br>
&gt;<br>
&gt; +CFLAGS +=  -Wno-error=overflow<br>
<br>
I&#39;d apply this direct to the test in question rather than a global change.<br></blockquote><div><br></div><div>I think we should not apply it at all. I was so happy to get things compiling</div><div>that I&#39;d raced ahead of myself: when this is active, the tests fail to run.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
&gt;  #<br>
&gt;  # hello-i386 is a barebones app<br>
&gt;  #<br>
&gt; diff --git a/tests/tcg/i386/hello-i386.c b/tests/tcg/i386/hello-i386.c<br>
&gt; index 59196dd0b7..4a5a25211c 100644<br>
&gt; --- a/tests/tcg/i386/hello-i386.c<br>
&gt; +++ b/tests/tcg/i386/hello-i386.c<br>
&gt; @@ -1,4 +1,10 @@<br>
&gt; +#ifdef __FreeBSD__<br>
&gt; +#include &lt;sys/syscall.h&gt;<br>
&gt; +#define __NR_exit SYS_exit<br>
&gt; +#define __NR_write SYS_write<br>
&gt; +#else<br>
&gt;  #include &lt;asm/unistd.h&gt;<br>
&gt; +#endif<br>
&gt;<br>
&gt;  static inline void exit(int status)<br>
&gt;  {<br></blockquote><div><br></div><div>I can submit this as a separate thing, but it&#39;s the only patch I&#39;m completely sure of.</div><div><br></div><div>Warner</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
&gt; I get down to a failure i the mmap test.... and that&#39;s all I have time to plumb the depths<br>
&gt; of this morning... Investigating the mmap test failure will have to wait for another day.<br>
&gt;<br>
&gt; Warner<br>
&gt;  <br>
&gt;  diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target<br>
&gt;  index 85a6fb7a2e..38ee0f1dec 100644<br>
&gt;  --- a/tests/tcg/multiarch/Makefile.target<br>
&gt;  +++ b/tests/tcg/multiarch/Makefile.target<br>
&gt;  @@ -10,7 +10,11 @@ MULTIARCH_SRC=$(SRC_PATH)/tests/tcg/multiarch<br>
&gt;   # Set search path for all sources<br>
&gt;   VPATH          += $(MULTIARCH_SRC)<br>
&gt;   MULTIARCH_SRCS   =$(notdir $(wildcard $(MULTIARCH_SRC)/*.c))<br>
&gt;  -MULTIARCH_TESTS  =$(filter-out float_helpers, $(MULTIARCH_SRCS:.c=))<br>
&gt;  +MULTIARCH_SKIP=float_helpers<br>
&gt;  +ifeq ($(CONFIG_LINUX),)<br>
&gt;  +MULTIARCH_SKIP+=linux-test<br>
&gt;  +endif<br>
&gt;  +MULTIARCH_TESTS  =$(filter-out $(MULTIARCH_SKIP),$(MULTIARCH_SRCS:.c=))<br>
&gt;<br>
&gt;   #<br>
&gt;   # The following are any additional rules needed to build things<br>
&gt;  diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target<br>
&gt;  index 2151ea6302..d7a7385583 100644<br>
&gt;  --- a/tests/tcg/x86_64/Makefile.target<br>
&gt;  +++ b/tests/tcg/x86_64/Makefile.target<br>
&gt;  @@ -8,8 +8,12 @@<br>
&gt;<br>
&gt;   include $(SRC_PATH)/tests/tcg/i386/Makefile.target<br>
&gt;<br>
&gt;  +ifneq ($(CONFIG_LINUX),)<br>
&gt;   X86_64_TESTS += vsyscall<br>
&gt;   TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64<br>
&gt;  +else<br>
&gt;  +TESTS=$(MULTIARCH_TESTS)<br>
&gt;  +endif<br>
&gt;   QEMU_OPTS += -cpu max<br>
&gt;<br>
&gt;   test-x86_64: LDFLAGS+=-lm -lc<br>
&gt;  -- <br>
&gt;  2.30.2<br>
<br>
<br>
-- <br>
Alex Bennée<br>
</blockquote></div></div>
Alex Bennée Sept. 17, 2021, 4:41 p.m. UTC | #4
Warner Losh <imp@bsdimp.com> writes:

> On Fri, Sep 17, 2021 at 8:39 AM Alex Bennée <alex.bennee@linaro.org> wrote:

>

>  Warner Losh <imp@bsdimp.com> writes:

>

>  > On Tue, Aug 3, 2021 at 5:02 AM Alex Bennée <alex.bennee@linaro.org> wrote:

>  >

>  >  Not all of the multiarch tests are pure POSIX so elide over those

>  >  tests on a non-Linux system. This allows for at least some of the

>  >  tests to be nominally usable by *BSD user builds.

>  >

>  >  Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

>  >  Cc: Warner Losh <imp@bsdimp.com>

>  >  ---

>  >   tests/tcg/multiarch/Makefile.target | 6 +++++-

>  >   tests/tcg/x86_64/Makefile.target    | 4 ++++

>  >   2 files changed, 9 insertions(+), 1 deletion(-)

>  >

>  > Acked-by: Warner Losh <imp@bsdimp.com>

>  >

>  > To do this with gcc10, however, I had to add -Wno-error=overflow

>  > otherwise I got a lot of warnings about constants being truncated to

>  > 0.

>  >

>  > It also fails the sha1 test, but when I run it by hand it works. It turns

>  > out that I have a sha1 in my path, and at least in the bsd-user edition

>  > of qemu-i386 tries to run that and fails.

>  >

>  > Also, the hello world program needed tweaking

>  >

>  > So with this applied and the following patch

>  >

>  > diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target

>  > index 63cf1b2573..39420631a8 100644

>  > --- a/tests/tcg/Makefile.target

>  > +++ b/tests/tcg/Makefile.target

>  > @@ -155,7 +155,7 @@ RUN_TESTS+=$(EXTRA_RUNS)

>  >

>  >  ifdef CONFIG_USER_ONLY

>  >  run-%: %

>  > -       $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)")

>  > +       $(call run-test, $<, $(QEMU) $(QEMU_OPTS) ./$<, "$< on $(TARGET_NAME)")

>  >

>  >  run-plugin-%:

>  >         $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \

>  > @@ -168,7 +168,7 @@ run-%: %

>  >         $(call run-test, $<, \

>  >           $(QEMU) -monitor none -display none \

>  >                   -chardev file$(COMMA)path=$<.out$(COMMA)id=output \

>  > -                 $(QEMU_OPTS) $<, \

>  > +                 $(QEMU_OPTS) ./$<, \

>  >           "$< on $(TARGET_NAME)")

>

>  That's weird. I'm not super keen to merge this because it's incomplete

>  (we have a large number of manual run-FOO stanzas). AFAICT neither of

>  the loaders attempt to enumerate and search path so I wonder if this is

>  a function of the shell?

>

> bsd-user does, in fact, search the path. It does so in loader_exec. It does this,

> I believe, to support execing native binaries, but I'll need to check

> on that.


It's certainly different from what linux-user does. The execing of
native binaries seems a bit niche given you can always pass an explicit
path. Maybe you could tweak loader_exec to check for the local binary
first. It seems to skip straight to searching the path if there are no
/'s in the filename.

This is unrelated to how you handle foreign binaries on the BSDs? Is
there an equivalent to binfmt_misc?

-- 
Alex Bennée
Warner Losh Sept. 17, 2021, 5:23 p.m. UTC | #5
On Fri, Sep 17, 2021 at 10:45 AM Alex Bennée <alex.bennee@linaro.org> wrote:

>

> Warner Losh <imp@bsdimp.com> writes:

>

> > On Fri, Sep 17, 2021 at 8:39 AM Alex Bennée <alex.bennee@linaro.org>

> wrote:

> >

> >  Warner Losh <imp@bsdimp.com> writes:

> >

> >  > On Tue, Aug 3, 2021 at 5:02 AM Alex Bennée <alex.bennee@linaro.org>

> wrote:

> >  >

> >  >  Not all of the multiarch tests are pure POSIX so elide over those

> >  >  tests on a non-Linux system. This allows for at least some of the

> >  >  tests to be nominally usable by *BSD user builds.

> >  >

> >  >  Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

> >  >  Cc: Warner Losh <imp@bsdimp.com>

> >  >  ---

> >  >   tests/tcg/multiarch/Makefile.target | 6 +++++-

> >  >   tests/tcg/x86_64/Makefile.target    | 4 ++++

> >  >   2 files changed, 9 insertions(+), 1 deletion(-)

> >  >

> >  > Acked-by: Warner Losh <imp@bsdimp.com>

> >  >

> >  > To do this with gcc10, however, I had to add -Wno-error=overflow

> >  > otherwise I got a lot of warnings about constants being truncated to

> >  > 0.

> >  >

> >  > It also fails the sha1 test, but when I run it by hand it works. It

> turns

> >  > out that I have a sha1 in my path, and at least in the bsd-user

> edition

> >  > of qemu-i386 tries to run that and fails.

> >  >

> >  > Also, the hello world program needed tweaking

> >  >

> >  > So with this applied and the following patch

> >  >

> >  > diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target

> >  > index 63cf1b2573..39420631a8 100644

> >  > --- a/tests/tcg/Makefile.target

> >  > +++ b/tests/tcg/Makefile.target

> >  > @@ -155,7 +155,7 @@ RUN_TESTS+=$(EXTRA_RUNS)

> >  >

> >  >  ifdef CONFIG_USER_ONLY

> >  >  run-%: %

> >  > -       $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on

> $(TARGET_NAME)")

> >  > +       $(call run-test, $<, $(QEMU) $(QEMU_OPTS) ./$<, "$< on

> $(TARGET_NAME)")

> >  >

> >  >  run-plugin-%:

> >  >         $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \

> >  > @@ -168,7 +168,7 @@ run-%: %

> >  >         $(call run-test, $<, \

> >  >           $(QEMU) -monitor none -display none \

> >  >                   -chardev file$(COMMA)path=$<.out$(COMMA)id=output \

> >  > -                 $(QEMU_OPTS) $<, \

> >  > +                 $(QEMU_OPTS) ./$<, \

> >  >           "$< on $(TARGET_NAME)")

> >

> >  That's weird. I'm not super keen to merge this because it's incomplete

> >  (we have a large number of manual run-FOO stanzas). AFAICT neither of

> >  the loaders attempt to enumerate and search path so I wonder if this is

> >  a function of the shell?

> >

> > bsd-user does, in fact, search the path. It does so in loader_exec. It

> does this,

> > I believe, to support execing native binaries, but I'll need to check

> > on that.

>

> It's certainly different from what linux-user does. The execing of

> native binaries seems a bit niche given you can always pass an explicit

> path. Maybe you could tweak loader_exec to check for the local binary

> first. It seems to skip straight to searching the path if there are no

> /'s in the filename.

>

> This is unrelated to how you handle foreign binaries on the BSDs? Is

> there an equivalent to binfmt_misc?

>


It's a difference in the presentation of args in BSD. When reviewing the
code,
Kyle Evans said:

>> IIRC imgact_binmisc will have the resolved path but preserve argv as

>> it should have been were it not emulated, so we have to re-evaluate

>> the PATH search here because we try to be faithful to the context.


At the time, I confirmed that behavior. Thinking about it, if '.' isn't in
the
path, and we can't find it, then we're not in this condition. So that means
looking for it in '.' also won't break anything and will fix this issue.
I'll
rework bsd-user's bsdload.c to improve the logic.

Warner
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 17, 2021 at 10:45 AM Alex Bennée &lt;<a href="mailto:alex.bennee@linaro.org">alex.bennee@linaro.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Warner Losh &lt;<a href="mailto:imp@bsdimp.com" target="_blank">imp@bsdimp.com</a>&gt; writes:<br>
<br>
&gt; On Fri, Sep 17, 2021 at 8:39 AM Alex Bennée &lt;<a href="mailto:alex.bennee@linaro.org" target="_blank">alex.bennee@linaro.org</a>&gt; wrote:<br>
&gt;<br>
&gt;  Warner Losh &lt;<a href="mailto:imp@bsdimp.com" target="_blank">imp@bsdimp.com</a>&gt; writes:<br>
&gt;<br>
&gt;  &gt; On Tue, Aug 3, 2021 at 5:02 AM Alex Bennée &lt;<a href="mailto:alex.bennee@linaro.org" target="_blank">alex.bennee@linaro.org</a>&gt; wrote:<br>
&gt;  &gt;<br>
&gt;  &gt;  Not all of the multiarch tests are pure POSIX so elide over those<br>
&gt;  &gt;  tests on a non-Linux system. This allows for at least some of the<br>
&gt;  &gt;  tests to be nominally usable by *BSD user builds.<br>
&gt;  &gt;<br>
&gt;  &gt;  Signed-off-by: Alex Bennée &lt;<a href="mailto:alex.bennee@linaro.org" target="_blank">alex.bennee@linaro.org</a>&gt;<br>
&gt;  &gt;  Cc: Warner Losh &lt;<a href="mailto:imp@bsdimp.com" target="_blank">imp@bsdimp.com</a>&gt;<br>
&gt;  &gt;  ---<br>
&gt;  &gt;   tests/tcg/multiarch/Makefile.target | 6 +++++-<br>
&gt;  &gt;   tests/tcg/x86_64/Makefile.target    | 4 ++++<br>
&gt;  &gt;   2 files changed, 9 insertions(+), 1 deletion(-)<br>
&gt;  &gt;<br>
&gt;  &gt; Acked-by: Warner Losh &lt;<a href="mailto:imp@bsdimp.com" target="_blank">imp@bsdimp.com</a>&gt;<br>
&gt;  &gt;<br>
&gt;  &gt; To do this with gcc10, however, I had to add -Wno-error=overflow<br>
&gt;  &gt; otherwise I got a lot of warnings about constants being truncated to<br>
&gt;  &gt; 0.<br>
&gt;  &gt;<br>
&gt;  &gt; It also fails the sha1 test, but when I run it by hand it works. It turns<br>
&gt;  &gt; out that I have a sha1 in my path, and at least in the bsd-user edition<br>
&gt;  &gt; of qemu-i386 tries to run that and fails.<br>
&gt;  &gt;<br>
&gt;  &gt; Also, the hello world program needed tweaking<br>
&gt;  &gt;<br>
&gt;  &gt; So with this applied and the following patch<br>
&gt;  &gt;<br>
&gt;  &gt; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target<br>
&gt;  &gt; index 63cf1b2573..39420631a8 100644<br>
&gt;  &gt; --- a/tests/tcg/Makefile.target<br>
&gt;  &gt; +++ b/tests/tcg/Makefile.target<br>
&gt;  &gt; @@ -155,7 +155,7 @@ RUN_TESTS+=$(EXTRA_RUNS)<br>
&gt;  &gt;<br>
&gt;  &gt;  ifdef CONFIG_USER_ONLY<br>
&gt;  &gt;  run-%: %<br>
&gt;  &gt; -       $(call run-test, $&lt;, $(QEMU) $(QEMU_OPTS) $&lt;, &quot;$&lt; on $(TARGET_NAME)&quot;)<br>
&gt;  &gt; +       $(call run-test, $&lt;, $(QEMU) $(QEMU_OPTS) ./$&lt;, &quot;$&lt; on $(TARGET_NAME)&quot;)<br>
&gt;  &gt;<br>
&gt;  &gt;  run-plugin-%:<br>
&gt;  &gt;         $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \<br>
&gt;  &gt; @@ -168,7 +168,7 @@ run-%: %<br>
&gt;  &gt;         $(call run-test, $&lt;, \<br>
&gt;  &gt;           $(QEMU) -monitor none -display none \<br>
&gt;  &gt;                   -chardev file$(COMMA)path=$&lt;.out$(COMMA)id=output \<br>
&gt;  &gt; -                 $(QEMU_OPTS) $&lt;, \<br>
&gt;  &gt; +                 $(QEMU_OPTS) ./$&lt;, \<br>
&gt;  &gt;           &quot;$&lt; on $(TARGET_NAME)&quot;)<br>
&gt;<br>
&gt;  That&#39;s weird. I&#39;m not super keen to merge this because it&#39;s incomplete<br>
&gt;  (we have a large number of manual run-FOO stanzas). AFAICT neither of<br>
&gt;  the loaders attempt to enumerate and search path so I wonder if this is<br>
&gt;  a function of the shell?<br>
&gt;<br>
&gt; bsd-user does, in fact, search the path. It does so in loader_exec. It does this,<br>
&gt; I believe, to support execing native binaries, but I&#39;ll need to check<br>
&gt; on that.<br>
<br>
It&#39;s certainly different from what linux-user does. The execing of<br>
native binaries seems a bit niche given you can always pass an explicit<br>
path. Maybe you could tweak loader_exec to check for the local binary<br>
first. It seems to skip straight to searching the path if there are no<br>
/&#39;s in the filename.<br>
<br>
This is unrelated to how you handle foreign binaries on the BSDs? Is<br>
there an equivalent to binfmt_misc?<br></blockquote><div><br></div><div>It&#39;s a difference in the presentation of args in BSD. When reviewing the code,</div><div>Kyle Evans said:</div><div><br></div>&gt;&gt; IIRC imgact_binmisc will have the resolved path but preserve argv as<br>&gt;&gt; it should have been were it not emulated, so we have to re-evaluate<br><div>&gt;&gt; the PATH search here because we try to be faithful to the context.</div><div><br></div><div>At the time, I confirmed that behavior. Thinking about it, if &#39;.&#39; isn&#39;t in the</div><div>path, and we can&#39;t find it, then we&#39;re not in this condition. So that means</div><div>looking for it in &#39;.&#39; also won&#39;t break anything and will fix this issue. I&#39;ll</div><div>rework bsd-user&#39;s bsdload.c to improve the logic.</div><div><br></div><div>Warner</div></div></div>
diff mbox series

Patch

diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target
index 85a6fb7a2e..38ee0f1dec 100644
--- a/tests/tcg/multiarch/Makefile.target
+++ b/tests/tcg/multiarch/Makefile.target
@@ -10,7 +10,11 @@  MULTIARCH_SRC=$(SRC_PATH)/tests/tcg/multiarch
 # Set search path for all sources
 VPATH 		+= $(MULTIARCH_SRC)
 MULTIARCH_SRCS   =$(notdir $(wildcard $(MULTIARCH_SRC)/*.c))
-MULTIARCH_TESTS  =$(filter-out float_helpers, $(MULTIARCH_SRCS:.c=))
+MULTIARCH_SKIP=float_helpers
+ifeq ($(CONFIG_LINUX),)
+MULTIARCH_SKIP+=linux-test
+endif
+MULTIARCH_TESTS  =$(filter-out $(MULTIARCH_SKIP),$(MULTIARCH_SRCS:.c=))
 
 #
 # The following are any additional rules needed to build things
diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target
index 2151ea6302..d7a7385583 100644
--- a/tests/tcg/x86_64/Makefile.target
+++ b/tests/tcg/x86_64/Makefile.target
@@ -8,8 +8,12 @@ 
 
 include $(SRC_PATH)/tests/tcg/i386/Makefile.target
 
+ifneq ($(CONFIG_LINUX),)
 X86_64_TESTS += vsyscall
 TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64
+else
+TESTS=$(MULTIARCH_TESTS)
+endif
 QEMU_OPTS += -cpu max
 
 test-x86_64: LDFLAGS+=-lm -lc