1# SPDX-License-Identifier: LGPL-2.1-or-later
2
3if install_tests
4        testdata_dir = testsdir + '/testdata/'
5
6        install_subdir('journal-data',
7                       exclude_files : '.gitattributes',
8                       install_dir : testdata_dir)
9        install_subdir('units',
10                       exclude_files : '.gitattributes',
11                       install_dir : testdata_dir)
12        install_subdir('test-execute',
13                       exclude_files : '.gitattributes',
14                       install_dir : testdata_dir)
15        install_subdir('test-fstab-generator',
16                       exclude_files : '.gitattributes',
17                       install_dir : testdata_dir)
18        install_subdir('test-path',
19                       exclude_files : '.gitattributes',
20                       install_dir : testdata_dir)
21        install_subdir('test-path-util',
22                       exclude_files : '.gitattributes',
23                       install_dir : testdata_dir)
24        install_subdir('test-umount',
25                       exclude_files : '.gitattributes',
26                       install_dir : testdata_dir)
27        install_subdir('test-network-generator-conversion',
28                       exclude_files : '.gitattributes',
29                       install_dir : testdata_dir)
30        install_subdir('testsuite-04.units',
31                       exclude_files : '.gitattributes',
32                       install_dir : testdata_dir)
33        install_subdir('testsuite-06.units',
34                       exclude_files : '.gitattributes',
35                       install_dir : testdata_dir)
36        install_subdir('testsuite-10.units',
37                       exclude_files : '.gitattributes',
38                       install_dir : testdata_dir)
39        install_subdir('testsuite-11.units',
40                       exclude_files : '.gitattributes',
41                       install_dir : testdata_dir)
42        install_subdir('testsuite-16.units',
43                       exclude_files : '.gitattributes',
44                       install_dir : testdata_dir)
45        install_subdir('testsuite-28.units',
46                       exclude_files : '.gitattributes',
47                       install_dir : testdata_dir)
48        install_subdir('testsuite-30.units',
49                       exclude_files : '.gitattributes',
50                       install_dir : testdata_dir)
51        install_subdir('testsuite-52.units',
52                       exclude_files : '.gitattributes',
53                       install_dir : testdata_dir)
54        install_subdir('testsuite-63.units',
55                       exclude_files : '.gitattributes',
56                       install_dir : testdata_dir)
57
58        install_data(kbd_model_map,
59                     install_dir : testdata_dir + '/test-keymap-util')
60
61        testsuite08_dir = testdata_dir + '/testsuite-08.units'
62        install_data('testsuite-08.units/-.mount',
63                     install_dir : testsuite08_dir)
64        install_data('testsuite-08.units/systemd-remount-fs.service',
65                     install_dir : testsuite08_dir)
66        meson.add_install_script(meson_make_symlink,
67                                 './-.mount',
68                                 testsuite08_dir + '/root.mount')
69        meson.add_install_script(meson_make_symlink,
70                                 '../-.mount',
71                                 testsuite08_dir + '/local-fs.target.wants/-.mount')
72
73        if conf.get('HAVE_GNU_EFI') == 1 and conf.get('HAVE_ZSTD') == 1
74                install_subdir('test-bcd',
75                               exclude_files : '.gitattributes',
76                               install_dir : testdata_dir)
77        endif
78        if conf.get('ENABLE_RESOLVE') == 1
79                install_subdir('test-resolve',
80                               exclude_files : '.gitattributes',
81                               install_dir : testdata_dir)
82        endif
83
84        install_data('create-busybox-container',
85                     install_mode : 'rwxr-xr-x',
86                     install_dir : testdata_dir)
87endif
88
89test_fstab_generator_sh = find_program('test-fstab-generator.sh')
90test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh')
91test_systemctl_enable_sh = find_program('test-systemctl-enable.sh')
92test_systemd_tmpfiles_py = find_program('test-systemd-tmpfiles.py')
93hwdb_test_sh = find_program('hwdb-test.sh')
94
95############################################################
96
97test_sysusers_sh = configure_file(
98        input : 'test-sysusers.sh.in',
99        output : 'test-sysusers.sh',
100        configuration : conf)
101if install_tests and conf.get('ENABLE_SYSUSERS') == 1
102        install_data(test_sysusers_sh,
103                     install_dir : testsdir)
104        install_subdir('test-sysusers',
105                       exclude_files : '.gitattributes',
106                       install_dir : testdata_dir)
107endif
108
109############################################################
110
111rule_syntax_check_py = find_program('rule-syntax-check.py')
112if want_tests != 'false'
113        test('rule-syntax-check',
114             rule_syntax_check_py,
115             suite : 'dist-check',
116             args : all_rules)
117endif
118
119############################################################
120
121if install_tests
122        install_data('run-unit-tests.py',
123                     install_mode : 'rwxr-xr-x',
124                     install_dir : testsdir)
125
126        install_data('test-fstab-generator.sh',
127                     install_mode : 'rwxr-xr-x',
128                     install_dir : testsdir)
129
130        install_data('test-network-generator-conversion.sh',
131                     install_mode : 'rwxr-xr-x',
132                     install_dir : testsdir)
133endif
134
135############################################################
136
137# prepare test/sys tree
138sys_script_py = find_program('sys-script.py')
139custom_target(
140        'sys',
141        command : [sys_script_py, meson.current_build_dir()],
142        output : 'sys',
143        build_by_default : want_tests != 'false')
144
145if perl.found()
146        udev_test_pl = find_program('udev-test.pl')
147        if want_tests != 'false'
148                test('udev-test',
149                     udev_test_pl,
150                     timeout : 180)
151        endif
152else
153        message('Skipping udev-test because perl is not available')
154endif
155
156############################################################
157
158rpm = find_program('rpm', required : false)
159rpmspec = find_program('rpmspec', required : false)
160test_rpm_macros = find_program('test-rpm-macros.sh')
161
162if rpm.found() and rpmspec.found()
163        if want_tests != 'false'
164                test('test-rpm-macros',
165                     test_rpm_macros,
166                     suite : 'dist-check',
167                     args : [project_build_root])
168        endif
169else
170      message('Skipping test-rpm-macros since rpm and/or rpmspec are not available')
171endif
172
173############################################################
174
175if want_tests != 'false' and dmi_arches.contains(host_machine.cpu_family())
176        udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh')
177
178        if git.found() and fs.exists(project_source_root / '.git')
179                out = run_command(
180                        env, '-u', 'GIT_WORK_TREE',
181                        git, '--git-dir=@0@/.git'.format(project_source_root),
182                        'ls-files', ':/test/dmidecode-dumps/*.bin',
183                        check: true)
184        else
185                out = run_command(
186                        sh, '-c', 'cd "$1"; echo test/dmidecode-dumps/*.bin', '_', project_source_root,
187                        check: true)
188        endif
189
190        foreach p : out.stdout().split()
191                source = project_source_root / p
192                name = 'dmidecode_' + p.split('/')[-1].split('.')[0]
193
194                test(name,
195                     udev_dmi_memory_id_test,
196                     suite : 'dist-check',
197                     args : [udev_prog_paths['dmi_memory_id'].full_path(),
198                             source,
199                             source + '.txt'],
200                     depends : udev_prog_paths['dmi_memory_id'])
201        endforeach
202endif
203
204subdir('fuzz')
205