diff mbox series

Add --disable-test-container to disable test container

Message ID 20240204185531.2816341-1-hjl.tools@gmail.com
State New
Headers show
Series Add --disable-test-container to disable test container | expand

Commit Message

H.J. Lu Feb. 4, 2024, 6:55 p.m. UTC
It can be difficult to run tests in container under simulator.  Add
--disable-test-container configure option to disable test container.
Container tests are enabled by default.
---
 Makefile        |  2 ++
 Rules           |  5 +++++
 configure       |  7 +++++++
 configure.ac    |  6 ++++++
 nss/Makefile    |  2 ++
 posix/Makefile  |  6 +++++-
 resolv/Makefile | 11 +++++++++--
 7 files changed, 36 insertions(+), 3 deletions(-)

Comments

Adhemerval Zanella Netto Feb. 5, 2024, 1:55 p.m. UTC | #1
On 04/02/24 15:55, H.J. Lu wrote:
> It can be difficult to run tests in container under simulator.  Add
> --disable-test-container configure option to disable test container.
> Container tests are enabled by default.

Which is the failure that running under this simulator throw? Would be
possible to detect it on test-container and fail with UNSUPPORTED instead?

I am not found on configure switch that disable testing, it seems just
extra burden while adding test-container and this decrease test coverage
when using this flag.

> ---
>  Makefile        |  2 ++
>  Rules           |  5 +++++
>  configure       |  7 +++++++
>  configure.ac    |  6 ++++++
>  nss/Makefile    |  2 ++
>  posix/Makefile  |  6 +++++-
>  resolv/Makefile | 11 +++++++++--
>  7 files changed, 36 insertions(+), 3 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 7052b46df8..2ba4a5ecd3 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -610,6 +610,7 @@ else
>  LINKS_DSO_PROGRAM = links-dso-program
>  endif
>  
> +ifeq (yes,$(enable-test-container))
>  $(tests-container) $(addsuffix /tests,$(subdirs)) : \
>  		$(objpfx)testroot.pristine/install.stamp
>  $(objpfx)testroot.pristine/install.stamp :
> @@ -655,6 +656,7 @@ endif
>  	  INSTALL_UNCOMPRESSED=yes subdirs='$(sorted-subdirs)'
>  	rm -f $(symbolic-link-list)
>  	touch $(objpfx)testroot.pristine/install.stamp
> +endif
>  
>  tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special))
>  tests: $(tests-special)
> diff --git a/Rules b/Rules
> index c7db0a4869..787024c729 100644
> --- a/Rules
> +++ b/Rules
> @@ -142,6 +142,11 @@ endif
>  # Generate constant files for Python pretty printers if required.
>  others: $(py-const)
>  
> +ifeq (no,$(enable-test-container))
> +# Don't run any container tests with --disable-test-container.
> +tests-container :=
> +endif
> +
>  ifeq ($(run-built-tests),no)
>  tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported), \
>                                            $(tests) $(tests-internal) \
> diff --git a/configure b/configure
> index 59ff1e415d..2ca1fcf43f 100755
> --- a/configure
> +++ b/configure
> @@ -7852,6 +7852,13 @@ fi
>  config_vars="$config_vars
>  enable-static-pie = $libc_cv_static_pie"
>  
> +# Enable test-container by default.
> +if test "x$enable_test_container" = x; then
> +  enable_test_container=yes
> +fi
> +config_vars="$config_vars
> +enable-test-container = $enable_test_container"
> +
>  # Set the `multidir' variable by grabbing the variable from the compiler.
>  # We do it once and save the result in a generated makefile.
>  libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
> diff --git a/configure.ac b/configure.ac
> index 65799e5685..e1956b98cc 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1740,6 +1740,12 @@ if test "$libc_cv_static_pie" = "yes"; then
>  fi
>  LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
>  
> +# Enable test-container by default.
> +if test "x$enable_test_container" = x; then
> +  enable_test_container=yes
> +fi
> +LIBC_CONFIG_VAR([enable-test-container], [$enable_test_container])
> +
>  # Set the `multidir' variable by grabbing the variable from the compiler.
>  # We do it once and save the result in a generated makefile.
>  libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
> diff --git a/nss/Makefile b/nss/Makefile
> index 9331b3308c..ae083a9343 100644
> --- a/nss/Makefile
> +++ b/nss/Makefile
> @@ -434,9 +434,11 @@ extra-test-objs		+= nss_test1.os nss_test2.os nss_test_errno.os \
>  
>  ifeq ($(run-built-tests),yes)
>  ifneq (no,$(PERL))
> +ifeq (yes,$(enable-test-container))
>  tests-special += $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out
>  endif
>  endif
> +endif
>  
>  generated += mtrace-tst-nss-gai-hv2-canonname.out \
>  		tst-nss-gai-hv2-canonname.mtrace
> diff --git a/posix/Makefile b/posix/Makefile
> index a1e84853a8..d3a70ab6b4 100644
> --- a/posix/Makefile
> +++ b/posix/Makefile
> @@ -462,7 +462,6 @@ endif
>  tests-special += $(objpfx)annexc.out
>  ifeq ($(run-built-tests),yes)
>  tests-special += \
> -  $(objpfx)bug-ga2-mem.out \
>    $(objpfx)bug-glob2-mem.out \
>    $(objpfx)bug-regex14-mem.out \
>    $(objpfx)bug-regex2-mem.out \
> @@ -475,9 +474,14 @@ tests-special += \
>    $(objpfx)tst-glob-tilde-mem.out \
>    $(objpfx)tst-pcre-mem.out \
>    $(objpfx)tst-rxspencer-no-utf8-mem.out \
> +  # tests-special
> +ifeq (yes,$(enable-test-container))
> +tests-special += \
> +  $(objpfx)bug-ga2-mem.out \
>    $(objpfx)tst-vfork3-mem.out \
>    # tests-special
>  endif
> +endif
>  
>  include ../Rules
>  
> diff --git a/resolv/Makefile b/resolv/Makefile
> index 5f44f5896b..62c81fe998 100644
> --- a/resolv/Makefile
> +++ b/resolv/Makefile
> @@ -221,8 +221,15 @@ $(inst_libdir)/libnss_dns.so:
>  
>  ifeq ($(run-built-tests),yes)
>  ifneq (no,$(PERL))
> -tests-special += $(objpfx)mtrace-tst-leaks.out $(objpfx)mtrace-tst-leaks2.out \
> -		 $(objpfx)mtrace-tst-resolv-res_ninit.out
> +tests-special += \
> +  $(objpfx)mtrace-tst-leaks.out \
> +  $(objpfx)mtrace-tst-resolv-res_ninit.out \
> +# tests-special
> +ifeq (yes,$(enable-test-container))
> +tests-special += \
> +  $(objpfx)mtrace-tst-leaks2.out \
> +# tests-special
> +endif
>  endif
>  endif
>
H.J. Lu Feb. 5, 2024, 2:41 p.m. UTC | #2
On Mon, Feb 5, 2024 at 5:55 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 04/02/24 15:55, H.J. Lu wrote:
> > It can be difficult to run tests in container under simulator.  Add
> > --disable-test-container configure option to disable test container.
> > Container tests are enabled by default.
>
> Which is the failure that running under this simulator throw? Would be
> possible to detect it on test-container and fail with UNSUPPORTED instead?

