2020-11-09 12:23:58 +08:00
|
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
2017-11-19 01:32:01 +08:00
|
|
|
|
2020-07-14 17:35:29 +08:00
|
|
|
if install_tests
|
|
|
|
testdata_dir = testsdir + '/testdata/'
|
|
|
|
|
|
|
|
install_subdir('journal-data',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('units',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('test-execute',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('test-path',
|
|
|
|
install_dir : testdata_dir)
|
2020-09-18 20:28:08 +08:00
|
|
|
install_subdir('test-path-util',
|
|
|
|
install_dir : testdata_dir)
|
2020-07-14 17:35:29 +08:00
|
|
|
install_subdir('test-umount',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('test-network-generator-conversion',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('testsuite-04.units',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('testsuite-06.units',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('testsuite-10.units',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('testsuite-11.units',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('testsuite-16.units',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('testsuite-28.units',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('testsuite-30.units',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
install_subdir('testsuite-52.units',
|
|
|
|
install_dir : testdata_dir)
|
2021-08-24 23:46:47 +08:00
|
|
|
install_subdir('testsuite-63.units',
|
|
|
|
install_dir : testdata_dir)
|
2019-12-08 18:24:39 +08:00
|
|
|
|
2020-07-14 17:35:29 +08:00
|
|
|
testsuite08_dir = testdata_dir + '/testsuite-08.units'
|
|
|
|
install_data('testsuite-08.units/-.mount',
|
|
|
|
install_dir : testsuite08_dir)
|
|
|
|
install_data('testsuite-08.units/systemd-remount-fs.service',
|
|
|
|
install_dir : testsuite08_dir)
|
|
|
|
meson.add_install_script(meson_make_symlink,
|
|
|
|
'./-.mount',
|
|
|
|
testsuite08_dir + '/root.mount')
|
|
|
|
meson.add_install_script(meson_make_symlink,
|
|
|
|
'../-.mount',
|
|
|
|
testsuite08_dir + '/local-fs.target.wants/-.mount')
|
2017-04-14 08:47:20 +08:00
|
|
|
|
2020-07-14 17:35:29 +08:00
|
|
|
if conf.get('ENABLE_RESOLVE') == 1
|
|
|
|
install_subdir('test-resolve',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
endif
|
2019-12-10 23:05:48 +08:00
|
|
|
|
2020-07-14 17:35:29 +08:00
|
|
|
install_data('create-busybox-container',
|
|
|
|
install_mode : 'rwxr-xr-x',
|
|
|
|
install_dir : testdata_dir)
|
2017-04-14 08:47:20 +08:00
|
|
|
endif
|
|
|
|
|
2019-12-10 20:04:39 +08:00
|
|
|
test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh')
|
2021-01-01 03:56:02 +08:00
|
|
|
test_systemd_tmpfiles_py = find_program('test-systemd-tmpfiles.py')
|
2021-04-15 14:20:31 +08:00
|
|
|
hwdb_test_sh = find_program('hwdb-test.sh')
|
2021-01-01 03:56:02 +08:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
|
2020-09-26 17:58:24 +08:00
|
|
|
test_sysusers_sh = configure_file(
|
|
|
|
input : 'test-sysusers.sh.in',
|
|
|
|
output : 'test-sysusers.sh',
|
2021-05-16 21:57:55 +08:00
|
|
|
configuration : conf)
|
2020-09-26 17:58:24 +08:00
|
|
|
if install_tests and conf.get('ENABLE_SYSUSERS') == 1
|
|
|
|
install_data(test_sysusers_sh,
|
|
|
|
install_dir : testsdir)
|
|
|
|
install_subdir('test-sysusers',
|
|
|
|
install_dir : testdata_dir)
|
|
|
|
endif
|
|
|
|
|
|
|
|
############################################################
|
|
|
|
|
2017-11-22 19:42:28 +08:00
|
|
|
rule_syntax_check_py = find_program('rule-syntax-check.py')
|
2018-09-12 17:08:49 +08:00
|
|
|
if want_tests != 'false'
|
|
|
|
test('rule-syntax-check',
|
|
|
|
rule_syntax_check_py,
|
|
|
|
args : all_rules)
|
|
|
|
endif
|
2017-11-22 19:42:28 +08:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
|
2017-10-09 04:14:45 +08:00
|
|
|
if conf.get('HAVE_SYSV_COMPAT') == 1
|
|
|
|
sysv_generator_test_py = find_program('sysv-generator-test.py')
|
2018-09-12 17:08:49 +08:00
|
|
|
if want_tests != 'false'
|
|
|
|
test('sysv-generator-test',
|
|
|
|
sysv_generator_test_py)
|
|
|
|
endif
|
2017-10-09 04:14:45 +08:00
|
|
|
endif
|
2017-09-26 19:39:43 +08:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
|
tests: add a runner for installed tests
We have "installed tests", but don't provide an easy way to run them.
The protocol is very simple: each test must return 0 for success, 77 means
"skipped", anything else is an error. In addition, we want to print test
output only if the test failed.
I wrote this simple script. It is pretty basic, but implements the functions
listed above. Since it is written in python it should be easy to add option
parsing (like running only specific tests, or running unsafe tests, etc.)
I looked at the following alternatives:
- Ubuntu root-unittests: this works, but just dumps all output to the terminal,
has no coloring.
- @ssahani's test runner [2]
It uses the unittest library and the test suite was implented as a class, and
doesn't implement any of the functions listed above.
- cram [3,4]
cram runs our tests, but does not understand the "ignore the output" part,
has not support for our magic skip code (it uses hardcoded 80 instead),
and seems dead upstream.
- meson test
Here the idea would be to provide an almost-empty meson.build file under
/usr/lib/systemd/tests/ that would just define all the tests. This would
allow us to reuse the test runner we use normally. Unfortunately meson requires
a build directory and configuration to be done before running tests. This
would be possible, but seems a lot of effort to just run a few binaries.
[1] https://salsa.debian.org/systemd-team/systemd/blob/242c96addb06480ec9cd75248a5660f37a17b4b9/debian/tests/root-unittests
[2] https://github.com/systemd/systemd-fedora-ci/blob/master/upstream/systemd-upstream-tests.py
[3] https://bitheap.org/cram/
[4] https://pypi.org/project/pytest-cram/
Fixes #10069.
2018-09-20 22:34:14 +08:00
|
|
|
if install_tests
|
|
|
|
install_data('run-unit-tests.py',
|
|
|
|
install_mode : 'rwxr-xr-x',
|
|
|
|
install_dir : testsdir)
|
2021-10-21 01:43:34 +08:00
|
|
|
|
|
|
|
if conf.get('ENABLE_NETWORKD') == 1
|
|
|
|
install_data('test-network-generator-conversion.sh',
|
|
|
|
install_mode : 'rwxr-xr-x',
|
|
|
|
install_dir : testsdir)
|
|
|
|
endif
|
tests: add a runner for installed tests
We have "installed tests", but don't provide an easy way to run them.
The protocol is very simple: each test must return 0 for success, 77 means
"skipped", anything else is an error. In addition, we want to print test
output only if the test failed.
I wrote this simple script. It is pretty basic, but implements the functions
listed above. Since it is written in python it should be easy to add option
parsing (like running only specific tests, or running unsafe tests, etc.)
I looked at the following alternatives:
- Ubuntu root-unittests: this works, but just dumps all output to the terminal,
has no coloring.
- @ssahani's test runner [2]
It uses the unittest library and the test suite was implented as a class, and
doesn't implement any of the functions listed above.
- cram [3,4]
cram runs our tests, but does not understand the "ignore the output" part,
has not support for our magic skip code (it uses hardcoded 80 instead),
and seems dead upstream.
- meson test
Here the idea would be to provide an almost-empty meson.build file under
/usr/lib/systemd/tests/ that would just define all the tests. This would
allow us to reuse the test runner we use normally. Unfortunately meson requires
a build directory and configuration to be done before running tests. This
would be possible, but seems a lot of effort to just run a few binaries.
[1] https://salsa.debian.org/systemd-team/systemd/blob/242c96addb06480ec9cd75248a5660f37a17b4b9/debian/tests/root-unittests
[2] https://github.com/systemd/systemd-fedora-ci/blob/master/upstream/systemd-upstream-tests.py
[3] https://bitheap.org/cram/
[4] https://pypi.org/project/pytest-cram/
Fixes #10069.
2018-09-20 22:34:14 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
############################################################
|
|
|
|
|
2017-09-26 19:39:43 +08:00
|
|
|
# prepare test/sys tree
|
|
|
|
sys_script_py = find_program('sys-script.py')
|
|
|
|
custom_target(
|
|
|
|
'sys',
|
|
|
|
command : [sys_script_py, meson.current_build_dir()],
|
|
|
|
output : 'sys',
|
2018-09-12 20:47:56 +08:00
|
|
|
build_by_default : want_tests != 'false')
|
2017-09-26 19:39:43 +08:00
|
|
|
|
2018-03-22 15:34:21 +08:00
|
|
|
if perl.found()
|
|
|
|
udev_test_pl = find_program('udev-test.pl')
|
2018-09-12 17:08:49 +08:00
|
|
|
if want_tests != 'false'
|
|
|
|
test('udev-test',
|
2019-01-19 05:32:42 +08:00
|
|
|
udev_test_pl,
|
|
|
|
timeout : 180)
|
2018-09-12 17:08:49 +08:00
|
|
|
endif
|
2018-03-22 15:34:21 +08:00
|
|
|
else
|
|
|
|
message('Skipping udev-test because perl is not available')
|
|
|
|
endif
|
2017-09-26 19:44:04 +08:00
|
|
|
|
2020-12-16 19:21:43 +08:00
|
|
|
############################################################
|
|
|
|
|
|
|
|
if want_tests != 'false' and dmi_arches.contains(host_machine.cpu_family())
|
2020-12-02 19:40:42 +08:00
|
|
|
udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh')
|
2020-12-16 19:21:43 +08:00
|
|
|
|
|
|
|
if git.found()
|
|
|
|
out = run_command(
|
2021-05-14 20:16:17 +08:00
|
|
|
env, '-u', 'GIT_WORK_TREE',
|
|
|
|
git, '--git-dir=@0@/.git'.format(project_source_root),
|
2020-12-16 19:21:43 +08:00
|
|
|
'ls-files', ':/test/dmidecode-dumps/*.bin')
|
|
|
|
else
|
|
|
|
out = run_command(
|
2021-05-14 20:16:17 +08:00
|
|
|
sh, '-c', 'ls @0@/test/dmidecode-dumps/*.bin'.format(project_source_root))
|
2020-12-16 19:21:43 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
foreach p : out.stdout().split()
|
2021-07-28 01:32:35 +08:00
|
|
|
source = project_source_root / p
|
2020-12-16 19:21:43 +08:00
|
|
|
name = 'dmidecode_' + p.split('/')[-1].split('.')[0]
|
|
|
|
|
|
|
|
test(name,
|
|
|
|
udev_dmi_memory_id_test,
|
2021-07-27 23:48:53 +08:00
|
|
|
args : [udev_prog_paths['dmi_memory_id'],
|
|
|
|
source,
|
|
|
|
source + '.txt'])
|
2020-12-16 19:21:43 +08:00
|
|
|
endforeach
|
2020-12-02 19:40:42 +08:00
|
|
|
endif
|
|
|
|
|
2018-07-08 00:09:21 +08:00
|
|
|
subdir('fuzz')
|