xref: /openbmc/qemu/tests/functional/meson.build (revision 8d3031fa)
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' : 120,
15  'aarch64_sbsaref' : 600,
16  'aarch64_virt' : 360,
17  'acpi_bits' : 240,
18  'arm_raspi2' : 120,
19  'mips_malta' : 120,
20  'netdev_ethtool' : 180,
21  'ppc_40p' : 240,
22  'ppc64_hv' : 1000,
23  'ppc64_powernv' : 240,
24  'ppc64_pseries' : 240,
25  's390x_ccw_virtio' : 240,
26}
27
28tests_generic_system = [
29  'empty_cpu_model',
30  'info_usernet',
31  'version',
32]
33
34tests_generic_linuxuser = [
35]
36
37tests_generic_bsduser = [
38]
39
40tests_aarch64_system_thorough = [
41  'aarch64_raspi3',
42  'aarch64_raspi4',
43  'aarch64_sbsaref',
44  'aarch64_virt',
45  'multiprocess',
46]
47
48tests_alpha_system_thorough = [
49  'alpha_clipper',
50]
51
52tests_arm_system_thorough = [
53  'arm_canona1100',
54  'arm_integratorcp',
55  'arm_raspi2',
56  'arm_vexpress',
57]
58
59tests_arm_linuxuser_thorough = [
60  'arm_bflt',
61]
62
63tests_avr_system_thorough = [
64  'avr_mega2560',
65]
66
67tests_loongarch64_system_thorough = [
68  'loongarch64_virt',
69]
70
71tests_m68k_system_thorough = [
72  'm68k_mcf5208evb',
73  'm68k_nextcube',
74  'm68k_q800',
75]
76
77tests_microblaze_system_thorough = [
78  'microblaze_s3adsp1800'
79]
80
81tests_microblazeel_system_thorough = [
82  'microblazeel_s3adsp1800'
83]
84
85tests_mips_system_thorough = [
86  'mips_malta',
87]
88
89tests_mipsel_system_thorough = [
90  'mipsel_malta',
91]
92
93tests_mips64el_system_thorough = [
94  'mips64el_fuloong2e',
95  'mips64el_loongson3v',
96  'mips64el_malta',
97]
98
99tests_or1k_system_thorough = [
100  'or1k_sim',
101]
102
103tests_ppc_system_quick = [
104  'ppc_74xx',
105]
106
107tests_ppc_system_thorough = [
108  'ppc_405',
109  'ppc_40p',
110  'ppc_amiga',
111  'ppc_bamboo',
112  'ppc_mac',
113  'ppc_mpc8544ds',
114  'ppc_virtex_ml507',
115]
116
117tests_ppc64_system_thorough = [
118  'ppc64_e500',
119  'ppc64_hv',
120  'ppc64_powernv',
121  'ppc64_pseries',
122]
123
124tests_rx_system_thorough = [
125  'rx_gdbsim',
126]
127
128tests_s390x_system_thorough = [
129  's390x_ccw_virtio',
130  's390x_topology',
131]
132
133tests_sh4_system_thorough = [
134  'sh4_r2d',
135]
136
137tests_sparc_system_thorough = [
138  'sparc_sun4m',
139]
140
141tests_sparc64_system_thorough = [
142  'sparc64_sun4u',
143]
144
145tests_x86_64_system_quick = [
146  'cpu_queries',
147  'mem_addr_space',
148  'pc_cpu_hotplug_props',
149  'virtio_version',
150  'x86_cpu_model_versions',
151]
152
153tests_x86_64_system_thorough = [
154  'acpi_bits',
155  'linux_initrd',
156  'multiprocess',
157  'netdev_ethtool',
158  'virtio_gpu',
159]
160
161tests_xtensa_system_thorough = [
162  'xtensa_lx60',
163]
164
165precache_all = []
166foreach speed : ['quick', 'thorough']
167  foreach dir : target_dirs
168
169    target_base = dir.split('-')[0]
170
171    if dir.endswith('-softmmu')
172      sysmode = 'system'
173      test_emulator = emulators['qemu-system-' + target_base]
174    elif dir.endswith('-linux-user')
175      sysmode = 'linuxuser'
176      test_emulator = emulators['qemu-' + target_base]
177    elif dir.endswith('-bsd-user')
178      sysmode = 'bsduser'
179      test_emulator = emulators['qemu-' + target_base]
180    else
181      continue
182    endif
183
184    if speed == 'quick'
185      suites = ['func-quick', 'func-' + target_base]
186      target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_quick', []) \
187                     + get_variable('tests_generic_' + sysmode)
188    else
189      suites = ['func-' + speed, 'func-' + target_base + '-' + speed, speed]
190      target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_' + speed, [])
191    endif
192
193    test_deps = roms
194    test_env = environment()
195    if have_tools
196      test_env.set('QEMU_TEST_QEMU_IMG', meson.global_build_root() / 'qemu-img')
197      test_deps += [qemu_img]
198    endif
199    test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path())
200    test_env.set('QEMU_BUILD_ROOT', meson.project_build_root())
201    test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
202                               meson.current_source_dir())
203
204    foreach test : target_tests
205      testname = '@0@-@1@'.format(target_base, test)
206      testfile = 'test_' + test + '.py'
207      testpath = meson.current_source_dir() / testfile
208      teststamp = testname + '.tstamp'
209      test_precache_env = environment()
210      test_precache_env.set('QEMU_TEST_PRECACHE', meson.current_build_dir() / teststamp)
211      test_precache_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
212                                          meson.current_source_dir())
213      precache = custom_target('func-precache-' + testname,
214                               output: teststamp,
215                               command: [python, testpath],
216                               depend_files: files(testpath),
217                               build_by_default: false,
218                               env: test_precache_env)
219      precache_all += precache
220
221      # Ideally we would add 'precache' to 'depends' here, such that
222      # 'build_by_default: false' lets the pre-caching automatically
223      # run immediately before the test runs. In practice this is
224      # broken in meson, with it running the pre-caching in the normal
225      # compile phase https://github.com/mesonbuild/meson/issues/2518
226      # If the above bug ever gets fixed, when QEMU changes the min
227      # meson version, add the 'depends' and remove the custom
228      # 'run_target' logic below & in Makefile.include
229      test('func-' + testname,
230           python,
231           depends: [test_deps, test_emulator, emulator_modules],
232           env: test_env,
233           args: [testpath],
234           protocol: 'tap',
235           timeout: test_timeouts.get(test, 60),
236           priority: test_timeouts.get(test, 60),
237           suite: suites)
238    endforeach
239  endforeach
240endforeach
241
242run_target('precache-functional',
243           depends: precache_all,
244           command: ['true'])
245