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