I am using

$ make check test-wrapper=$(PWD)/test-sde.sh

to test glibc compiled with Intel APX under APX emulator (SDE).  SDE
doesn't work with container.  SDE doesn't require any code changes.
I don't think we can detect it in container.  Also GDB and LD_PELOAD
tests don't work.  I don't know how to detect them either.

> I am not found on configure switch that disable testing, it seems just
> extra burden while adding test-container and this decrease test coverage
> when using this flag.
>
> > ---
> >  Makefile        |  2 ++
> >  Rules           |  5 +++++
> >  configure       |  7 +++++++
> >  configure.ac    |  6 ++++++
> >  nss/Makefile    |  2 ++
> >  posix/Makefile  |  6 +++++-
> >  resolv/Makefile | 11 +++++++++--
> >  7 files changed, 36 insertions(+), 3 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 7052b46df8..2ba4a5ecd3 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -610,6 +610,7 @@ else
> >  LINKS_DSO_PROGRAM = links-dso-program
> >  endif
> >
> > +ifeq (yes,$(enable-test-container))
> >  $(tests-container) $(addsuffix /tests,$(subdirs)) : \
> >               $(objpfx)testroot.pristine/install.stamp
> >  $(objpfx)testroot.pristine/install.stamp :
> > @@ -655,6 +656,7 @@ endif
> >         INSTALL_UNCOMPRESSED=yes subdirs='$(sorted-subdirs)'
> >       rm -f $(symbolic-link-list)
> >       touch $(objpfx)testroot.pristine/install.stamp
> > +endif
> >
> >  tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special))
> >  tests: $(tests-special)
> > diff --git a/Rules b/Rules
> > index c7db0a4869..787024c729 100644
> > --- a/Rules
> > +++ b/Rules
> > @@ -142,6 +142,11 @@ endif
> >  # Generate constant files for Python pretty printers if required.
> >  others: $(py-const)
> >
> > +ifeq (no,$(enable-test-container))
> > +# Don't run any container tests with --disable-test-container.
> > +tests-container :=
> > +endif
> > +
> >  ifeq ($(run-built-tests),no)
> >  tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported), \
> >                                            $(tests) $(tests-internal) \
> > diff --git a/configure b/configure
> > index 59ff1e415d..2ca1fcf43f 100755
> > --- a/configure
> > +++ b/configure
> > @@ -7852,6 +7852,13 @@ fi
> >  config_vars="$config_vars
> >  enable-static-pie = $libc_cv_static_pie"
> >
> > +# Enable test-container by default.
> > +if test "x$enable_test_container" = x; then
> > +  enable_test_container=yes
> > +fi
> > +config_vars="$config_vars
> > +enable-test-container = $enable_test_container"
> > +
> >  # Set the `multidir' variable by grabbing the variable from the compiler.
> >  # We do it once and save the result in a generated makefile.
> >  libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
> > diff --git a/configure.ac b/configure.ac
> > index 65799e5685..e1956b98cc 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -1740,6 +1740,12 @@ if test "$libc_cv_static_pie" = "yes"; then
> >  fi
> >  LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
> >
> > +# Enable test-container by default.
> > +if test "x$enable_test_container" = x; then
> > +  enable_test_container=yes
> > +fi
> > +LIBC_CONFIG_VAR([enable-test-container], [$enable_test_container])
> > +
> >  # Set the `multidir' variable by grabbing the variable from the compiler.
> >  # We do it once and save the result in a generated makefile.
> >  libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
> > diff --git a/nss/Makefile b/nss/Makefile
> > index 9331b3308c..ae083a9343 100644
> > --- a/nss/Makefile
> > +++ b/nss/Makefile
> > @@ -434,9 +434,11 @@ extra-test-objs          += nss_test1.os nss_test2.os nss_test_errno.os \
> >
> >  ifeq ($(run-built-tests),yes)
> >  ifneq (no,$(PERL))
> > +ifeq (yes,$(enable-test-container))
> >  tests-special += $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out
> >  endif
> >  endif
> > +endif
> >
> >  generated += mtrace-tst-nss-gai-hv2-canonname.out \
> >               tst-nss-gai-hv2-canonname.mtrace
> > diff --git a/posix/Makefile b/posix/Makefile
> > index a1e84853a8..d3a70ab6b4 100644
> > --- a/posix/Makefile
> > +++ b/posix/Makefile
> > @@ -462,7 +462,6 @@ endif
> >  tests-special += $(objpfx)annexc.out
> >  ifeq ($(run-built-tests),yes)
> >  tests-special += \
> > -  $(objpfx)bug-ga2-mem.out \
> >    $(objpfx)bug-glob2-mem.out \
> >    $(objpfx)bug-regex14-mem.out \
> >    $(objpfx)bug-regex2-mem.out \
> > @@ -475,9 +474,14 @@ tests-special += \
> >    $(objpfx)tst-glob-tilde-mem.out \
> >    $(objpfx)tst-pcre-mem.out \
> >    $(objpfx)tst-rxspencer-no-utf8-mem.out \
> > +  # tests-special
> > +ifeq (yes,$(enable-test-container))
> > +tests-special += \
> > +  $(objpfx)bug-ga2-mem.out \
> >    $(objpfx)tst-vfork3-mem.out \
> >    # tests-special
> >  endif
> > +endif
> >
> >  include ../Rules
> >
> > diff --git a/resolv/Makefile b/resolv/Makefile
> > index 5f44f5896b..62c81fe998 100644
> > --- a/resolv/Makefile
> > +++ b/resolv/Makefile
> > @@ -221,8 +221,15 @@ $(inst_libdir)/libnss_dns.so:
> >
> >  ifeq ($(run-built-tests),yes)
> >  ifneq (no,$(PERL))
> > -tests-special += $(objpfx)mtrace-tst-leaks.out $(objpfx)mtrace-tst-leaks2.out \
> > -              $(objpfx)mtrace-tst-resolv-res_ninit.out
> > +tests-special += \
> > +  $(objpfx)mtrace-tst-leaks.out \
> > +  $(objpfx)mtrace-tst-resolv-res_ninit.out \
> > +# tests-special
> > +ifeq (yes,$(enable-test-container))
> > +tests-special += \
> > +  $(objpfx)mtrace-tst-leaks2.out \
> > +# tests-special
> > +endif
> >  endif
> >  endif
> >
Florian Weimer Feb. 5, 2024, 2:46 p.m. UTC | #3
* H. J. Lu:

