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