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