> It can be difficult to run tests in container under simulator.  Add
> --disable-test-container configure option to disable test container.
> Container tests are enabled by default.

I think we should compile the test-in-container tests.  One way to get
that might be to build support/test-container.c in such a way that it
always  returns 77.

Thanks,
Florian
Adhemerval Zanella Netto Feb. 5, 2024, 2:54 p.m. UTC | #4
On 05/02/24 11:41, H.J. Lu wrote:
> On Mon, Feb 5, 2024 at 5:55 AM Adhemerval Zanella Netto
> <adhemerval.zanella@linaro.org> wrote:
>>
>>
>>
>> On 04/02/24 15:55, H.J. Lu wrote:
>>> It can be difficult to run tests in container under simulator.  Add
>>> --disable-test-container configure option to disable test container.
>>> Container tests are enabled by default.
>>
>> Which is the failure that running under this simulator throw? Would be
>> possible to detect it on test-container and fail with UNSUPPORTED instead?
> 
> I am using
> 
> $ make check test-wrapper=$(PWD)/test-sde.sh
> 
> to test glibc compiled with Intel APX under APX emulator (SDE).  SDE
> doesn't work with container.  SDE doesn't require any code changes.
> I don't think we can detect it in container.  Also GDB and LD_PELOAD
> tests don't work.  I don't know how to detect them either.

Right, but what kind of error does the SDE emulator trigger with container
tests? It is something similar to qemu-user where it emulates the syscall
or is it running a underlying kernel like qemu-system?

