xref: /openbmc/qemu/tests/functional/meson.build (revision 118a2991)
1# QEMU functional tests:
2# Tests that are put in the 'quick' category are run by default during
3# 'make check'. Everything that should not be run during 'make check'
4# (e.g. tests that fetch assets from the internet) should be put into
5# the 'thorough' category instead.
6
7# Most tests run too slow with TCI enabled, so skip the functional tests there
8if get_option('tcg_interpreter')
9  subdir_done()
10endif
11
12# Timeouts for individual tests that can be slow e.g. with debugging enabled
13test_timeouts = {
14  'aarch64_raspi4' : 480,
15  'aarch64_sbsaref_alpine' : 720,
16  'aarch64_sbsaref_freebsd' : 720,
17  'aarch64_virt' : 720,
18  'acpi_bits' : 420,
19  'arm_aspeed' : 600,
20  'arm_bpim2u' : 500,
21  'arm_collie' : 180,
22  'arm_orangepi' : 540,
23  'arm_raspi2' : 120,
24  'arm_tuxrun' : 240,
25  'arm_sx1' : 360,
26  'mips_malta' : 120,
27  'netdev_ethtool' : 180,
28  'ppc_40p' : 240,
29  'ppc64_hv' : 1000,
30  'ppc64_powernv' : 480,
31  'ppc64_pseries' : 480,
32  'ppc64_tuxrun' : 420,
33  'riscv64_tuxrun' : 120,
34  's390x_ccw_virtio' : 420,
35}
36
37tests_generic_system = [
38  'empty_cpu_model',
39  'info_usernet',
40  'version',
41]
42
43tests_generic_linuxuser = [
44]
45
46tests_generic_bsduser = [
47]
48
49tests_aarch64_system_thorough = [
50  'aarch64_raspi3',
51  'aarch64_raspi4',
52  'aarch64_sbsaref',
53  'aarch64_sbsaref_alpine',
54  'aarch64_sbsaref_freebsd',
55  'aarch64_virt',
56  'multiprocess',
57]
58
59tests_alpha_system_thorough = [
60  'alpha_clipper',
61]
62
63tests_arm_system_thorough = [
64  'arm_aspeed',
65  'arm_bpim2u',
66  'arm_canona1100',
67  'arm_collie',
68  'arm_integratorcp',
69  'arm_orangepi',
70  'arm_raspi2',
71  'arm_sx1',
72  'arm_vexpress',
73  'arm_tuxrun',
74]
75
76tests_arm_linuxuser_thorough = [
77  'arm_bflt',
78]
79
80tests_avr_system_thorough = [
81  'avr_mega2560',
82]
83
84tests_i386_system_thorough = [
85  'i386_tuxrun',
86]
87
88tests_loongarch64_system_thorough = [
89  'loongarch64_virt',
90]
91
92tests_m68k_system_thorough = [
93  'm68k_mcf5208evb',
94  'm68k_nextcube',
95  'm68k_q800',
96]
97
98tests_microblaze_system_thorough = [
99  'microblaze_s3adsp1800'
100]
101
102tests_microblazeel_system_thorough = [
103  'microblazeel_s3adsp1800'
104]
105
106tests_mips_system_thorough = [
107  'mips_malta',
108  'mips_tuxrun',
109]
110
111tests_mipsel_system_thorough = [
112  'mipsel_malta',
113  'mipsel_tuxrun',
114]
115
116tests_mips64_system_thorough = [
117  'mips64_tuxrun',
118]
119
120tests_mips64el_system_thorough = [
121  'mips64el_fuloong2e',
122  'mips64el_loongson3v',
123  'mips64el_malta',
124  'mips64el_tuxrun',
125]
126
127tests_or1k_system_thorough = [
128  'or1k_sim',
129]
130
131tests_ppc_system_quick = [
132  'ppc_74xx',
133]
134
135tests_ppc_system_thorough = [
136  'ppc_405',
137  'ppc_40p',
138  'ppc_amiga',
139  'ppc_bamboo',
140  'ppc_mac',
141  'ppc_mpc8544ds',
142  'ppc_tuxrun',
143  'ppc_virtex_ml507',
144]
145
146tests_ppc64_system_thorough = [
147  'ppc64_e500',
148  'ppc64_hv',
149  'ppc64_powernv',
150  'ppc64_pseries',
151  'ppc64_tuxrun',
152]
153
154tests_riscv32_system_quick = [
155  'riscv_opensbi',
156]
157
158tests_riscv32_system_thorough = [
159  'riscv32_tuxrun',
160]
161
162tests_riscv64_system_quick = [
163  'riscv_opensbi',
164]
165
166tests_riscv64_system_thorough = [
167  'riscv64_tuxrun',
168]
169
170tests_rx_system_thorough = [
171  'rx_gdbsim',
172]
173
174tests_s390x_system_thorough = [
175  's390x_ccw_virtio',
176  's390x_topology',
177  's390x_tuxrun',
178]
179
180tests_sh4_system_thorough = [
181  'sh4_r2d',
182  'sh4_tuxrun',
183]
184
185tests_sh4eb_system_thorough = [
186  'sh4eb_r2d',
187]
188
189tests_sparc_system_thorough = [
190  'sparc_sun4m',
191]
192
193tests_sparc64_system_thorough = [
194  'sparc64_sun4u',
195  'sparc64_tuxrun',
196]
197
198tests_x86_64_system_quick = [
199  'cpu_queries',
200  'mem_addr_space',
201  'pc_cpu_hotplug_props',
202  'virtio_version',
203  'x86_cpu_model_versions',
204]
205
206tests_x86_64_system_thorough = [
207  'acpi_bits',
208  'x86_64_tuxrun',
209  'linux_initrd',
210  'multiprocess',
211  'netdev_ethtool',
212  'virtio_gpu',
213]
214
215tests_xtensa_system_thorough = [
216  'xtensa_lx60',
217]
218
219precache_all = []
220foreach speed : ['quick', 'thorough']
221  foreach dir : target_dirs
222
223    target_base = dir.split('-')[0]
224
225    if dir.endswith('-softmmu')
226      sysmode = 'system'
227      test_emulator = emulators['qemu-system-' + target_base]
228    elif dir.endswith('-linux-user')
229      sysmode = 'linuxuser'
230      test_emulator = emulators['qemu-' + target_base]
231    elif dir.endswith('-bsd-user')
232      sysmode = 'bsduser'
233      test_emulator = emulators['qemu-' + target_base]
234    else
235      continue
236    endif
237
238    if speed == 'quick'
239      suites = ['func-quick', 'func-' + target_base]
240      target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_quick', []) \
241                     + get_variable('tests_generic_' + sysmode)
242    else
243      suites = ['func-' + speed, 'func-' + target_base + '-' + speed, speed]
244      target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_' + speed, [])
245    endif
246
247    test_deps = roms
248    test_env = environment()
249    if have_tools
250      test_env.set('QEMU_TEST_QEMU_IMG', meson.global_build_root() / 'qemu-img')
251      test_deps += [qemu_img]
252    endif
253    test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path())
254    test_env.set('QEMU_BUILD_ROOT', meson.project_build_root())
255    test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
256                               meson.current_source_dir())
257
258    foreach test : target_tests
259      testname = '@0@-@1@'.format(target_base, test)
260      testfile = 'test_' + test + '.py'
261      testpath = meson.current_source_dir() / testfile
262      teststamp = testname + '.tstamp'
263      test_precache_env = environment()
264      test_precache_env.set('QEMU_TEST_PRECACHE', meson.current_build_dir() / teststamp)
265      test_precache_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
266                                          meson.current_source_dir())
267      precache = custom_target('func-precache-' + testname,
268                               output: teststamp,
269                               command: [python, testpath],
270                               depend_files: files(testpath),
271                               build_by_default: false,
272                               env: test_precache_env)
273      precache_all += precache
274
275      # Ideally we would add 'precache' to 'depends' here, such that
276      # 'build_by_default: false' lets the pre-caching automatically
277      # run immediately before the test runs. In practice this is
278      # broken in meson, with it running the pre-caching in the normal
279      # compile phase https://github.com/mesonbuild/meson/issues/2518
280      # If the above bug ever gets fixed, when QEMU changes the min
281      # meson version, add the 'depends' and remove the custom
282      # 'run_target' logic below & in Makefile.include
283      test('func-' + testname,
284           python,
285           depends: [test_deps, test_emulator, emulator_modules],
286           env: test_env,
287           args: [testpath],
288           protocol: 'tap',
289           timeout: test_timeouts.get(test, 90),
290           priority: test_timeouts.get(test, 90),
291           suite: suites)
292    endforeach
293  endforeach
294endforeach
295
296run_target('precache-functional',
297           depends: precache_all,
298           command: ['true'])
299