xref: /openbmc/qemu/tests/functional/meson.build (revision d8d5ca40)
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_thorough = [
90  'mips64el_fuloong2e',
91  'mips64el_loongson3v',
92  'mips64el_malta',
93]
94
95tests_or1k_system_quick = [
96  'or1k_sim',
97]
98
99tests_ppc_system_quick = [
100  'ppc_74xx',
101]
102
103tests_ppc_system_thorough = [
104  'ppc_405',
105  'ppc_40p',
106  'ppc_amiga',
107  'ppc_bamboo',
108  'ppc_mpc8544ds',
109  'ppc_virtex_ml507',
110]
111
112tests_ppc64_system_thorough = [
113  'ppc64_hv',
114  'ppc64_powernv',
115  'ppc64_pseries',
116]
117
118tests_rx_system_thorough = [
119  'rx_gdbsim',
120]
121
122tests_s390x_system_thorough = [
123  's390x_ccw_virtio',
124  's390x_topology',
125]
126
127tests_sparc64_system_thorough = [
128  'sparc64_sun4u',
129]
130
131tests_x86_64_system_quick = [
132  'cpu_queries',
133  'mem_addr_space',
134  'pc_cpu_hotplug_props',
135  'virtio_version',
136  'x86_cpu_model_versions',
137]
138
139tests_x86_64_system_thorough = [
140  'acpi_bits',
141  'linux_initrd',
142  'multiprocess',
143  'netdev_ethtool',
144  'virtio_gpu',
145]
146
147precache_all = []
148foreach speed : ['quick', 'thorough']
149  foreach dir : target_dirs
150
151    target_base = dir.split('-')[0]
152
153    if dir.endswith('-softmmu')
154      sysmode = 'system'
155      test_emulator = emulators['qemu-system-' + target_base]
156    elif dir.endswith('-linux-user')
157      sysmode = 'linuxuser'
158      test_emulator = emulators['qemu-' + target_base]
159    elif dir.endswith('-bsd-user')
160      sysmode = 'bsduser'
161      test_emulator = emulators['qemu-' + target_base]
162    else
163      continue
164    endif
165
166    if speed == 'quick'
167      suites = ['func-quick', 'func-' + target_base]
168      target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_quick', []) \
169                     + get_variable('tests_generic_' + sysmode)
170    else
171      suites = ['func-' + speed, 'func-' + target_base + '-' + speed, speed]
172      target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_' + speed, [])
173    endif
174
175    test_deps = roms
176    test_env = environment()
177    if have_tools
178      test_env.set('QEMU_TEST_QEMU_IMG', meson.global_build_root() / 'qemu-img')
179      test_deps += [qemu_img]
180    endif
181    test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path())
182    test_env.set('QEMU_BUILD_ROOT', meson.project_build_root())
183    test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
184                               meson.current_source_dir())
185
186    foreach test : target_tests
187      testname = '@0@-@1@'.format(target_base, test)
188      testfile = 'test_' + test + '.py'
189      testpath = meson.current_source_dir() / testfile
190      teststamp = testname + '.tstamp'
191      test_precache_env = environment()
192      test_precache_env.set('QEMU_TEST_PRECACHE', meson.current_build_dir() / teststamp)
193      test_precache_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
194                                          meson.current_source_dir())
195      precache = custom_target('func-precache-' + testname,
196                               output: teststamp,
197                               command: [python, testpath],
198                               depend_files: files(testpath),
199                               build_by_default: false,
200                               env: test_precache_env)
201      precache_all += precache
202
203      # Ideally we would add 'precache' to 'depends' here, such that
204      # 'build_by_default: false' lets the pre-caching automatically
205      # run immediately before the test runs. In practice this is
206      # broken in meson, with it running the pre-caching in the normal
207      # compile phase https://github.com/mesonbuild/meson/issues/2518
208      # If the above bug ever gets fixed, when QEMU changes the min
209      # meson version, add the 'depends' and remove the custom
210      # 'run_target' logic below & in Makefile.include
211      test('func-' + testname,
212           python,
213           depends: [test_deps, test_emulator, emulator_modules],
214           env: test_env,
215           args: [testpath],
216           protocol: 'tap',
217           timeout: test_timeouts.get(test, 60),
218           priority: test_timeouts.get(test, 60),
219           suite: suites)
220    endforeach
221  endforeach
222endforeach
223
224run_target('precache-functional',
225           depends: precache_all,
226           command: ['true'])
227