> 
>> I am not found on configure switch that disable testing, it seems just
>> extra burden while adding test-container and this decrease test coverage
>> when using this flag.
>>
>>> ---
>>>  Makefile        |  2 ++
>>>  Rules           |  5 +++++
>>>  configure       |  7 +++++++
>>>  configure.ac    |  6 ++++++
>>>  nss/Makefile    |  2 ++
>>>  posix/Makefile  |  6 +++++-
>>>  resolv/Makefile | 11 +++++++++--
>>>  7 files changed, 36 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/Makefile b/Makefile
>>> index 7052b46df8..2ba4a5ecd3 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -610,6 +610,7 @@ else
>>>  LINKS_DSO_PROGRAM = links-dso-program
>>>  endif
>>>
>>> +ifeq (yes,$(enable-test-container))
>>>  $(tests-container) $(addsuffix /tests,$(subdirs)) : \
>>>               $(objpfx)testroot.pristine/install.stamp
>>>  $(objpfx)testroot.pristine/install.stamp :
>>> @@ -655,6 +656,7 @@ endif
>>>         INSTALL_UNCOMPRESSED=yes subdirs='$(sorted-subdirs)'
>>>       rm -f $(symbolic-link-list)
>>>       touch $(objpfx)testroot.pristine/install.stamp
>>> +endif
>>>
>>>  tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special))
>>>  tests: $(tests-special)
>>> diff --git a/Rules b/Rules
>>> index c7db0a4869..787024c729 100644
>>> --- a/Rules
>>> +++ b/Rules
>>> @@ -142,6 +142,11 @@ endif
>>>  # Generate constant files for Python pretty printers if required.
>>>  others: $(py-const)
>>>
>>> +ifeq (no,$(enable-test-container))
>>> +# Don't run any container tests with --disable-test-container.
>>> +tests-container :=
>>> +endif
>>> +
>>>  ifeq ($(run-built-tests),no)
>>>  tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported), \
>>>                                            $(tests) $(tests-internal) \
>>> diff --git a/configure b/configure
>>> index 59ff1e415d..2ca1fcf43f 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -7852,6 +7852,13 @@ fi
>>>  config_vars="$config_vars
>>>  enable-static-pie = $libc_cv_static_pie"
>>>
>>> +# Enable test-container by default.
>>> +if test "x$enable_test_container" = x; then
>>> +  enable_test_container=yes
>>> +fi
>>> +config_vars="$config_vars
>>> +enable-test-container = $enable_test_container"
>>> +
>>>  # Set the `multidir' variable by grabbing the variable from the compiler.
>>>  # We do it once and save the result in a generated makefile.
>>>  libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
>>> diff --git a/configure.ac b/configure.ac
>>> index 65799e5685..e1956b98cc 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -1740,6 +1740,12 @@ if test "$libc_cv_static_pie" = "yes"; then
>>>  fi
>>>  LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
>>>
>>> +# Enable test-container by default.
>>> +if test "x$enable_test_container" = x; then
>>> +  enable_test_container=yes
>>> +fi
>>> +LIBC_CONFIG_VAR([enable-test-container], [$enable_test_container])
>>> +
>>>  # Set the `multidir' variable by grabbing the variable from the compiler.
>>>  # We do it once and save the result in a generated makefile.
>>>  libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
>>> diff --git a/nss/Makefile b/nss/Makefile
>>> index 9331b3308c..ae083a9343 100644
>>> --- a/nss/Makefile
>>> +++ b/nss/Makefile
>>> @@ -434,9 +434,11 @@ extra-test-objs          += nss_test1.os nss_test2.os nss_test_errno.os \
>>>
>>>  ifeq ($(run-built-tests),yes)
>>>  ifneq (no,$(PERL))
>>> +ifeq (yes,$(enable-test-container))
>>>  tests-special += $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out
>>>  endif
>>>  endif
>>> +endif
>>>
>>>  generated += mtrace-tst-nss-gai-hv2-canonname.out \
>>>               tst-nss-gai-hv2-canonname.mtrace
>>> diff --git a/posix/Makefile b/posix/Makefile
>>> index a1e84853a8..d3a70ab6b4 100644
>>> --- a/posix/Makefile
>>> +++ b/posix/Makefile
>>> @@ -462,7 +462,6 @@ endif
>>>  tests-special += $(objpfx)annexc.out
>>>  ifeq ($(run-built-tests),yes)
>>>  tests-special += \
>>> -  $(objpfx)bug-ga2-mem.out \
>>>    $(objpfx)bug-glob2-mem.out \
>>>    $(objpfx)bug-regex14-mem.out \
>>>    $(objpfx)bug-regex2-mem.out \
>>> @@ -475,9 +474,14 @@ tests-special += \
>>>    $(objpfx)tst-glob-tilde-mem.out \
>>>    $(objpfx)tst-pcre-mem.out \
>>>    $(objpfx)tst-rxspencer-no-utf8-mem.out \
>>> +  # tests-special
>>> +ifeq (yes,$(enable-test-container))
>>> +tests-special += \
>>> +  $(objpfx)bug-ga2-mem.out \
>>>    $(objpfx)tst-vfork3-mem.out \
>>>    # tests-special
>>>  endif
>>> +endif
>>>
>>>  include ../Rules
>>>
>>> diff --git a/resolv/Makefile b/resolv/Makefile
>>> index 5f44f5896b..62c81fe998 100644
>>> --- a/resolv/Makefile
>>> +++ b/resolv/Makefile
>>> @@ -221,8 +221,15 @@ $(inst_libdir)/libnss_dns.so:
>>>
>>>  ifeq ($(run-built-tests),yes)
>>>  ifneq (no,$(PERL))
>>> -tests-special += $(objpfx)mtrace-tst-leaks.out $(objpfx)mtrace-tst-leaks2.out \
>>> -              $(objpfx)mtrace-tst-resolv-res_ninit.out
>>> +tests-special += \
>>> +  $(objpfx)mtrace-tst-leaks.out \
>>> +  $(objpfx)mtrace-tst-resolv-res_ninit.out \
>>> +# tests-special
>>> +ifeq (yes,$(enable-test-container))
>>> +tests-special += \
>>> +  $(objpfx)mtrace-tst-leaks2.out \
>>> +# tests-special
>>> +endif
>>>  endif
>>>  endif
>>>
> 
> 
>
H.J. Lu Feb. 5, 2024, 3:20 p.m. UTC | #5
On Mon, Feb 5, 2024 at 6:54 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 05/02/24 11:41, H.J. Lu wrote:
> > On Mon, Feb 5, 2024 at 5:55 AM Adhemerval Zanella Netto
> > <adhemerval.zanella@linaro.org> wrote:
> >>
> >>
> >>
> >> On 04/02/24 15:55, H.J. Lu wrote:
> >>> It can be difficult to run tests in container under simulator.  Add
> >>> --disable-test-container configure option to disable test container.
> >>> Container tests are enabled by default.
> >>
> >> Which is the failure that running under this simulator throw? Would be
> >> possible to detect it on test-container and fail with UNSUPPORTED instead?
> >
> > I am using
> >
> > $ make check test-wrapper=$(PWD)/test-sde.sh
> >
> > to test glibc compiled with Intel APX under APX emulator (SDE).  SDE
> > doesn't work with container.  SDE doesn't require any code changes.
> > I don't think we can detect it in container.  Also GDB and LD_PELOAD
> > tests don't work.  I don't know how to detect them either.
>
> Right, but what kind of error does the SDE emulator trigger with container

