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