xref: /openbmc/qemu/tests/qtest/meson.build (revision 8cf1da729170b7cc47ebaca46912a4f37675dc95)
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']
198qtests_arm = \
199  (config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \
200  (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \
201  (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
202  (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \
203  (config_all_devices.has_key('CONFIG_PFLASH_CFI02') and
204   config_all_devices.has_key('CONFIG_MUSICPAL') ? ['pflash-cfi02-test'] : []) + \
205  (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed : []) + \
206  (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
207  (config_all_devices.has_key('CONFIG_GENERIC_LOADER') ? ['hexloader-test'] : []) + \
208  (config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
209  (config_all_devices.has_key('CONFIG_VEXPRESS') ? ['test-arm-mptimer'] : []) + \
210  (config_all_devices.has_key('CONFIG_MICROBIT') ? ['microbit-test'] : []) + \
211  ['arm-cpu-features',
212   'boot-serial-test']
213
214# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
215qtests_aarch64 = \
216  (cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) +                            \
217  (config_all_accel.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ?            \
218    ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) +                                         \
219  (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
220  (config_all_devices.has_key('CONFIG_XLNX_VERSAL') ? ['xlnx-canfd-test', 'xlnx-versal-trng-test'] : []) + \
221  (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) +  \
222  (config_all_accel.has_key('CONFIG_TCG') and                                            \
223   config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
224  ['arm-cpu-features',
225   'numa-test',
226   'boot-serial-test',
227   'migration-test']
228
229qtests_s390x = \
230  qtests_filter + \
231  ['boot-serial-test',
232   'drive_del-test',
233   'device-plug-test',
234   'virtio-ccw-test',
235   'cpu-plug-test',
236   'migration-test']
237
238qtests_riscv32 = \
239  (config_all_devices.has_key('CONFIG_SIFIVE_E_AON') ? ['sifive-e-aon-watchdog-test'] : [])
240
241qos_test_ss = ss.source_set()
242qos_test_ss.add(
243  'ac97-test.c',
244  'adm1272-test.c',
245  'adm1266-test.c',
246  'ds1338-test.c',
247  'e1000-test.c',
248  'eepro100-test.c',
249  'es1370-test.c',
250  'ipoctal232-test.c',
251  'lsm303dlhc-mag-test.c',
252  'isl_pmbus_vr-test.c',
253  'max34451-test.c',
254  'megasas-test.c',
255  'ne2000-test.c',
256  'tulip-test.c',
257  'nvme-test.c',
258  'pca9552-test.c',
259  'pci-test.c',
260  'pcnet-test.c',
261  'sdhci-test.c',
262  'spapr-phb-test.c',
263  'tmp105-test.c',
264  'emc141x-test.c',
265  'usb-hcd-ohci-test.c',
266  'virtio-test.c',
267  'virtio-blk-test.c',
268  'virtio-net-test.c',
269  'virtio-rng-test.c',
270  'virtio-scsi-test.c',
271  'virtio-iommu-test.c',
272  'vmxnet3-test.c',
273  'igb-test.c',
274  'ufs-test.c',
275)
276
277if config_all_devices.has_key('CONFIG_VIRTIO_SERIAL')
278  qos_test_ss.add(files('virtio-serial-test.c'))
279endif
280
281if host_os != 'windows'
282  qos_test_ss.add(files('e1000e-test.c'))
283endif
284if have_virtfs
285  qos_test_ss.add(files('virtio-9p-test.c'))
286endif
287if have_vhost_user
288  qos_test_ss.add(files('vhost-user-test.c'))
289endif
290if have_tools and have_vhost_user_blk_server
291  qos_test_ss.add(files('vhost-user-blk-test.c'))
292endif
293
294tpmemu_files = ['tpm-emu.c', 'tpm-util.c', 'tpm-tests.c']
295
296migration_files = [files('migration-helpers.c')]
297if gnutls.found()
298  migration_files += [files('../unit/crypto-tls-psk-helpers.c'), gnutls]
299
300  if tasn1.found()
301    migration_files += [files('../unit/crypto-tls-x509-helpers.c',
302                              '../unit/pkix_asn1_tab.c'), tasn1]
303  endif
304endif
305
306qtests = {
307  'bios-tables-test': [io, 'boot-sector.c', 'acpi-utils.c', 'tpm-emu.c'],
308  'cdrom-test': files('boot-sector.c'),
309  'dbus-vmstate-test': files('migration-helpers.c') + dbus_vmstate1,
310  'erst-test': files('erst-test.c'),
311  'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'],
312  'migration-test': migration_files,
313  'pxe-test': files('boot-sector.c'),
314  'qos-test': [chardev, io, qos_test_ss.apply({}).sources()],
315  'tpm-crb-swtpm-test': [io, tpmemu_files],
316  'tpm-crb-test': [io, tpmemu_files],
317  'tpm-tis-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'],
318  'tpm-tis-test': [io, tpmemu_files, 'tpm-tis-util.c'],
319  'tpm-tis-i2c-test': [io, tpmemu_files, 'qtest_aspeed.c'],
320  'tpm-tis-device-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'],
321  'tpm-tis-device-test': [io, tpmemu_files, 'tpm-tis-util.c'],
322  'virtio-net-failover': files('migration-helpers.c'),
323  'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'),
324  'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'),
325}
326
327if vnc.found()
328  gvnc = dependency('gvnc-1.0', method: 'pkg-config', required: false)
329  if gvnc.found()
330    qtests += {'vnc-display-test': [gvnc]}
331    qtests_generic += [ 'vnc-display-test' ]
332  endif
333endif
334
335if dbus_display
336  qtests += {'dbus-display-test': [dbus_display1, gio]}
337endif
338
339qtest_executables = {}
340foreach dir : target_dirs
341  if not dir.endswith('-softmmu')
342    continue
343  endif
344
345  target_base = dir.split('-')[0]
346  qtest_emulator = emulators['qemu-system-' + target_base]
347  target_qtests = get_variable('qtests_' + target_base, []) + qtests_generic
348
349  test_deps = roms
350  qtest_env = environment()
351  if have_tools
352    qtest_env.set('QTEST_QEMU_IMG', './qemu-img')
353    test_deps += [qemu_img]
354  endif
355  qtest_env.set('G_TEST_DBUS_DAEMON', meson.project_source_root() / 'tests/dbus-vmstate-daemon.sh')
356  qtest_env.set('QTEST_QEMU_BINARY', './qemu-system-' + target_base)
357  if have_tools and have_vhost_user_blk_server
358    qtest_env.set('QTEST_QEMU_STORAGE_DAEMON_BINARY', './storage-daemon/qemu-storage-daemon')
359    test_deps += [qsd]
360  endif
361
362  qtest_env.set('PYTHON', python.full_path())
363
364  foreach test : target_qtests
365    # Executables are shared across targets, declare them only the first time we
366    # encounter them
367    if not qtest_executables.has_key(test)
368      src = [test + '.c']
369      deps = [qemuutil, qos]
370      if test in qtests
371        # use a sourceset to quickly separate sources and deps
372        test_ss = ss.source_set()
373        test_ss.add(qtests[test])
374        src += test_ss.all_sources()
375        deps += test_ss.all_dependencies()
376      endif
377      qtest_executables += {
378        test: executable(test, src, dependencies: deps)
379      }
380    endif
381    test('qtest-@0@/@1@'.format(target_base, test),
382         qtest_executables[test],
383         depends: [test_deps, qtest_emulator, emulator_modules],
384         env: qtest_env,
385         args: ['--tap', '-k'],
386         protocol: 'tap',
387         timeout: slow_qtests.get(test, 60),
388         priority: slow_qtests.get(test, 60),
389         suite: ['qtest', 'qtest-' + target_base])
390  endforeach
391endforeach
392