No error.  It just hangs forever.  The same applies to GDB and LD_PRELOAD
tests.

> tests? It is something similar to qemu-user where it emulates the syscall

SDE emulates syscalls.

> or is it running a underlying kernel like qemu-system?
>
> >
> >> I am not found on configure switch that disable testing, it seems just
> >> extra burden while adding test-container and this decrease test coverage
> >> when using this flag.
> >>
> >>> ---
> >>>  Makefile        |  2 ++
> >>>  Rules           |  5 +++++
> >>>  configure       |  7 +++++++
> >>>  configure.ac    |  6 ++++++
> >>>  nss/Makefile    |  2 ++
> >>>  posix/Makefile  |  6 +++++-
> >>>  resolv/Makefile | 11 +++++++++--
> >>>  7 files changed, 36 insertions(+), 3 deletions(-)
> >>>
> >>> diff --git a/Makefile b/Makefile
> >>> index 7052b46df8..2ba4a5ecd3 100644
> >>> --- a/Makefile
> >>> +++ b/Makefile
> >>> @@ -610,6 +610,7 @@ else
> >>>  LINKS_DSO_PROGRAM = links-dso-program
> >>>  endif
> >>>
> >>> +ifeq (yes,$(enable-test-container))
> >>>  $(tests-container) $(addsuffix /tests,$(subdirs)) : \
> >>>               $(objpfx)testroot.pristine/install.stamp
> >>>  $(objpfx)testroot.pristine/install.stamp :
> >>> @@ -655,6 +656,7 @@ endif
> >>>         INSTALL_UNCOMPRESSED=yes subdirs='$(sorted-subdirs)'
> >>>       rm -f $(symbolic-link-list)
> >>>       touch $(objpfx)testroot.pristine/install.stamp
> >>> +endif
> >>>
> >>>  tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special))
> >>>  tests: $(tests-special)
> >>> diff --git a/Rules b/Rules
> >>> index c7db0a4869..787024c729 100644
> >>> --- a/Rules
> >>> +++ b/Rules
> >>> @@ -142,6 +142,11 @@ endif
> >>>  # Generate constant files for Python pretty printers if required.
> >>>  others: $(py-const)
> >>>
> >>> +ifeq (no,$(enable-test-container))
> >>> +# Don't run any container tests with --disable-test-container.
> >>> +tests-container :=
> >>> +endif
> >>> +
> >>>  ifeq ($(run-built-tests),no)
> >>>  tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported), \
> >>>                                            $(tests) $(tests-internal) \
> >>> diff --git a/configure b/configure
> >>> index 59ff1e415d..2ca1fcf43f 100755
> >>> --- a/configure
> >>> +++ b/configure
> >>> @@ -7852,6 +7852,13 @@ fi
> >>>  config_vars="$config_vars
> >>>  enable-static-pie = $libc_cv_static_pie"
> >>>
> >>> +# Enable test-container by default.
> >>> +if test "x$enable_test_container" = x; then
> >>> +  enable_test_container=yes
> >>> +fi
> >>> +config_vars="$config_vars
> >>> +enable-test-container = $enable_test_container"
> >>> +
> >>>  # Set the `multidir' variable by grabbing the variable from the compiler.
> >>>  # We do it once and save the result in a generated makefile.
> >>>  libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
> >>> diff --git a/configure.ac b/configure.ac
> >>> index 65799e5685..e1956b98cc 100644
> >>> --- a/configure.ac
> >>> +++ b/configure.ac
> >>> @@ -1740,6 +1740,12 @@ if test "$libc_cv_static_pie" = "yes"; then
> >>>  fi
> >>>  LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
> >>>
> >>> +# Enable test-container by default.
> >>> +if test "x$enable_test_container" = x; then
> >>> +  enable_test_container=yes
> >>> +fi
> >>> +LIBC_CONFIG_VAR([enable-test-container], [$enable_test_container])
> >>> +
> >>>  # Set the `multidir' variable by grabbing the variable from the compiler.
> >>>  # We do it once and save the result in a generated makefile.
> >>>  libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
> >>> diff --git a/nss/Makefile b/nss/Makefile
> >>> index 9331b3308c..ae083a9343 100644
> >>> --- a/nss/Makefile
> >>> +++ b/nss/Makefile
> >>> @@ -434,9 +434,11 @@ extra-test-objs          += nss_test1.os nss_test2.os nss_test_errno.os \
> >>>
> >>>  ifeq ($(run-built-tests),yes)
> >>>  ifneq (no,$(PERL))
> >>> +ifeq (yes,$(enable-test-container))
> >>>  tests-special += $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out
> >>>  endif
> >>>  endif
> >>> +endif
> >>>
> >>>  generated += mtrace-tst-nss-gai-hv2-canonname.out \
> >>>               tst-nss-gai-hv2-canonname.mtrace
> >>> diff --git a/posix/Makefile b/posix/Makefile
> >>> index a1e84853a8..d3a70ab6b4 100644
> >>> --- a/posix/Makefile
> >>> +++ b/posix/Makefile
> >>> @@ -462,7 +462,6 @@ endif
> >>>  tests-special += $(objpfx)annexc.out
> >>>  ifeq ($(run-built-tests),yes)
> >>>  tests-special += \
> >>> -  $(objpfx)bug-ga2-mem.out \
> >>>    $(objpfx)bug-glob2-mem.out \
> >>>    $(objpfx)bug-regex14-mem.out \
> >>>    $(objpfx)bug-regex2-mem.out \
> >>> @@ -475,9 +474,14 @@ tests-special += \
> >>>    $(objpfx)tst-glob-tilde-mem.out \
> >>>    $(objpfx)tst-pcre-mem.out \
> >>>    $(objpfx)tst-rxspencer-no-utf8-mem.out \
> >>> +  # tests-special
> >>> +ifeq (yes,$(enable-test-container))
> >>> +tests-special += \
> >>> +  $(objpfx)bug-ga2-mem.out \
> >>>    $(objpfx)tst-vfork3-mem.out \
> >>>    # tests-special
> >>>  endif
> >>> +endif
> >>>
> >>>  include ../Rules
> >>>
> >>> diff --git a/resolv/Makefile b/resolv/Makefile
> >>> index 5f44f5896b..62c81fe998 100644
> >>> --- a/resolv/Makefile
> >>> +++ b/resolv/Makefile
> >>> @@ -221,8 +221,15 @@ $(inst_libdir)/libnss_dns.so:
> >>>
> >>>  ifeq ($(run-built-tests),yes)
> >>>  ifneq (no,$(PERL))
> >>> -tests-special += $(objpfx)mtrace-tst-leaks.out $(objpfx)mtrace-tst-leaks2.out \
> >>> -              $(objpfx)mtrace-tst-resolv-res_ninit.out
> >>> +tests-special += \
> >>> +  $(objpfx)mtrace-tst-leaks.out \
> >>> +  $(objpfx)mtrace-tst-resolv-res_ninit.out \
> >>> +# tests-special
> >>> +ifeq (yes,$(enable-test-container))
> >>> +tests-special += \
> >>> +  $(objpfx)mtrace-tst-leaks2.out \
> >>> +# tests-special
> >>> +endif
> >>>  endif
> >>>  endif
> >>>
> >
> >
> >
H.J. Lu Feb. 5, 2024, 3:22 p.m. UTC | #6
On Mon, Feb 5, 2024 at 6:46 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > It can be difficult to run tests in container under simulator.  Add
> > --disable-test-container configure option to disable test container.
> > Container tests are enabled by default.
>
> I think we should compile the test-in-container tests.  One way to get
> that might be to build support/test-container.c in such a way that it
> always  returns 77.

