From: Daan De Meyer Date: Wed, 2 Apr 2025 19:58:59 +0000 (+0200) Subject: test: Use test.service template for all integration tests X-Git-Tag: v258-rc1~930^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F36979%2Fhead;p=thirdparty%2Fsystemd.git test: Use test.service template for all integration tests Instead of having some tests have their own unit, let's make test.service.in generic enough so that it works for all integration tests. --- diff --git a/test/integration-tests/TEST-07-PID1/TEST-07-PID1.service b/test/integration-tests/TEST-07-PID1/TEST-07-PID1.service deleted file mode 100644 index f2c8697e5b6..00000000000 --- a/test/integration-tests/TEST-07-PID1/TEST-07-PID1.service +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later -[Unit] -Description=TEST-07-PID1 -Wants=basic.target multi-user.target -After=basic.target - -[Service] -Type=oneshot -ExecStartPre=rm -f /failed /testok -ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh -NotifyAccess=all -# Issue: https://github.com/systemd/systemd/issues/2691 -ExecStop=sh -c 'kill -SEGV $$$$' -RemainAfterExit=yes -TimeoutStopSec=270s diff --git a/test/integration-tests/TEST-07-PID1/meson.build b/test/integration-tests/TEST-07-PID1/meson.build index 3b317821083..678fc5f0ec5 100644 --- a/test/integration-tests/TEST-07-PID1/meson.build +++ b/test/integration-tests/TEST-07-PID1/meson.build @@ -3,6 +3,14 @@ integration_tests += [ integration_test_template + { 'name' : fs.name(meson.current_source_dir()), - 'unit' : files('TEST-07-PID1.service'), + 'configuration' : integration_test_template['configuration'] + { + 'service' : integration_test_template['configuration']['service'] + { + 'NotifyAccess' : 'all', + # Issue: https://github.com/systemd/systemd/issues/2691 + 'ExecStop' : 'sh -c \'kill -SEGV $$$$\'', + 'RemainAfterExit' : 'yes', + 'TimeoutStopSec' : '270s', + }, + }, }, ] diff --git a/test/integration-tests/TEST-16-EXTEND-TIMEOUT/TEST-16-EXTEND-TIMEOUT.service b/test/integration-tests/TEST-16-EXTEND-TIMEOUT/TEST-16-EXTEND-TIMEOUT.service deleted file mode 100644 index 3189a2484a6..00000000000 --- a/test/integration-tests/TEST-16-EXTEND-TIMEOUT/TEST-16-EXTEND-TIMEOUT.service +++ /dev/null @@ -1,21 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later -[Unit] -Description=TEST-16-EXTEND-TIMEOUT -# Testsuite: Assess all other testsuite-*.services worked as expected - -Wants=basic.target multi-user.target -After=basic.target - -Wants=success-all.service -Wants=success-start.service -Wants=success-runtime.service -Wants=success-stop.service -Wants=fail-start.service -Wants=fail-stop.service -Wants=fail-runtime.service -StopWhenUnneeded=yes - -[Service] -ExecStartPre=rm -f /failed /testok -Type=oneshot -ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh diff --git a/test/integration-tests/TEST-16-EXTEND-TIMEOUT/meson.build b/test/integration-tests/TEST-16-EXTEND-TIMEOUT/meson.build index e18b8474710..a7eac125e32 100644 --- a/test/integration-tests/TEST-16-EXTEND-TIMEOUT/meson.build +++ b/test/integration-tests/TEST-16-EXTEND-TIMEOUT/meson.build @@ -3,7 +3,20 @@ integration_tests += [ integration_test_template + { 'name' : fs.name(meson.current_source_dir()), - 'unit' : files('TEST-16-EXTEND-TIMEOUT.service'), + 'configuration' : integration_test_template['configuration'] + { + 'unit' : integration_test_template['configuration']['unit'] + { + 'Wants' : ' '.join([ + 'success-all.service', + 'success-start.service', + 'success-runtime.service', + 'success-stop.service', + 'fail-start.service', + 'fail-stop.service', + 'fail-runtime.service', + ]), + 'StopWhenUnneeded' : 'yes', + }, + }, 'coredump-exclude-regex' : '/(bash|sleep)$', }, ] diff --git a/test/integration-tests/TEST-44-LOG-NAMESPACE/TEST-44-LOG-NAMESPACE.service b/test/integration-tests/TEST-44-LOG-NAMESPACE/TEST-44-LOG-NAMESPACE.service deleted file mode 100644 index bed66fa0037..00000000000 --- a/test/integration-tests/TEST-44-LOG-NAMESPACE/TEST-44-LOG-NAMESPACE.service +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later -[Unit] -Description=TEST-44-LOG-NAMESPACE -Wants=basic.target multi-user.target systemd-journald@foobar.socket systemd-journald-varlink@foobar.socket -After=basic.target systemd-journald@foobar.socket systemd-journald-varlink@foobar.socket - -[Service] -ExecStartPre=rm -f /failed /testok -ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh -Type=oneshot diff --git a/test/integration-tests/TEST-44-LOG-NAMESPACE/meson.build b/test/integration-tests/TEST-44-LOG-NAMESPACE/meson.build index 555ba7befdf..6a33a8bd18d 100644 --- a/test/integration-tests/TEST-44-LOG-NAMESPACE/meson.build +++ b/test/integration-tests/TEST-44-LOG-NAMESPACE/meson.build @@ -3,6 +3,17 @@ integration_tests += [ integration_test_template + { 'name' : fs.name(meson.current_source_dir()), - 'unit' : files('TEST-44-LOG-NAMESPACE.service'), + 'configuration' : integration_test_template['configuration'] + { + 'unit' : integration_test_template['configuration']['unit'] + { + 'Wants' : ' '.join([ + 'systemd-journald@foobar.socket', + 'systemd-journald-varlink@foobar.socket', + ]), + 'After' : ' '.join([ + 'systemd-journald@foobar.socket', + 'systemd-journald-varlink@foobar.socket', + ]), + }, + }, }, ] diff --git a/test/integration-tests/TEST-69-SHUTDOWN/TEST-69-SHUTDOWN.service b/test/integration-tests/TEST-69-SHUTDOWN/TEST-69-SHUTDOWN.service deleted file mode 100644 index 7b47b618936..00000000000 --- a/test/integration-tests/TEST-69-SHUTDOWN/TEST-69-SHUTDOWN.service +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later -[Unit] -Description=TEST-69-SHUTDOWN -Wants=basic.target multi-user.target -After=basic.target - -ConditionPathExists=/usr/bin/python3 - -[Service] -Type=oneshot -ExecStart=/usr/lib/systemd/tests/testdata/units/TEST-69-SHUTDOWN.py diff --git a/test/integration-tests/TEST-69-SHUTDOWN/meson.build b/test/integration-tests/TEST-69-SHUTDOWN/meson.build index c1b1ab557f0..edc0abfb875 100644 --- a/test/integration-tests/TEST-69-SHUTDOWN/meson.build +++ b/test/integration-tests/TEST-69-SHUTDOWN/meson.build @@ -3,10 +3,8 @@ integration_tests += [ integration_test_template + { 'name' : fs.name(meson.current_source_dir()), - 'unit' : files('TEST-69-SHUTDOWN.service'), 'configuration' : integration_test_template['configuration'] + { - 'wants' : '@0@ systemd-user-sessions.service'.format(integration_test_template['configuration']['wants']), - 'after' : '@0@ systemd-user-sessions.service'.format(integration_test_template['configuration']['after']), + 'command' : '/usr/lib/systemd/tests/testdata/units/%N.py', }, }, ] diff --git a/test/integration-tests/TEST-82-SOFTREBOOT/TEST-82-SOFTREBOOT.service b/test/integration-tests/TEST-82-SOFTREBOOT/TEST-82-SOFTREBOOT.service deleted file mode 100644 index d9c45294125..00000000000 --- a/test/integration-tests/TEST-82-SOFTREBOOT/TEST-82-SOFTREBOOT.service +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later -[Unit] -Description=TEST-82-SOFTREBOOT -DefaultDependencies=no -Wants=basic.target multi-user.target -After=basic.target - -[Service] -Type=oneshot -ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh -FileDescriptorStoreMax=3 -NotifyAccess=all diff --git a/test/integration-tests/TEST-82-SOFTREBOOT/meson.build b/test/integration-tests/TEST-82-SOFTREBOOT/meson.build index a7c1bf0bd55..3e3f7767c6a 100644 --- a/test/integration-tests/TEST-82-SOFTREBOOT/meson.build +++ b/test/integration-tests/TEST-82-SOFTREBOOT/meson.build @@ -3,7 +3,15 @@ integration_tests += [ integration_test_template + { 'name' : fs.name(meson.current_source_dir()), - 'unit' : files('TEST-82-SOFTREBOOT.service'), + 'configuration' : integration_test_template['configuration'] + { + 'unit' : integration_test_template['configuration']['unit'] + { + 'DefaultDependencies' : 'no', + }, + 'service' : integration_test_template['configuration']['service'] + { + 'FileDescriptorStoreMax' : '3', + 'NotifyAccess' : 'all', + }, + }, 'cmdline' : ['systemd.set_credential=kernelcmdlinecred:uff'], 'storage' : 'persistent', 'vm' : true, diff --git a/test/integration-tests/meson.build b/test/integration-tests/meson.build index 3afbeac1e46..1980acc10c4 100644 --- a/test/integration-tests/meson.build +++ b/test/integration-tests/meson.build @@ -15,6 +15,8 @@ integration_test_template = { 'wants' : 'multi-user.target user@4711.service', 'after' : 'user@4711.service', 'env' : {}, + 'service' : {}, + 'unit' : {}, }, 'cmdline' : [], 'credentials' : [], @@ -109,14 +111,9 @@ foreach integration_test : integration_tests '--exit-code', integration_test['exit-code'].to_string(), '--coredump-exclude-regex', integration_test['coredump-exclude-regex'], '--sanitizer-exclude-regex', integration_test['sanitizer-exclude-regex'], + '--unit', '@0@.service'.format(integration_test['name']) ] - if 'unit' in integration_test - integration_test_args += ['--unit', fs.name(integration_test['unit'])] - else - integration_test_args += ['--unit', '@0@.service'.format(integration_test['name'])] - endif - if integration_test['vm'] integration_test_args += ['--vm'] endif diff --git a/test/meson.build b/test/meson.build index b23553e34a8..68bffdb282f 100644 --- a/test/meson.build +++ b/test/meson.build @@ -283,27 +283,33 @@ endif if install_tests foreach integration_test : integration_tests - if 'unit' in integration_test - integration_test_unit = integration_test['unit'] - else - integration_test_unit_env = [] - - foreach key, value : integration_test['configuration']['env'] - integration_test_unit_env += [f'@key@=@value@'] - endforeach - - integration_test_unit = configure_file( - input : 'test.service.in', - output : '@0@.service'.format(integration_test['name']), - configuration : integration_test['configuration'] + { - 'env' : ' '.join(integration_test_unit_env) - }, - ) - endif - - if install_tests - install_data(integration_test_unit, install_dir : testdata_dir / 'units') - endif + integration_test_unit_env = [] + integration_test_extra_unit_properties = [] + integration_test_extra_service_properties = [] + + foreach key, value : integration_test['configuration']['env'] + integration_test_unit_env += [f'@key@=@value@'] + endforeach + + foreach key, value : integration_test['configuration']['unit'] + integration_test_extra_unit_properties += [f'@key@=@value@'] + endforeach + + foreach key, value : integration_test['configuration']['service'] + integration_test_extra_service_properties += [f'@key@=@value@'] + endforeach + + integration_test_unit = configure_file( + input : 'test.service.in', + output : '@0@.service'.format(integration_test['name']), + configuration : integration_test['configuration'] + { + 'env' : ' '.join(integration_test_unit_env), + 'unit' : '\n'.join(integration_test_extra_unit_properties), + 'service' : '\n'.join(integration_test_extra_service_properties), + }, + ) + + install_data(integration_test_unit, install_dir : testdata_dir / 'units') endforeach testdata_subdirs = [ diff --git a/test/test.service.in b/test/test.service.in index a2e60afa4d8..0d0dccdb754 100644 --- a/test/test.service.in +++ b/test/test.service.in @@ -3,6 +3,7 @@ Description=%N Wants=basic.target network.target @wants@ After=basic.target network.target @after@ +@unit@ [Service] ExecStartPre=rm -f /failed /testok @@ -11,3 +12,4 @@ Type=oneshot MemoryAccounting=@memory-accounting@ Environment=SYSTEMD_PAGER= @env@ UnsetEnvironment=JOURNAL_STREAM +@service@