xref: /qemu/tests/qtest/meson.build (revision d67611907590a1e6c998b7c5a5cb4394acf84329)
1 slow_qtests = {
2   'aspeed_smc-test': 360,
3   'bios-tables-test' : 610,
4   'cdrom-test' : 610,
5   'device-introspect-test' : 720,
6   'migration-test' : 480,
7   'npcm7xx_pwm-test': 300,
8   'npcm7xx_watchdog_timer-test': 120,
9   'qom-test' : 900,
10   'test-hmp' : 240,
11   'pxe-test': 610,
12   'prom-env-test': 360,
13   'boot-serial-test': 360,
14   'qos-test': 120,
15   'vmgenid-test': 610,
16 }
17 
18 qtests_generic = [
19   'cdrom-test',
20   'device-introspect-test',
21   'machine-none-test',
22   'qmp-test',
23   'qmp-cmd-test',
24   'qom-test',
25   'test-hmp',
26   'qos-test',
27   'readconfig-test',
28   'netdev-socket',
29 ]
30 if enable_modules
31   qtests_generic += [ 'modules-test' ]
32 endif
33 
34 qtests_pci = \
35   (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) +                  \
36   (config_all_devices.has_key('CONFIG_IVSHMEM_DEVICE') ? ['ivshmem-test'] : [])
37 
38 qtests_cxl = \
39   (config_all_devices.has_key('CONFIG_CXL') ? ['cxl-test'] : [])
40 
41 # FIXME: Get rid of get_option('default_devices') here and check
42 #        for the availability of the default NICs in the tests
43 qtests_filter = \
44   (get_option('default_devices') and slirp.found() ? ['test-netfilter'] : []) + \
45   (get_option('default_devices') and host_os != 'windows' ? ['test-filter-mirror'] : []) + \
46   (get_option('default_devices') and host_os != 'windows' ? ['test-filter-redirector'] : [])
47 
48 qtests_i386 = \
49   (slirp.found() ? ['pxe-test'] : []) + \
50   qtests_filter + \
51   (have_tools ? ['ahci-test'] : []) +                                                       \
52   (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) +           \
53   (config_all_devices.has_key('CONFIG_SGA') ? ['boot-serial-test'] : []) +                  \
54   (config_all_devices.has_key('CONFIG_ISA_IPMI_KCS') ? ['ipmi-kcs-test'] : []) +            \
55   (host_os == 'linux' and                                                                  \
56    config_all_devices.has_key('CONFIG_ISA_IPMI_BT') and
57    config_all_devices.has_key('CONFIG_IPMI_EXTERN') ? ['ipmi-bt-test'] : []) +              \
58   (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) +              \
59   (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) +              \
60   (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) +          \
61   (config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) +                    \
62   (config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) +             \
63   (config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) +                  \
64   (config_all_devices.has_key('CONFIG_LPC_ICH9') ? ['lpc-ich9-test'] : []) +              \
65   (config_all_devices.has_key('CONFIG_USB_UHCI') ? ['usb-hcd-uhci-test'] : []) +            \
66   (config_all_devices.has_key('CONFIG_USB_UHCI') and                                        \
67    config_all_devices.has_key('CONFIG_USB_EHCI') ? ['usb-hcd-ehci-test'] : []) +            \
68   (config_all_devices.has_key('CONFIG_USB_XHCI_NEC') ? ['usb-hcd-xhci-test'] : []) +        \
69   (config_all_devices.has_key('CONFIG_TPM_CRB') ? ['tpm-crb-test'] : []) +                  \
70   (config_all_devices.has_key('CONFIG_TPM_CRB') ? ['tpm-crb-swtpm-test'] : []) +            \
71   (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-test'] : []) +              \
72   (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-swtpm-test'] : []) +        \
73   (config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['rtl8139-test'] : []) +              \
74   (config_all_devices.has_key('CONFIG_E1000E_PCI_EXPRESS') ? ['fuzz-e1000e-test'] : []) +   \
75   (config_all_devices.has_key('CONFIG_MEGASAS_SCSI_PCI') ? ['fuzz-megasas-test'] : []) +    \
76   (config_all_devices.has_key('CONFIG_LSI_SCSI_PCI') ? ['fuzz-lsi53c895a-test'] : []) +     \
77   (config_all_devices.has_key('CONFIG_VIRTIO_SCSI') ? ['fuzz-virtio-scsi-test'] : []) +     \
78   (config_all_devices.has_key('CONFIG_SB16') ? ['fuzz-sb16-test'] : []) +                   \
79   (config_all_devices.has_key('CONFIG_SDHCI_PCI') ? ['fuzz-sdcard-test'] : []) +            \
80   (config_all_devices.has_key('CONFIG_ESP_PCI') ? ['am53c974-test'] : []) +                 \
81   (host_os != 'windows' and                                                                \
82    config_all_devices.has_key('CONFIG_ACPI_ERST') ? ['erst-test'] : []) +                   \
83   (config_all_devices.has_key('CONFIG_PCIE_PORT') and                                       \
84    config_all_devices.has_key('CONFIG_VIRTIO_NET') and                                      \
85    config_all_devices.has_key('CONFIG_Q35') and                                             \
86    config_all_devices.has_key('CONFIG_VIRTIO_PCI') and                                      \
87    slirp.found() ? ['virtio-net-failover'] : []) +                                          \
88   (unpack_edk2_blobs and                                                                    \
89    config_all_devices.has_key('CONFIG_HPET') and                                            \
90    config_all_devices.has_key('CONFIG_PARALLEL') ? ['bios-tables-test'] : []) +             \
91   qtests_pci +                                                                              \
92   qtests_cxl +                                                                              \
93   ['fdc-test',
94    'ide-test',
95    'hd-geo-test',
96    'boot-order-test',
97    'rtc-test',
98    'i440fx-test',
99    'fw_cfg-test',
100    'device-plug-test',
101    'drive_del-test',
102    'tco-test',
103    'cpu-plug-test',
104    'q35-test',
105    'vmgenid-test',
106    'migration-test',
107    'test-x86-cpuid-compat',
108    'numa-test'
109   ]
110 
111 if dbus_display
112   qtests_i386 += ['dbus-display-test']
113 endif
114 
115 dbus_daemon = find_program('dbus-daemon', required: false)
116 if dbus_daemon.found() and gdbus_codegen.found()
117   # Temporarily disabled due to Patchew failures:
118   #qtests_i386 += ['dbus-vmstate-test']
119   dbus_vmstate1 = custom_target('dbus-vmstate description',
120                                 output: ['dbus-vmstate1.h', 'dbus-vmstate1.c'],
121                                 input: meson.project_source_root() / 'backends/dbus-vmstate1.xml',
122                                 command: [gdbus_codegen, '@INPUT@',
123                                           '--interface-prefix', 'org.qemu',
124                                           '--generate-c-code', '@BASENAME@']).to_list()
125 else
126   dbus_vmstate1 = []
127 endif
128 
129 qtests_x86_64 = qtests_i386
130 
131 qtests_alpha = ['boot-serial-test'] + \
132   qtests_filter + \
133   (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
134 
135 qtests_avr = [ 'boot-serial-test' ]
136 
137 qtests_hppa = ['boot-serial-test'] + \
138   qtests_filter + \
139   (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
140 
141 qtests_m68k = ['boot-serial-test'] + \
142   qtests_filter
143 
144 qtests_microblaze = ['boot-serial-test'] + \
145   qtests_filter
146 
147 qtests_microblazeel = qtests_microblaze
148 
149 qtests_mips = \
150   qtests_filter + \
151   (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) +            \
152   (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
153 
154 qtests_mipsel = qtests_mips
155 qtests_mips64 = qtests_mips
156 qtests_mips64el = qtests_mips
157 
158 qtests_ppc = \
159   qtests_filter + \
160   (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) +            \
161   (config_all_devices.has_key('CONFIG_M48T59') ? ['m48t59-test'] : []) +                     \
162   (config_all_accel.has_key('CONFIG_TCG') ? ['prom-env-test'] : []) +                              \
163   (config_all_accel.has_key('CONFIG_TCG') ? ['boot-serial-test'] : []) +                           \
164   ['boot-order-test']
165 
166 qtests_ppc64 = \
167   qtests_ppc + \
168   (config_all_devices.has_key('CONFIG_PSERIES') ? ['device-plug-test'] : []) +               \
169   (config_all_devices.has_key('CONFIG_POWERNV') ? ['pnv-xscom-test'] : []) +                 \
170   (config_all_devices.has_key('CONFIG_PSERIES') ? ['rtas-test'] : []) +                      \
171   (slirp.found() ? ['pxe-test'] : []) +              \
172   (config_all_devices.has_key('CONFIG_USB_UHCI') ? ['usb-hcd-uhci-test'] : []) +             \
173   (config_all_devices.has_key('CONFIG_USB_XHCI_NEC') ? ['usb-hcd-xhci-test'] : []) +         \
174   qtests_pci + ['migration-test', 'numa-test', 'cpu-plug-test', 'drive_del-test']
175 
176 qtests_sh4 = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : [])
177 qtests_sh4eb = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : [])
178 
179 qtests_sparc = ['prom-env-test', 'm48t59-test', 'boot-serial-test'] + \
180   qtests_filter
181 
182 qtests_sparc64 = \
183   (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) +            \
184   qtests_filter + \
185   ['prom-env-test', 'boot-serial-test']
186 
187 qtests_npcm7xx = \
188   ['npcm7xx_adc-test',
189    'npcm7xx_gpio-test',
190    'npcm7xx_pwm-test',
191    'npcm7xx_rng-test',
192    'npcm7xx_sdhci-test',
193    'npcm7xx_smbus-test',
194    'npcm7xx_timer-test',
195    'npcm7xx_watchdog_timer-test',
196    'npcm_gmac-test'] + \
197    (slirp.found() ? ['npcm7xx_emc-test'] : [])
198 qtests_aspeed = \
199   ['aspeed_hace-test',
200    'aspeed_smc-test',
201    'aspeed_gpio-test']
202 
203 qtests_stm32l4x5 = \
204   ['stm32l4x5_exti-test',
205    'stm32l4x5_syscfg-test']
206 
207 qtests_arm = \
208   (config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \
209   (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \
210   (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
211   (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \
212   (config_all_devices.has_key('CONFIG_PFLASH_CFI02') and
213    config_all_devices.has_key('CONFIG_MUSICPAL') ? ['pflash-cfi02-test'] : []) + \
214   (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed : []) + \
215   (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
216   (config_all_devices.has_key('CONFIG_GENERIC_LOADER') ? ['hexloader-test'] : []) + \
217   (config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
218   (config_all_devices.has_key('CONFIG_VEXPRESS') ? ['test-arm-mptimer'] : []) + \
219   (config_all_devices.has_key('CONFIG_MICROBIT') ? ['microbit-test'] : []) + \
220   (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') ? qtests_stm32l4x5 : []) + \
221   (config_all_devices.has_key('CONFIG_FSI_APB2OPB_ASPEED') ? ['aspeed_fsi-test'] : []) + \
222   ['arm-cpu-features',
223    'boot-serial-test']
224 
225 # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
226 qtests_aarch64 = \
227   (cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) +                            \
228   (config_all_accel.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ?            \
229     ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) +                                         \
230   (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
231   (config_all_devices.has_key('CONFIG_XLNX_VERSAL') ? ['xlnx-canfd-test', 'xlnx-versal-trng-test'] : []) + \
232   (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) +  \
233   (config_all_accel.has_key('CONFIG_TCG') and                                            \
234    config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
235   ['arm-cpu-features',
236    'numa-test',
237    'boot-serial-test',
238    'migration-test']
239 
240 qtests_s390x = \
241   qtests_filter + \
242   ['boot-serial-test',
243    'drive_del-test',
244    'device-plug-test',
245    'virtio-ccw-test',
246    'cpu-plug-test',
247    'migration-test']
248 
249 qtests_riscv32 = \
250   (config_all_devices.has_key('CONFIG_SIFIVE_E_AON') ? ['sifive-e-aon-watchdog-test'] : [])
251 
252 qos_test_ss = ss.source_set()
253 qos_test_ss.add(
254   'ac97-test.c',
255   'adm1272-test.c',
256   'adm1266-test.c',
257   'ds1338-test.c',
258   'e1000-test.c',
259   'eepro100-test.c',
260   'es1370-test.c',
261   'ipoctal232-test.c',
262   'lsm303dlhc-mag-test.c',
263   'isl_pmbus_vr-test.c',
264   'max34451-test.c',
265   'megasas-test.c',
266   'ne2000-test.c',
267   'tulip-test.c',
268   'nvme-test.c',
269   'pca9552-test.c',
270   'pci-test.c',
271   'pcnet-test.c',
272   'sdhci-test.c',
273   'spapr-phb-test.c',
274   'tmp105-test.c',
275   'emc141x-test.c',
276   'usb-hcd-ohci-test.c',
277   'virtio-test.c',
278   'virtio-blk-test.c',
279   'virtio-net-test.c',
280   'virtio-rng-test.c',
281   'virtio-scsi-test.c',
282   'virtio-iommu-test.c',
283   'vmxnet3-test.c',
284   'igb-test.c',
285   'ufs-test.c',
286 )
287 
288 if config_all_devices.has_key('CONFIG_VIRTIO_SERIAL')
289   qos_test_ss.add(files('virtio-serial-test.c'))
290 endif
291 
292 if host_os != 'windows'
293   qos_test_ss.add(files('e1000e-test.c'))
294 endif
295 if have_virtfs
296   qos_test_ss.add(files('virtio-9p-test.c'))
297 endif
298 if have_vhost_user
299   qos_test_ss.add(files('vhost-user-test.c'))
300 endif
301 if have_tools and have_vhost_user_blk_server
302   qos_test_ss.add(files('vhost-user-blk-test.c'))
303 endif
304 
305 tpmemu_files = ['tpm-emu.c', 'tpm-util.c', 'tpm-tests.c']
306 
307 migration_files = [files('migration-helpers.c')]
308 if gnutls.found()
309   migration_files += [files('../unit/crypto-tls-psk-helpers.c'), gnutls]
310 
311   if tasn1.found()
312     migration_files += [files('../unit/crypto-tls-x509-helpers.c',
313                               '../unit/pkix_asn1_tab.c'), tasn1]
314   endif
315 endif
316 
317 qtests = {
318   'bios-tables-test': [io, 'boot-sector.c', 'acpi-utils.c', 'tpm-emu.c'],
319   'cdrom-test': files('boot-sector.c'),
320   'dbus-vmstate-test': files('migration-helpers.c') + dbus_vmstate1,
321   'erst-test': files('erst-test.c'),
322   'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'],
323   'migration-test': migration_files,
324   'pxe-test': files('boot-sector.c'),
325   'qos-test': [chardev, io, qos_test_ss.apply({}).sources()],
326   'tpm-crb-swtpm-test': [io, tpmemu_files],
327   'tpm-crb-test': [io, tpmemu_files],
328   'tpm-tis-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'],
329   'tpm-tis-test': [io, tpmemu_files, 'tpm-tis-util.c'],
330   'tpm-tis-i2c-test': [io, tpmemu_files, 'qtest_aspeed.c'],
331   'tpm-tis-device-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'],
332   'tpm-tis-device-test': [io, tpmemu_files, 'tpm-tis-util.c'],
333   'virtio-net-failover': files('migration-helpers.c'),
334   'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'),
335   'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'),
336 }
337 
338 if vnc.found()
339   gvnc = dependency('gvnc-1.0', method: 'pkg-config', required: false)
340   if gvnc.found()
341     qtests += {'vnc-display-test': [gvnc]}
342     qtests_generic += [ 'vnc-display-test' ]
343   endif
344 endif
345 
346 if dbus_display
347   qtests += {'dbus-display-test': [dbus_display1, gio]}
348 endif
349 
350 qtest_executables = {}
351 foreach dir : target_dirs
352   if not dir.endswith('-softmmu')
353     continue
354   endif
355 
356   target_base = dir.split('-')[0]
357   qtest_emulator = emulators['qemu-system-' + target_base]
358   target_qtests = get_variable('qtests_' + target_base, []) + qtests_generic
359 
360   test_deps = roms
361   qtest_env = environment()
362   if have_tools
363     qtest_env.set('QTEST_QEMU_IMG', './qemu-img')
364     test_deps += [qemu_img]
365   endif
366   qtest_env.set('G_TEST_DBUS_DAEMON', meson.project_source_root() / 'tests/dbus-vmstate-daemon.sh')
367   qtest_env.set('QTEST_QEMU_BINARY', './qemu-system-' + target_base)
368   if have_tools and have_vhost_user_blk_server
369     qtest_env.set('QTEST_QEMU_STORAGE_DAEMON_BINARY', './storage-daemon/qemu-storage-daemon')
370     test_deps += [qsd]
371   endif
372 
373   qtest_env.set('PYTHON', python.full_path())
374 
375   foreach test : target_qtests
376     # Executables are shared across targets, declare them only the first time we
377     # encounter them
378     if not qtest_executables.has_key(test)
379       src = [test + '.c']
380       deps = [qemuutil, qos]
381       if test in qtests
382         # use a sourceset to quickly separate sources and deps
383         test_ss = ss.source_set()
384         test_ss.add(qtests[test])
385         src += test_ss.all_sources()
386         deps += test_ss.all_dependencies()
387       endif
388       qtest_executables += {
389         test: executable(test, src, dependencies: deps)
390       }
391     endif
392     test('qtest-@0@/@1@'.format(target_base, test),
393          qtest_executables[test],
394          depends: [test_deps, qtest_emulator, emulator_modules],
395          env: qtest_env,
396          args: ['--tap', '-k'],
397          protocol: 'tap',
398          timeout: slow_qtests.get(test, 60),
399          priority: slow_qtests.get(test, 60),
400          suite: ['qtest', 'qtest-' + target_base])
401   endforeach
402 endforeach
403