diff --git a/src/test/meson.build b/src/test/meson.build index 69b2b1e587..a452021f62 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -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) diff --git a/test/README.testsuite b/test/README.testsuite index 7dcb602e84..91cafeb58e 100644 --- a/test/README.testsuite +++ b/test/README.testsuite @@ -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. diff --git a/test/integration-test-wrapper.py b/test/integration-test-wrapper.py index f3c7fe5b85..4465576c5b 100755 --- a/test/integration-test-wrapper.py +++ b/test/integration-test-wrapper.py @@ -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) diff --git a/test/meson.build b/test/meson.build index 8e0d11682e..bd25e94276 100644 --- a/test/meson.build +++ b/test/meson.build @@ -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') +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, + } + + # 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 - 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, - } + 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'] - # 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 + # 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