]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: install unit tests in a dedicated subdirectory below '$testsdir'
authorFranck Bui <fbui@suse.com>
Thu, 26 Jan 2023 15:07:17 +0000 (16:07 +0100)
committerFranck Bui <fbui@suse.com>
Fri, 24 Mar 2023 13:08:57 +0000 (14:08 +0100)
/usr/lib/systemd/tests may contain more than the unit tests. For example on
SUSE we also install the integration tests there.

Putting the unit tests in a dedicated directory named 'unit-tests' makes the
layout cleaner.

Note that `run-unit-tests.py` has not been moved so we don't need to adjust
(Fedora) packaging and users also don't need to descend into the subdirectory.

meson.build
test/meson.build
test/run-unit-tests.py
test/test-functions
test/units/testsuite-02.sh
test/units/testsuite-35.sh

index 6770deed4ff11a41d4e8cc68386d802a50b982eb..100bf54506d6fb7510c77bd4a607a585432c0435 100644 (file)
@@ -201,6 +201,7 @@ kernelinstalldir = kerneldir / 'install.d'
 factorydir = datadir / 'factory'
 bootlibdir = prefixdir / 'lib/systemd/boot/efi'
 testsdir = prefixdir / 'lib/systemd/tests'
+unittestsdir = testsdir / 'unit-tests'
 systemdstatedir = localstatedir / 'lib/systemd'
 catalogstatedir = systemdstatedir / 'catalog'
 randomseeddir = localstatedir / 'lib/systemd'
@@ -4330,7 +4331,7 @@ foreach test : tests
                 build_by_default : want_tests != 'false',
                 install_rpath : rootpkglibdir,
                 install : install_tests,
-                install_dir : testsdir / type,
+                install_dir : unittestsdir / type,
                 link_depends : runtest_env)
 
         if type == 'manual'
@@ -4354,7 +4355,7 @@ exe = executable(
         dependencies : userspace,
         build_by_default : want_tests != 'false',
         install : install_tests,
-        install_dir : testsdir)
+        install_dir : unittestsdir)
 if want_tests != 'false'
         test('test-libsystemd-sym', exe)
 endif
@@ -4372,7 +4373,7 @@ exe = executable(
         ],
         build_by_default : want_tests != 'false' and static_libsystemd_pic,
         install : install_tests and static_libsystemd_pic,
-        install_dir : testsdir)
+        install_dir : unittestsdir)
 if want_tests != 'false' and static_libsystemd_pic
         test('test-libsystemd-static-sym', exe)
 endif
@@ -4386,7 +4387,7 @@ exe = executable(
         dependencies : userspace,
         build_by_default : want_tests != 'false',
         install : install_tests,
-        install_dir : testsdir)
+        install_dir : unittestsdir)
 if want_tests != 'false'
         test('test-libudev-sym', exe)
 endif
@@ -4400,7 +4401,7 @@ exe = executable(
         dependencies : userspace,
         build_by_default : want_tests != 'false' and static_libudev_pic,
         install : install_tests and static_libudev_pic,
-        install_dir : testsdir)
+        install_dir : unittestsdir)
 if want_tests != 'false' and static_libudev_pic
         test('test-libudev-static-sym', exe)
 endif
index 1721cffcd557aaeb3ad5337b5afec377d17f1074..4bd7376c62d115f1d3d5742f750df3e17600b8fe 100644 (file)
@@ -76,7 +76,7 @@ test_sysusers_sh = configure_file(
         configuration : conf)
 if install_tests and conf.get('ENABLE_SYSUSERS') == 1
         install_data(test_sysusers_sh,
-                     install_dir : testsdir)
+                     install_dir : unittestsdir)
         install_subdir('test-sysusers',
                        exclude_files : '.gitattributes',
                        install_dir : testdata_dir)
