]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: Only set environment variable if integration tests are enabled.
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 2 May 2024 18:21:29 +0000 (20:21 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 6 May 2024 08:56:54 +0000 (10:56 +0200)
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
src/test/meson.build
test/meson.build

index 0b27285da03241e5413e3056e5f73fd4cb72761b..63c358194d82a4812d3777bd826058379d75ef2c 100644 (file)
@@ -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')],
index a452021f626c0710f6fc2fa6f3f077ed1f47f8ef..3abbb94d9fb4877e6c86b09caa623e909780af18 100644 (file)
@@ -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)
index c4f4057e5949cb43d02e690d4c071283b2a1c9aa..f93137c07a1a2ec6fedcd1005c3579278a4d5331 100644 (file)
@@ -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')