xref: /openbmc/qemu/tests/functional/meson.build (revision 05caa062)
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_s390x_system_thorough = [
83  's390x_ccw_virtio',
84  's390x_topology',
85]
86
87tests_sparc64_system_thorough = [
88  'sparc64_sun4u',
89]
90
91tests_x86_64_system_quick = [
92  'cpu_queries',
93  'mem_addr_space',
94  'pc_cpu_hotplug_props',
95  'virtio_version',
96  'x86_cpu_model_versions',
97]
98
99tests_x86_64_system_thorough = [
100  'acpi_bits',
101  'netdev_ethtool',
102  'virtio_gpu',
103]
104
105precache_all = []
106foreach speed : ['quick', 'thorough']
107  foreach dir : target_dirs
108
109    target_base = dir.split('-')[0]
110
111    if dir.endswith('-softmmu')
112      sysmode = 'system'
113      test_emulator = emulators['qemu-system-' + target_base]
114    elif dir.endswith('-linux-user')
115      sysmode = 'linuxuser'
116      test_emulator = emulators['qemu-' + target_base]
117    elif dir.endswith('-bsd-user')
118      sysmode = 'bsduser'
119      test_emulator = emulators['qemu-' + target_base]
120    else
121      continue
122    endif
123
124    if speed == 'quick'
125      suites = ['func-quick', 'func-' + target_base]
126      target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_quick', []) \
127                     + get_variable('tests_generic_' + sysmode)
128    else
129      suites = ['func-' + speed, 'func-' + target_base + '-' + speed, speed]
130      target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_' + speed, [])
131    endif
132
133    test_deps = roms
134    test_env = environment()
135    if have_tools
136      test_env.set('QEMU_TEST_QEMU_IMG', meson.global_build_root() / 'qemu-img')
137      test_deps += [qemu_img]
138    endif
139    test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path())
140    test_env.set('QEMU_BUILD_ROOT', meson.project_build_root())
141    test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
142                               meson.current_source_dir())
143
144    foreach test : target_tests
145      testname = '@0@-@1@'.format(target_base, test)
146      testfile = 'test_' + test + '.py'
147      testpath = meson.current_source_dir() / testfile
148      teststamp = testname + '.tstamp'
149      test_precache_env = environment()
150      test_precache_env.set('QEMU_TEST_PRECACHE', meson.current_build_dir() / teststamp)
151      test_precache_env.set('PYTHONPATH', meson.project_source_root() / 'python:' +
152                                          meson.current_source_dir())
153      precache = custom_target('func-precache-' + testname,
154                               output: teststamp,
155                               command: [python, testpath],
156                               depend_files: files(testpath),
157                               build_by_default: false,
158                               env: test_precache_env)
159      precache_all += precache
160
161      # Ideally we would add 'precache' to 'depends' here, such that
162      # 'build_by_default: false' lets the pre-caching automatically
163      # run immediately before the test runs. In practice this is
164      # broken in meson, with it running the pre-caching in the normal
165      # compile phase https://github.com/mesonbuild/meson/issues/2518
166      # If the above bug ever gets fixed, when QEMU changes the min
167      # meson version, add the 'depends' and remove the custom
168      # 'run_target' logic below & in Makefile.include
169      test('func-' + testname,
170           python,
171           depends: [test_deps, test_emulator, emulator_modules],
172           env: test_env,
173           args: [testpath],
174           protocol: 'tap',
175           timeout: test_timeouts.get(test, 60),
176           priority: test_timeouts.get(test, 60),
177           suite: suites)
178    endforeach
179  endforeach
180endforeach
181
182run_target('precache-functional',
183           depends: precache_all,
184           command: ['true'])
185