Skip to content

Commit cf5e1b5

Browse files
committed
test: Skip meson integration tests if SYSTEMD_INTEGRATION_TESTS != 1
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.
1 parent ff4fe9d commit cf5e1b5

File tree

4 files changed

+43
-44
lines changed

4 files changed

+43
-44
lines changed

src/test/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map)
1515
test_env.set('PATH', project_build_root + ':' + path)
1616
test_env.set('PROJECT_BUILD_ROOT', project_build_root)
1717
test_env.set('SYSTEMD_SLOW_TESTS', slow_tests ? '1' : '0')
18+
test_env.set('SYSTEMD_INTEGRATION_TESTS', integration_tests ? '1' : '0')
1819

1920
if efi_addon != ''
2021
test_env.set('EFI_ADDON', efi_addon)

test/README.testsuite

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,26 @@ $ sudo make -C test/TEST-01-BASIC clean setup run
3131
To run the meson-based integration test config
3232
enable integration tests and options for required commands with the following:
3333

34-
$ meson configure build -Dintegration-tests=true -Dremote=enabled -Dopenssl=enabled -Dblkid=enabled -Dtpm2=enabled
34+
$ meson configure build -Dremote=enabled -Dopenssl=enabled -Dblkid=enabled -Dtpm2=enabled
3535

3636
Once enabled, first build the integration test image:
3737

3838
$ meson compile -C build mkosi
3939

4040
After the image has been built, the integration tests can be run with:
4141

42-
$ meson test -C build/ --suite integration-tests --num-processes "$(($(nproc) / 2))"
42+
$ SYSTEMD_INTEGRATION_TESTS=1 meson test -C build/ --suite integration-tests --num-processes "$(($(nproc) / 2))"
4343

4444
As usual, specific tests can be run in meson by appending the name of the test
4545
which is usually the name of the directory e.g.
4646

47-
$ meson test -C build/ -v TEST-01-BASIC
47+
$ SYSTEMD_INTEGRATION_TESTS=1 meson test -C build/ -v TEST-01-BASIC
4848

4949
Due to limitations in meson, the integration tests do not yet depend on the mkosi target, which means the
5050
mkosi target has to be manually rebuilt before running the integration tests. To rebuild the image and rerun
5151
a test, the following command can be used:
5252

53-
$ meson compile -C build mkosi && meson test -C build -v TEST-01-BASIC
53+
$ meson compile -C build mkosi && SYSTEMD_INTEGRATION_TESTS=1 meson test -C build -v TEST-01-BASIC
5454

5555
See `meson introspect build --tests` for a list of tests.
5656

test/integration-test-wrapper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838

3939

4040
def main():
41+
if not bool(int(os.getenv("SYSTEMD_INTEGRATION_TESTS", "0"))):
42+
print("SYSTEMD_INTEGRATION_TESTS=1 not found in environment, skipping", file=sys.stderr)
43+
exit(77)
44+
4145
parser = argparse.ArgumentParser(description=__doc__)
4246
parser.add_argument('--meson-source-dir', required=True, type=Path)
4347
parser.add_argument('--meson-build-dir', required=True, type=Path)

test/meson.build

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -334,45 +334,39 @@ endif
334334

335335
############################################################
336336

337-
if get_option('integration-tests')
338-
if not mkosi.found()
339-
error('Could not find mkosi which is required to run the integration tests')
340-
endif
341-
342-
integration_test_wrapper = find_program('integration-test-wrapper.py')
343-
integration_tests = {
344-
'01': 'TEST-01-BASIC',
345-
'02': 'TEST-02-UNITTESTS',
337+
integration_test_wrapper = find_program('integration-test-wrapper.py')
338+
integration_tests = {
339+
'01': 'TEST-01-BASIC',
340+
'02': 'TEST-02-UNITTESTS',
341+
}
342+
foreach test_number, dirname : integration_tests
343+
test_params = {
344+
'mkosi_args' : [],
345+
'timeout' : 600,
346346
}
347-
foreach test_number, dirname : integration_tests
348-
test_params = {
349-
'mkosi_args' : [],
350-
'timeout' : 600,
351-
}
352-
353-
# TODO: This fs.exists call isn't included in rebuild logic
354-
# so if you add a new meson.build in a subdir
355-
# you need to touch another build file to get it to reparse.
356-
if fs.exists(dirname / 'meson.build')
357-
subdir(dirname)
358-
endif
359347

360-
args = [
361-
'--meson-source-dir', meson.project_source_root(),
362-
'--meson-build-dir', meson.project_build_root(),
363-
'--test-name', dirname,
364-
'--test-number', test_number,
365-
'--',
366-
] + test_params['mkosi_args']
367-
368-
# We don't explicitly depend on the "mkosi" target because that means the image is rebuilt
369-
# on every "ninja -C build". Instead, the mkosi target has to be rebuilt manually before
370-
# running the integration tests with mkosi.
371-
test(dirname,
372-
integration_test_wrapper,
373-
env: test_env,
374-
args : args,
375-
timeout : test_params['timeout'],
376-
suite : 'integration-tests')
377-
endforeach
378-
endif
348+
# TODO: This fs.exists call isn't included in rebuild logic
349+
# so if you add a new meson.build in a subdir
350+
# you need to touch another build file to get it to reparse.
351+
if fs.exists(dirname / 'meson.build')
352+
subdir(dirname)
353+
endif
354+
355+
args = [
356+
'--meson-source-dir', meson.project_source_root(),
357+
'--meson-build-dir', meson.project_build_root(),
358+
'--test-name', dirname,
359+
'--test-number', test_number,
360+
'--',
361+
] + test_params['mkosi_args']
362+
363+
# We don't explicitly depend on the "mkosi" target because that means the image is rebuilt
364+
# on every "ninja -C build". Instead, the mkosi target has to be rebuilt manually before
365+
# running the integration tests with mkosi.
366+
test(dirname,
367+
integration_test_wrapper,
368+
env: test_env,
369+
args : args,
370+
timeout : test_params['timeout'],
371+
suite : 'integration-tests')
372+
endforeach

0 commit comments

Comments
 (0)