Make all test-wrapper unsupported?  Or add an emulator test-wrapper
option and make only emulator test-wrapper unsupported?
Florian Weimer Feb. 5, 2024, 3:34 p.m. UTC | #7
* H. J. Lu:

> On Mon, Feb 5, 2024 at 6:46 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > It can be difficult to run tests in container under simulator.  Add
>> > --disable-test-container configure option to disable test container.
>> > Container tests are enabled by default.
>>
>> I think we should compile the test-in-container tests.  One way to get
>> that might be to build support/test-container.c in such a way that it
>> always  returns 77.
>
> Make all test-wrapper unsupported?  Or add an emulator test-wrapper
> option and make only emulator test-wrapper unsupported?

I meant support/test-container.c specifically, not test-wrapper.

Thanks,
Florian
H.J. Lu Feb. 5, 2024, 3:38 p.m. UTC | #8
On Mon, Feb 5, 2024 at 7:34 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Mon, Feb 5, 2024 at 6:46 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu:
> >>
> >> > It can be difficult to run tests in container under simulator.  Add
> >> > --disable-test-container configure option to disable test container.
> >> > Container tests are enabled by default.
> >>
> >> I think we should compile the test-in-container tests.  One way to get
> >> that might be to build support/test-container.c in such a way that it
> >> always  returns 77.
> >
> > Make all test-wrapper unsupported?  Or add an emulator test-wrapper
> > option and make only emulator test-wrapper unsupported?
>
> I meant support/test-container.c specifically, not test-wrapper.
>

SDE is transparent to programs.  How does support/test-container.c
know that it is running under SDE?
Florian Weimer Feb. 5, 2024, 3:44 p.m. UTC | #9
* H. J. Lu:

