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:
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.
############################################################
-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