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