@@ -87,7 +87,7 @@ endif
 test_compare_versions_sh = files('test-compare-versions.sh')
 if install_tests
         install_data(test_compare_versions_sh,
-                     install_dir : testsdir)
+                     install_dir : unittestsdir)
 endif
 
 ############################################################
@@ -109,11 +109,11 @@ if install_tests
 
         install_data('test-fstab-generator.sh',
                      install_mode : 'rwxr-xr-x',
-                     install_dir : testsdir)
+                     install_dir : unittestsdir)
 
         install_data('test-network-generator-conversion.sh',
                      install_mode : 'rwxr-xr-x',
-                     install_dir : testsdir)
+                     install_dir : unittestsdir)
 endif
 
 ############################################################
index 4b180cc8df0814f7a3be5ce5625f9df385d9b4a1..2d6709b703c9bac6b38b06a48aef69221637bc0a 100755 (executable)
@@ -32,7 +32,7 @@ def argument_parser():
 
 opts = argument_parser().parse_args()
 
-unittestdir = pathlib.Path(__file__).parent.absolute()
+unittestdir = pathlib.Path(__file__).parent.absolute() / 'unit-tests'
 
 tests = list(unittestdir.glob('test-*'))
 if opts.unsafe:
index 820cb93e95409d87b25bc992fb8f3391317705fd..472ede1ba0a5be66e9069155e7ecfb165abb222c 100644 (file)
@@ -1188,9 +1188,8 @@ install_suse_systemd() {
     # long as it runs an equivalent version of systemd) getting rid of the
     # hassles of fetching, configuring, building the source code.
     dinfo "Install the files needed by the tests at runtime"
-    image_install "${SOURCE_DIR}"/test-*
     inst_recursive "${SOURCE_DIR}/testdata"
-    inst_recursive "${SOURCE_DIR}/manual"
+    inst_recursive "${SOURCE_DIR}/unit-tests"
 
     # On openSUSE, this directory is not created at package install, at least
     # for now.
@@ -1272,7 +1271,7 @@ get_ldpath() {
 install_missing_libraries() {
     dinfo "Install missing libraries"
     # install possible missing libraries
-    for i in "${initdir:?}"{,/usr}/{sbin,bin}/* "$initdir"{,/usr}/lib/systemd/{,tests/{,manual/,unsafe/}}*; do
+    for i in "${initdir:?}"{,/usr}/{sbin,bin}/* "$initdir"{,/usr}/lib/systemd/{,tests/unit-tests/{,manual/,unsafe/}}*; do
         LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$(get_ldpath "$i")" inst_libs "$i"
     done
 
index 8ebcc575ee7cab5c1fd8471a5102647f5620374a..61f6d06397012646a377048cecaade74188f872b 100755 (executable)
@@ -6,7 +6,7 @@ set -o pipefail
 NPROC=$(nproc)
 MAX_QUEUE_SIZE=${NPROC:-2}
 TESTS_GLOB=${TESTS_GLOB:-test-*}
-mapfile -t TEST_LIST < <(find /usr/lib/systemd/tests/ -maxdepth 1 -type f -name "${TESTS_GLOB}")
+mapfile -t TEST_LIST < <(find /usr/lib/systemd/tests/unit-tests/ -maxdepth 1 -type f -name "${TESTS_GLOB}")
 
 # reset state
 rm -fv /failed-tests /skipped-tests /skipped
index 02f22cf2a2355f0d674fb351173c5ffee5e17b51..8dcd7563bb4081bfee5401ee769e5a13de29ed00 100755 (executable)
@@ -517,7 +517,7 @@ test_session_properties() {
     create_session
 
     s=$(loginctl list-sessions --no-legend | awk '$3 == "logind-test-user" { print $1 }')
-    /usr/lib/systemd/tests/manual/test-session-properties "/org/freedesktop/login1/session/_3${s?}"
+    /usr/lib/systemd/tests/unit-tests/manual/test-session-properties "/org/freedesktop/login1/session/_3${s?}"
 }
 
 test_list_users() {