> On Mon, Feb 5, 2024 at 7:34 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > On Mon, Feb 5, 2024 at 6:46 AM Florian Weimer <fweimer@redhat.com> wrote:
>> >>
>> >> * H. J. Lu:
>> >>
>> >> > It can be difficult to run tests in container under simulator.  Add
>> >> > --disable-test-container configure option to disable test container.
>> >> > Container tests are enabled by default.
>> >>
>> >> I think we should compile the test-in-container tests.  One way to get
>> >> that might be to build support/test-container.c in such a way that it
>> >> always  returns 77.
>> >
>> > Make all test-wrapper unsupported?  Or add an emulator test-wrapper
>> > option and make only emulator test-wrapper unsupported?
>>
>> I meant support/test-container.c specifically, not test-wrapper.
>>
>
> SDE is transparent to programs.  How does support/test-container.c
> know that it is running under SDE?

Sorry, I was trying to suggest this as a way to implement
--disable-test-container.

Thanks,
Florian
Andreas Schwab Feb. 5, 2024, 3:48 p.m. UTC | #10
On Feb 05 2024, H.J. Lu wrote:

> SDE is transparent to programs.  How does support/test-container.c
> know that it is running under SDE?

With qemu linux-user I get an error like this:

    error: test-container.c:1116: unable to unshare user/fs: Invalid argument

and the test is marked unsupported.
H.J. Lu Feb. 5, 2024, 3:50 p.m. UTC | #11
On Mon, Feb 5, 2024 at 7:48 AM Andreas Schwab <schwab@suse.de> wrote:
>
> On Feb 05 2024, H.J. Lu wrote:
>
> > SDE is transparent to programs.  How does support/test-container.c
> > know that it is running under SDE?
>
> With qemu linux-user I get an error like this:
>
>     error: test-container.c:1116: unable to unshare user/fs: Invalid argument
>
> and the test is marked unsupported.
>
>

SDE is more transparent.  You can run almost all programs unmodified.
test-container.c doesn't fail that way under SDE.
Adhemerval Zanella Netto Feb. 5, 2024, 3:51 p.m. UTC | #12
On 05/02/24 12:48, Andreas Schwab wrote:
> On Feb 05 2024, H.J. Lu wrote:
> 
>> SDE is transparent to programs.  How does support/test-container.c
>> know that it is running under SDE?
> 
> With qemu linux-user I get an error like this:
> 
>     error: test-container.c:1116: unable to unshare user/fs: Invalid argument
> 
> and the test is marked unsupported.
> 

And the forever hanging leads to believe this is an issue with SDE emulator
and I don't think we should add a configure switch to paper this over.
H.J. Lu Feb. 5, 2024, 3:51 p.m. UTC | #13
On Mon, Feb 5, 2024 at 7:44 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Mon, Feb 5, 2024 at 7:34 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu:
> >>
> >> > On Mon, Feb 5, 2024 at 6:46 AM Florian Weimer <fweimer@redhat.com> wrote:
> >> >>
> >> >> * H. J. Lu:
> >> >>
> >> >> > It can be difficult to run tests in container under simulator.  Add
> >> >> > --disable-test-container configure option to disable test container.
> >> >> > Container tests are enabled by default.
> >> >>
> >> >> I think we should compile the test-in-container tests.  One way to get
> >> >> that might be to build support/test-container.c in such a way that it
> >> >> always  returns 77.
> >> >
> >> > Make all test-wrapper unsupported?  Or add an emulator test-wrapper
> >> > option and make only emulator test-wrapper unsupported?
> >>
> >> I meant support/test-container.c specifically, not test-wrapper.
> >>
> >
> > SDE is transparent to programs.  How does support/test-container.c
> > know that it is running under SDE?
>
> Sorry, I was trying to suggest this as a way to implement
> --disable-test-container.

I can do that.  What should we do with GDB tests?
Florian Weimer Feb. 5, 2024, 3:55 p.m. UTC | #14
* Adhemerval Zanella Netto:

> On 05/02/24 12:48, Andreas Schwab wrote:
>> On Feb 05 2024, H.J. Lu wrote:
>> 
>>> SDE is transparent to programs.  How does support/test-container.c
>>> know that it is running under SDE?
>> 
>> With qemu linux-user I get an error like this:
>> 
>>     error: test-container.c:1116: unable to unshare user/fs: Invalid argument
>> 
>> and the test is marked unsupported.
>> 
>
> And the forever hanging leads to believe this is an issue with SDE emulator
> and I don't think we should add a configure switch to paper this over.

That's also a good point.  Hopefully this can be fixed in SDE.

Thanks,
Florian
Andreas Schwab Feb. 5, 2024, 3:57 p.m. UTC | #15
On Feb 05 2024, H.J. Lu wrote:

> SDE is more transparent.  You can run almost all programs unmodified.

Like qemu linux-user.

> test-container.c doesn't fail that way under SDE.

Then how does it fail?  Perhaps test-container is missing an error
check, or the simulator is too lenient to let some unsupported
operations through.
H.J. Lu Feb. 5, 2024, 4:19 p.m. UTC | #16
On Mon, Feb 5, 2024 at 7:57 AM Andreas Schwab <schwab@suse.de> wrote:
>
> On Feb 05 2024, H.J. Lu wrote:
>
> > SDE is more transparent.  You can run almost all programs unmodified.
>
> Like qemu linux-user.

