From 38db5eff344dcc97739be2ee4696f02eae1555dd Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 2 May 2024 20:21:29 +0200 Subject: [PATCH] test: Only set environment variable if integration tests are enabled. If we set it to '0' if integration tests are not enabled then we can't enable them from the command line since environment from meson takes priority over environment variables from the command line. We also rename the related variables to avoid conflicts with the existing integration_tests variable. --- meson.build | 16 ++++++++-------- src/test/meson.build | 3 +-- test/meson.build | 8 +++++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 0b27285da0..63c358194d 100644 --- a/meson.build +++ b/meson.build @@ -319,9 +319,9 @@ userspace_c_ld_args = [] meson_build_sh = find_program('tools/meson-build.sh') want_tests = get_option('tests') -slow_tests = want_tests != 'false' and get_option('slow-tests') -fuzz_tests = want_tests != 'false' and get_option('fuzz-tests') -integration_tests = want_tests != 'false' and get_option('integration-tests') +want_slow_tests = want_tests != 'false' and get_option('slow-tests') +want_fuzz_tests = want_tests != 'false' and get_option('fuzz-tests') +want_integration_tests = want_tests != 'false' and get_option('integration-tests') install_tests = want_tests != 'false' and get_option('install-tests') if add_languages('cpp', native : false, required : fuzzer_build) @@ -1684,7 +1684,7 @@ conf.set10('ENABLE_TIMEDATECTL', get_option('timedated') or get_option('timesync conf.set10('ENABLE_SSH_PROXY_CONFIG', sshconfdir != 'no') conf.set10('ENABLE_SSH_USERDB_CONFIG', conf.get('ENABLE_USERDB') == 1 and sshdconfdir != 'no') -conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests) +conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', want_slow_tests) ##################################################################### @@ -2594,7 +2594,7 @@ endif ##################################################################### mkosi = find_program('mkosi', required : false) -if integration_tests and not mkosi.found() +if want_integration_tests and not mkosi.found() error('Could not find mkosi which is required to run the integration tests') endif @@ -2729,7 +2729,7 @@ foreach tuple : fuzz_sanitizers message('Not compiling @0@ because tests is set to false'.format(name)) continue endif - if not fuzz_tests + if not want_fuzz_tests message('Not compiling @0@ because fuzz-tests is set to false'.format(name)) continue endif @@ -3028,8 +3028,8 @@ foreach tuple : [ ['debug mmap cache'], ['debug siphash'], ['trace logging', conf.get('LOG_TRACE') == 1], - ['slow tests', slow_tests], - ['fuzz tests', fuzz_tests], + ['slow tests', want_slow_tests], + ['fuzz tests', want_fuzz_tests], ['install tests', install_tests], ['link-udev-shared', get_option('link-udev-shared')], ['link-systemctl-shared', get_option('link-systemctl-shared')], diff --git a/src/test/meson.build b/src/test/meson.build index a452021f62..3abbb94d9f 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -14,8 +14,7 @@ test_env = environment() test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map) test_env.set('PATH', project_build_root + ':' + path) test_env.set('PROJECT_BUILD_ROOT', project_build_root) -test_env.set('SYSTEMD_SLOW_TESTS', slow_tests ? '1' : '0') -test_env.set('SYSTEMD_INTEGRATION_TESTS', integration_tests ? '1' : '0') +test_env.set('SYSTEMD_SLOW_TESTS', want_slow_tests ? '1' : '0') if efi_addon != '' test_env.set('EFI_ADDON', efi_addon) diff --git a/test/meson.build b/test/meson.build index c4f4057e59..f93137c07a 100644 --- a/test/meson.build +++ b/test/meson.build @@ -431,12 +431,18 @@ foreach test_number, dirname : integration_tests '--', ] + test_params['mkosi_args'] + integration_test_env = {} + + if want_integration_tests + integration_test_env = {'SYSTEMD_INTEGRATION_TESTS': '1'} + endif + # We don't explicitly depend on the "mkosi" target because that means the image is rebuilt # on every "ninja -C build". Instead, the mkosi target has to be rebuilt manually before # running the integration tests with mkosi. test(dirname, integration_test_wrapper, - env : test_env, + env : integration_test_env, args : args, timeout : test_params['timeout'], suite : 'integration-tests')