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