mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
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.
This commit is contained in:
@@ -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
|
||||
@@ -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',
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -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
|
||||
@@ -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)$',
|
||||
},
|
||||
]
|
||||
|
||||
@@ -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
|
||||
@@ -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',
|
||||
]),
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -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
|
||||
@@ -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',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -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
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = []
|
||||
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']['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
|
||||
foreach key, value : integration_test['configuration']['unit']
|
||||
integration_test_extra_unit_properties += [f'@key@=@value@']
|
||||
endforeach
|
||||
|
||||
if install_tests
|
||||
install_data(integration_test_unit, install_dir : testdata_dir / 'units')
|
||||
endif
|
||||
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 = [
|
||||
|
||||
@@ -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@
|
||||
|
||||
Reference in New Issue
Block a user