diff mbox series

meson: add tests option

Message ID 20210226220715.3103110-1-romain.naour@gmail.com (mailing list archive)
State New, archived
Headers show
Series meson: add tests option | expand

Commit Message

Romain Naour Feb. 26, 2021, 10:07 p.m. UTC
tests/fp/fp-bench.c use fenv.h that is not always provided
by the libc (uClibc).

To workaround this issue, add an new meson option to
disable tests while building Qemu.

Fixes:
http://autobuild.buildroot.net/results/53f5d8baa994d599b9da013ee643b82353366ec3/build-end.log

Signed-off-by: Romain Naour <romain.naour@gmail.com>
---
 configure         | 7 +++++++
 meson.build       | 6 +++++-
 meson_options.txt | 3 +++
 3 files changed, 15 insertions(+), 1 deletion(-)

Comments

Thomas Huth March 2, 2021, 10:22 a.m. UTC | #1
On 26/02/2021 23.07, Romain Naour wrote:
> tests/fp/fp-bench.c use fenv.h that is not always provided
> by the libc (uClibc).

For such  problem it might be better to check for the availability of the 
header and then to only disable the single test that depends on it if the 
header is not available.

Anyway, a switch to disable the tests completely could still be handy in 
some cases, so FWIW:

Acked-by: Thomas Huth <thuth@redhat.com>

> To workaround this issue, add an new meson option to
> disable tests while building Qemu.
> 
> Fixes:
> http://autobuild.buildroot.net/results/53f5d8baa994d599b9da013ee643b82353366ec3/build-end.log
> 
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> ---
>   configure         | 7 +++++++
>   meson.build       | 6 +++++-
>   meson_options.txt | 3 +++
>   3 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index a79b3746d4..cd114f4b9e 100755
> --- a/configure
> +++ b/configure
> @@ -464,6 +464,7 @@ gettext="auto"
>   fuse="auto"
>   fuse_lseek="auto"
>   multiprocess="no"
> +tests="auto"
>   
>   malloc_trim="auto"
>   
> @@ -1562,6 +1563,10 @@ for opt do
>     ;;
>     --disable-multiprocess) multiprocess="no"
>     ;;
> +  --disable-tests) tests="disabled"
> +  ;;
> +  --enable-tests) tests="enabled"
> +  ;;
>     *)
>         echo "ERROR: unknown option $opt"
>         echo "Try '$0 --help' for more information"
> @@ -1915,6 +1920,7 @@ disabled with --disable-FEATURE, default is enabled if available
>     fuse            FUSE block device export
>     fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
>     multiprocess    Multiprocess QEMU support
> +  tests           build tests
>   
>   NOTE: The object files are built at the place where configure is launched
>   EOF
> @@ -6428,6 +6434,7 @@ NINJA=$ninja $meson setup \
>           -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi \
>           $(if test "$default_features" = no; then echo "-Dauto_features=disabled"; fi) \
>   	-Dtcg_interpreter=$tcg_interpreter \
> +        -Dtests=$tests \
>           $cross_arg \
>           "$PWD" "$source_path"
>   
> diff --git a/meson.build b/meson.build
> index 05a67c20d9..2d7cbc0fbd 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2341,7 +2341,11 @@ subdir('scripts')
>   subdir('tools')
>   subdir('pc-bios')
>   subdir('docs')
> -subdir('tests')
> +
> +if get_option('tests').enabled()
> +  subdir('tests')
> +endif
> +
>   if gtk.found()
>     subdir('po')
>   endif
> diff --git a/meson_options.txt b/meson_options.txt
> index 675a9c500a..be30ad5450 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -114,6 +114,9 @@ option('virtfs', type: 'feature', value: 'auto',
>   option('virtiofsd', type: 'feature', value: 'auto',
>          description: 'build virtiofs daemon (virtiofsd)')
>   
> +option('tests', type : 'feature', value : 'auto',
> +       description: 'Tests build support')
> +
>   option('capstone', type: 'combo', value: 'auto',
>          choices: ['disabled', 'enabled', 'auto', 'system', 'internal'],
>          description: 'Whether and how to find the capstone library')
>
Paolo Bonzini March 2, 2021, 11:08 a.m. UTC | #2
On 02/03/21 11:22, Thomas Huth wrote:
> On 26/02/2021 23.07, Romain Naour wrote:
>> tests/fp/fp-bench.c use fenv.h that is not always provided
>> by the libc (uClibc).
> 
> For such  problem it might be better to check for the availability of 
> the header and then to only disable the single test that depends on it 
> if the header is not available.
> 
> Anyway, a switch to disable the tests completely could still be handy in 
> some cases, so FWIW:
> 
> Acked-by: Thomas Huth <thuth@redhat.com>

I disagree, without a use case the right thing to do is to check for 
fenv.h.  It's as easy as this:

diff --git a/tests/meson.build b/tests/meson.build
index 0c939f89f7..3b9b2f0483 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -281,7 +281,7 @@ test('decodetree', sh,
       workdir: meson.current_source_dir() / 'decode',
       suite: 'decodetree')

-if 'CONFIG_TCG' in config_all
+if 'CONFIG_TCG' in config_all and cc.has_header('fenv.h')
    subdir('fp')
  endif

Thanks,

Paolo
Romain Naour March 2, 2021, 9:14 p.m. UTC | #3
Hello,

Le 02/03/2021 à 12:08, Paolo Bonzini a écrit :
> On 02/03/21 11:22, Thomas Huth wrote:
>> On 26/02/2021 23.07, Romain Naour wrote:
>>> tests/fp/fp-bench.c use fenv.h that is not always provided
>>> by the libc (uClibc).
>>
>> For such  problem it might be better to check for the availability of the
>> header and then to only disable the single test that depends on it if the
>> header is not available.

You're right, I thought about adding a header check but I noticed that was no
option to disable all tests. Buildroot try to avoid as much as possible building
tests program.

>>
>> Anyway, a switch to disable the tests completely could still be handy in some
>> cases, so FWIW:

It can save some build time:

qemu build with tests disabled
real	3m27,310s
user	19m56,887s
sys	2m1,738s

qemu build with tests enabled
real	4m0,638s
user	23m34,963s
sys	2m32,944s


>>
>> Acked-by: Thomas Huth <thuth@redhat.com>
> 
> I disagree, without a use case the right thing to do is to check for fenv.h. 
> It's as easy as this:

Is it ok if I take your patch to disable fp tests when fenv.h is missing and
resend my patch with an updated commit log to disable all tests to save some
build time?

Best regards,
Romain

> 
> diff --git a/tests/meson.build b/tests/meson.build
> index 0c939f89f7..3b9b2f0483 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -281,7 +281,7 @@ test('decodetree', sh,
>       workdir: meson.current_source_dir() / 'decode',
>       suite: 'decodetree')
> 
> -if 'CONFIG_TCG' in config_all
> +if 'CONFIG_TCG' in config_all and cc.has_header('fenv.h')
>    subdir('fp')
>  endif
> 
> Thanks,
> 
> Paolo
>
Paolo Bonzini March 3, 2021, 12:22 p.m. UTC | #4
On 02/03/21 22:14, Romain Naour wrote:
>> I disagree, without a use case the right thing to do is to check for fenv.h.
>> It's as easy as this:
> Is it ok if I take your patch to disable fp tests when fenv.h is missing and
> resend my patch with an updated commit log to disable all tests to save some
> build time?

To save build time you could also mark the tests as "build_by_default: 
false".  They should be built lazily when you run "make check".

Paolo
diff mbox series

Patch

diff --git a/configure b/configure
index a79b3746d4..cd114f4b9e 100755
--- a/configure
+++ b/configure
@@ -464,6 +464,7 @@  gettext="auto"
 fuse="auto"
 fuse_lseek="auto"
 multiprocess="no"
+tests="auto"
 
 malloc_trim="auto"
 
@@ -1562,6 +1563,10 @@  for opt do
   ;;
   --disable-multiprocess) multiprocess="no"
   ;;
