]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: Use test.service template for all integration tests 36979/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 2 Apr 2025 19:58:59 +0000 (21:58 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 2 Apr 2025 19:58:59 +0000 (21:58 +0200)
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.

13 files changed:
test/integration-tests/TEST-07-PID1/TEST-07-PID1.service [deleted file]
test/integration-tests/TEST-07-PID1/meson.build
test/integration-tests/TEST-16-EXTEND-TIMEOUT/TEST-16-EXTEND-TIMEOUT.service [deleted file]
test/integration-tests/TEST-16-EXTEND-TIMEOUT/meson.build
test/integration-tests/TEST-44-LOG-NAMESPACE/TEST-44-LOG-NAMESPACE.service [deleted file]
test/integration-tests/TEST-44-LOG-NAMESPACE/meson.build
test/integration-tests/TEST-69-SHUTDOWN/TEST-69-SHUTDOWN.service [deleted file]
test/integration-tests/TEST-69-SHUTDOWN/meson.build
test/integration-tests/TEST-82-SOFTREBOOT/TEST-82-SOFTREBOOT.service [deleted file]
test/integration-tests/TEST-82-SOFTREBOOT/meson.build
test/integration-tests/meson.build
test/meson.build
test/test.service.in

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 (file)
index f2c8697..0000000
+++ /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
index 3b3178210833ef544f0625a3f7f9fec17bfe008e..678fc5f0ec5339998ab5aaefdd704856a332248d 100644 (file)
@@ -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 (file)
index 3189a24..0000000
+++ /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
index e18b8474710c73b419a5a16806f08fd496e2db0f..a7eac125e32e6faa6cf5218b9ee189eb6a083ae2 100644 (file)
@@ -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 (file)
index bed66fa..0000000
+++ /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
index 555ba7befdfd803fa3729604d2160256ebe7c864..6a33a8bd18dcdf6f51cdface71db243e376259c4 100644 (file)
@@ -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 (file)
index 7b47b61..0000000
+++ /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
index c1b1ab557f09d767e0d10ecaabbf31a6c1f199ee..edc0abfb87542b4386cd695de42a7cdb620e71d7 100644 (file)
@@ -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 (file)
index d9c4529..0000000
+++ /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
index a7c1bf0bd5573174d17dd448a0a18db87d1e76fe..3e3f7767c6aafcffc5ba06d7d4777d16e00947e7 100644 (file)
@@ -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,
index 3afbeac1e465c8411c6f48923be8ba267e57beec..1980acc10c4dbd1f3e9c6af24430c79f28ab943b 100644 (file)
@@ -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
index b23553e34a810341b80e454b75afb1333d16d57c..68bffdb282f65be8abb449d4874bf84605c6a763 100644 (file)
@@ -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 = [
index a2e60afa4d8ddcc9e2ccf1d35442015ba4197b86..0d0dccdb7549a7e1acc4a84d582213011b7bf48c 100644 (file)
@@ -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@