]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: Skip meson integration tests if SYSTEMD_INTEGRATION_TESTS != 1
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 24 Apr 2024 19:18:27 +0000 (21:18 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 25 Apr 2024 15:06:40 +0000 (17:06 +0200)
We cannot mark a test suite as excluded by default in meson. Instead,
let's require that SYSTEMD_INTEGRATION_TESTS=1 and skip any integration
test if it's not set. This is effectively the same as excluding it by
default. If the integration-test option is enabled, we'll set the
environment variable by default, just like we do with SYSTEMD_SLOW_TESTS
and the slow-tests meson option.

src/test/meson.build
test/README.testsuite
test/integration-test-wrapper.py
test/meson.build

index 69b2b1e5878a2a221e12a3435530abb5046ed3d2..a452021f626c0710f6fc2fa6f3f077ed1f47f8ef 100644 (file)
@@ -15,6 +15,7 @@ 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')
 
 if efi_addon != ''
         test_env.set('EFI_ADDON', efi_addon)
index 7dcb602e84f6d7f98c35ba79ce005805e5f5563c..91cafeb58e0f60a7ec6d21a1f2ab704266613701 100644 (file)
@@ -31,7 +31,7 @@ $ sudo make -C test/TEST-01-BASIC clean setup run
 To run the meson-based integration test config
 enable integration tests and options for required commands with the following:
 
-$ meson configure build -Dintegration-tests=true -Dremote=enabled -Dopenssl=enabled -Dblkid=enabled -Dtpm2=enabled
+$ meson configure build -Dremote=enabled -Dopenssl=enabled -Dblkid=enabled -Dtpm2=enabled
 
 Once enabled, first build the integration test image:
 
@@ -39,18 +39,18 @@ $ meson compile -C build mkosi
 
 After the image has been built, the integration tests can be run with:
 
-$ meson test -C build/ --suite integration-tests --num-processes "$(($(nproc) / 2))"
+$ SYSTEMD_INTEGRATION_TESTS=1 meson test -C build/ --suite integration-tests --num-processes "$(($(nproc) / 2))"
 
 As usual, specific tests can be run in meson by appending the name of the test
 which is usually the name of the directory e.g.
 
-$ meson test -C build/ -v TEST-01-BASIC
+$ SYSTEMD_INTEGRATION_TESTS=1 meson test -C build/ -v TEST-01-BASIC
 
 Due to limitations in meson, the integration tests do not yet depend on the mkosi target, which means the
 mkosi target has to be manually rebuilt before running the integration tests. To rebuild the image and rerun
 a test, the following command can be used:
 
-$ meson compile -C build mkosi && meson test -C build -v TEST-01-BASIC
+$ meson compile -C build mkosi && SYSTEMD_INTEGRATION_TESTS=1 meson test -C build -v TEST-01-BASIC
 
 See `meson introspect build --tests` for a list of tests.
 
index f3c7fe5b85572f277de9e30e522af54c1991a675..4465576c5bc3cda112fa7f8a963608cdbb9a1f58 100755 (executable)
@@ -38,6 +38,10 @@ ExecStart=false
 
 
 def main():
+    if not bool(int(os.getenv("SYSTEMD_INTEGRATION_TESTS", "0"))):
+        print("SYSTEMD_INTEGRATION_TESTS=1 not found in environment, skipping", file=sys.stderr)
+        exit(77)
+
     parser = argparse.ArgumentParser(description=__doc__)
     parser.add_argument('--meson-source-dir', required=True, type=Path)
     parser.add_argument('--meson-build-dir', required=True, type=Path)
index 8e0d11682ecd3bd82fd00bea2380300ee9b9b8fc..bd25e94276c9200d077c49a9c82f65bbd405e359 100644 (file)
@@ -334,45 +334,39 @@ endif
 
 ############################################################
 
-if get_option('integration-tests')
-        if not mkosi.found()
-                error('Could not find mkosi which is required to run the integration tests')
-        endif
-
-        integration_test_wrapper = find_program('integration-test-wrapper.py')
-        integration_tests = {
-                '01': 'TEST-01-BASIC',
-                '02': 'TEST-02-UNITTESTS',
+integration_test_wrapper = find_program('integration-test-wrapper.py')
+integration_tests = {
+        '01': 'TEST-01-BASIC',
+        '02': 'TEST-02-UNITTESTS',
+}
+foreach test_number, dirname : integration_tests
+        test_params = {
+                'mkosi_args' : [],
+                'timeout' : 600,
         }
-        foreach test_number, dirname : integration_tests
-                test_params = {
-                        'mkosi_args' : [],
-                        'timeout' : 600,
-                }
-
-                # TODO: This fs.exists call isn't included in rebuild logic
-                # so if you add a new meson.build in a subdir
-                # you need to touch another build file to get it to reparse.
-                if fs.exists(dirname / 'meson.build')
-                        subdir(dirname)
-                endif
 
-                args = [
-                        '--meson-source-dir', meson.project_source_root(),
-                        '--meson-build-dir', meson.project_build_root(),
-                        '--test-name', dirname,
-                        '--test-number', test_number,
-                        '--',
-                ] + test_params['mkosi_args']
-
-                # 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,
-                     args : args,
-                     timeout : test_params['timeout'],
-                     suite : 'integration-tests')
-        endforeach
-endif
+        # TODO: This fs.exists call isn't included in rebuild logic
+        # so if you add a new meson.build in a subdir
+        # you need to touch another build file to get it to reparse.
+        if fs.exists(dirname / 'meson.build')
+                subdir(dirname)
+        endif
+
+        args = [
+                '--meson-source-dir', meson.project_source_root(),
+                '--meson-build-dir', meson.project_build_root(),
+                '--test-name', dirname,
+                '--test-number', test_number,
+                '--',
+        ] + test_params['mkosi_args']
+
+        # 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,
+                args : args,
+                timeout : test_params['timeout'],
+                suite : 'integration-tests')
+endforeach