+  --disable-tests) tests="disabled"
+  ;;
+  --enable-tests) tests="enabled"
+  ;;
   *)
       echo "ERROR: unknown option $opt"
       echo "Try '$0 --help' for more information"
@@ -1915,6 +1920,7 @@  disabled with --disable-FEATURE, default is enabled if available
   fuse            FUSE block device export
   fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
   multiprocess    Multiprocess QEMU support
+  tests           build tests
 
 NOTE: The object files are built at the place where configure is launched
 EOF
@@ -6428,6 +6434,7 @@  NINJA=$ninja $meson setup \
         -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi \
         $(if test "$default_features" = no; then echo "-Dauto_features=disabled"; fi) \
 	-Dtcg_interpreter=$tcg_interpreter \
+        -Dtests=$tests \
         $cross_arg \
         "$PWD" "$source_path"
 
diff --git a/meson.build b/meson.build
index 05a67c20d9..2d7cbc0fbd 100644
--- a/meson.build
+++ b/meson.build
@@ -2341,7 +2341,11 @@  subdir('scripts')
 subdir('tools')
 subdir('pc-bios')
 subdir('docs')
-subdir('tests')
+
+if get_option('tests').enabled()
+  subdir('tests')
+endif
+
 if gtk.found()
   subdir('po')
 endif
diff --git a/meson_options.txt b/meson_options.txt
index 675a9c500a..be30ad5450 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -114,6 +114,9 @@  option('virtfs', type: 'feature', value: 'auto',
 option('virtiofsd', type: 'feature', value: 'auto',
        description: 'build virtiofs daemon (virtiofsd)')
 
+option('tests', type : 'feature', value : 'auto',
+       description: 'Tests build support')
+
 option('capstone', type: 'combo', value: 'auto',
        choices: ['disabled', 'enabled', 'auto', 'system', 'internal'],
        description: 'Whether and how to find the capstone library')