I am not familiar with qemu linux-user.  SDE can run most native programs
which are linked with host libraries.

> > test-container.c doesn't fail that way under SDE.
>
> Then how does it fail?  Perhaps test-container is missing an error
> check, or the simulator is too lenient to let some unsupported
> operations through.
>

This seems to be an SDE issue.  I will keep workarounds on my
personal branch.

Thanks.
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 7052b46df8..2ba4a5ecd3 100644
--- a/Makefile
+++ b/Makefile
@@ -610,6 +610,7 @@  else
 LINKS_DSO_PROGRAM = links-dso-program
 endif
 
+ifeq (yes,$(enable-test-container))
 $(tests-container) $(addsuffix /tests,$(subdirs)) : \
 		$(objpfx)testroot.pristine/install.stamp
 $(objpfx)testroot.pristine/install.stamp :
@@ -655,6 +656,7 @@  endif
 	  INSTALL_UNCOMPRESSED=yes subdirs='$(sorted-subdirs)'
 	rm -f $(symbolic-link-list)
 	touch $(objpfx)testroot.pristine/install.stamp
+endif
 
 tests-special-notdir = $(patsubst $(objpfx)%, %, $(tests-special))
 tests: $(tests-special)
diff --git a/Rules b/Rules
index c7db0a4869..787024c729 100644
--- a/Rules
+++ b/Rules
@@ -142,6 +142,11 @@  endif
 # Generate constant files for Python pretty printers if required.
 others: $(py-const)
 
+ifeq (no,$(enable-test-container))
+# Don't run any container tests with --disable-test-container.
+tests-container :=
+endif
+
 ifeq ($(run-built-tests),no)
 tests: $(addprefix $(objpfx),$(filter-out $(tests-unsupported), \
                                           $(tests) $(tests-internal) \
diff --git a/configure b/configure
index 59ff1e415d..2ca1fcf43f 100755
--- a/configure
+++ b/configure
@@ -7852,6 +7852,13 @@  fi
 config_vars="$config_vars
 enable-static-pie = $libc_cv_static_pie"
 
+# Enable test-container by default.
+if test "x$enable_test_container" = x; then
+  enable_test_container=yes
+fi
+config_vars="$config_vars
+enable-test-container = $enable_test_container"
+
 # Set the `multidir' variable by grabbing the variable from the compiler.
 # We do it once and save the result in a generated makefile.
 libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
diff --git a/configure.ac b/configure.ac
index 65799e5685..e1956b98cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1740,6 +1740,12 @@  if test "$libc_cv_static_pie" = "yes"; then
 fi
 LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
 
+# Enable test-container by default.
+if test "x$enable_test_container" = x; then
+  enable_test_container=yes
+fi
+LIBC_CONFIG_VAR([enable-test-container], [$enable_test_container])
+
 # Set the `multidir' variable by grabbing the variable from the compiler.
 # We do it once and save the result in a generated makefile.
 libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
diff --git a/nss/Makefile b/nss/Makefile
index 9331b3308c..ae083a9343 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -434,9 +434,11 @@  extra-test-objs		+= nss_test1.os nss_test2.os nss_test_errno.os \
 
 ifeq ($(run-built-tests),yes)
 ifneq (no,$(PERL))
+ifeq (yes,$(enable-test-container))
 tests-special += $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out
 endif
 endif
+endif
 
 generated += mtrace-tst-nss-gai-hv2-canonname.out \
 		tst-nss-gai-hv2-canonname.mtrace
diff --git a/posix/Makefile b/posix/Makefile
index a1e84853a8..d3a70ab6b4 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -462,7 +462,6 @@  endif
 tests-special += $(objpfx)annexc.out
 ifeq ($(run-built-tests),yes)
 tests-special += \
-  $(objpfx)bug-ga2-mem.out \
   $(objpfx)bug-glob2-mem.out \
   $(objpfx)bug-regex14-mem.out \
   $(objpfx)bug-regex2-mem.out \
@@ -475,9 +474,14 @@  tests-special += \
   $(objpfx)tst-glob-tilde-mem.out \
   $(objpfx)tst-pcre-mem.out \
   $(objpfx)tst-rxspencer-no-utf8-mem.out \
+  # tests-special
+ifeq (yes,$(enable-test-container))
+tests-special += \
+  $(objpfx)bug-ga2-mem.out \
   $(objpfx)tst-vfork3-mem.out \
   # tests-special
 endif
+endif
 
 include ../Rules
 
diff --git a/resolv/Makefile b/resolv/Makefile
index 5f44f5896b..62c81fe998 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -221,8 +221,15 @@  $(inst_libdir)/libnss_dns.so:
 
 ifeq ($(run-built-tests),yes)
 ifneq (no,$(PERL))
-tests-special += $(objpfx)mtrace-tst-leaks.out $(objpfx)mtrace-tst-leaks2.out \
-		 $(objpfx)mtrace-tst-resolv-res_ninit.out
+tests-special += \
+  $(objpfx)mtrace-tst-leaks.out \
+  $(objpfx)mtrace-tst-resolv-res_ninit.out \
+# tests-special
+ifeq (yes,$(enable-test-container))
+tests-special += \
+  $(objpfx)mtrace-tst-leaks2.out \
+# tests-special
+endif
 endif
 endif