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