114973778SThomas Huth# QEMU functional tests: 214973778SThomas Huth# Tests that are put in the 'quick' category are run by default during 314973778SThomas Huth# 'make check'. Everything that should not be run during 'make check' 414973778SThomas Huth# (e.g. tests that fetch assets from the internet) should be put into 514973778SThomas Huth# the 'thorough' category instead. 614973778SThomas Huth 714973778SThomas Huth# Most tests run too slow with TCI enabled, so skip the functional tests there 814973778SThomas Huthif get_option('tcg_interpreter') 914973778SThomas Huth subdir_done() 1014973778SThomas Huthendif 1114973778SThomas Huth 1214973778SThomas Huth# Timeouts for individual tests that can be slow e.g. with debugging enabled 1314973778SThomas Huthtest_timeouts = { 14d841f720SThomas Huth 'aarch64_raspi4' : 120, 158f16cd80SPhilippe Mathieu-Daudé 'aarch64_sbsaref' : 600, 161255f5e4SPhilippe Mathieu-Daudé 'aarch64_virt' : 360, 1705caa062SThomas Huth 'acpi_bits' : 240, 18d841f720SThomas Huth 'arm_raspi2' : 120, 19de9f57a6SThomas Huth 'arm_tuxrun' : 120, 20d841f720SThomas Huth 'mips_malta' : 120, 214c0a2df8SThomas Huth 'netdev_ethtool' : 180, 22407a6883SThomas Huth 'ppc_40p' : 240, 2388c90719SThomas Huth 'ppc64_hv' : 1000, 24d841f720SThomas Huth 'ppc64_powernv' : 240, 25d841f720SThomas Huth 'ppc64_pseries' : 240, 26d841f720SThomas Huth 's390x_ccw_virtio' : 240, 2714973778SThomas Huth} 2814973778SThomas Huth 2914973778SThomas Huthtests_generic_system = [ 30cce85725SThomas Huth 'empty_cpu_model', 31eeba3d73SThomas Huth 'info_usernet', 32eeba3d73SThomas Huth 'version', 33eeba3d73SThomas Huth] 34eeba3d73SThomas Huth 3514973778SThomas Huthtests_generic_linuxuser = [ 3614973778SThomas Huth] 3714973778SThomas Huth 3814973778SThomas Huthtests_generic_bsduser = [ 3914973778SThomas Huth] 4014973778SThomas Huth 418f16cd80SPhilippe Mathieu-Daudétests_aarch64_system_thorough = [ 42471f7ff7SPhilippe Mathieu-Daudé 'aarch64_raspi3', 43547738beSPhilippe Mathieu-Daudé 'aarch64_raspi4', 448f16cd80SPhilippe Mathieu-Daudé 'aarch64_sbsaref', 451255f5e4SPhilippe Mathieu-Daudé 'aarch64_virt', 4669e4fbd0SThomas Huth 'multiprocess', 478f16cd80SPhilippe Mathieu-Daudé] 488f16cd80SPhilippe Mathieu-Daudé 499a76bc04SThomas Huthtests_alpha_system_thorough = [ 509a76bc04SThomas Huth 'alpha_clipper', 519a76bc04SThomas Huth] 529a76bc04SThomas Huth 53e3fc99b1SThomas Huthtests_arm_system_thorough = [ 54e3fc99b1SThomas Huth 'arm_canona1100', 55ef83aea0SPhilippe Mathieu-Daudé 'arm_integratorcp', 56165ab274SPhilippe Mathieu-Daudé 'arm_raspi2', 57c3cff727SThomas Huth 'arm_vexpress', 58de9f57a6SThomas Huth 'arm_tuxrun', 59e3fc99b1SThomas Huth] 60e3fc99b1SThomas Huth 6134917eadSPhilippe Mathieu-Daudétests_arm_linuxuser_thorough = [ 6234917eadSPhilippe Mathieu-Daudé 'arm_bflt', 6334917eadSPhilippe Mathieu-Daudé] 6434917eadSPhilippe Mathieu-Daudé 654c0a2df8SThomas Huthtests_avr_system_thorough = [ 664c0a2df8SThomas Huth 'avr_mega2560', 674c0a2df8SThomas Huth] 684c0a2df8SThomas Huth 694007fc94SThomas Huthtests_i386_system_thorough = [ 704007fc94SThomas Huth 'i386_tuxrun', 714007fc94SThomas Huth] 724007fc94SThomas Huth 734c0a2df8SThomas Huthtests_loongarch64_system_thorough = [ 744c0a2df8SThomas Huth 'loongarch64_virt', 754c0a2df8SThomas Huth] 764c0a2df8SThomas Huth 77576fffbcSThomas Huthtests_m68k_system_thorough = [ 789f989d65SThomas Huth 'm68k_mcf5208evb', 79c7f3663cSThomas Huth 'm68k_nextcube', 80c7f3663cSThomas Huth 'm68k_q800', 81576fffbcSThomas Huth] 82576fffbcSThomas Huth 83624fb343SThomas Huthtests_microblaze_system_thorough = [ 84624fb343SThomas Huth 'microblaze_s3adsp1800' 85624fb343SThomas Huth] 86624fb343SThomas Huth 87624fb343SThomas Huthtests_microblazeel_system_thorough = [ 88624fb343SThomas Huth 'microblazeel_s3adsp1800' 89624fb343SThomas Huth] 90624fb343SThomas Huth 9179cb4a14SPhilippe Mathieu-Daudétests_mips_system_thorough = [ 9279cb4a14SPhilippe Mathieu-Daudé 'mips_malta', 9387cab1aeSThomas Huth 'mips_tuxrun', 9479cb4a14SPhilippe Mathieu-Daudé] 9579cb4a14SPhilippe Mathieu-Daudé 96a4b60becSPhilippe Mathieu-Daudétests_mipsel_system_thorough = [ 97a4b60becSPhilippe Mathieu-Daudé 'mipsel_malta', 9855716a89SThomas Huth 'mipsel_tuxrun', 99a4b60becSPhilippe Mathieu-Daudé] 100a4b60becSPhilippe Mathieu-Daudé 101a01be218SThomas Huthtests_mips64_system_thorough = [ 102a01be218SThomas Huth 'mips64_tuxrun', 103a01be218SThomas Huth] 104a01be218SThomas Huth 1054c0a2df8SThomas Huthtests_mips64el_system_thorough = [ 1060d2a8acfSThomas Huth 'mips64el_fuloong2e', 1074c0a2df8SThomas Huth 'mips64el_loongson3v', 108fcf2658bSPhilippe Mathieu-Daudé 'mips64el_malta', 109*a2a2a5b0SThomas Huth 'mips64el_tuxrun', 1104c0a2df8SThomas Huth] 1114c0a2df8SThomas Huth 1120addb05aSThomas Huthtests_or1k_system_thorough = [ 1133a07875fSThomas Huth 'or1k_sim', 1143a07875fSThomas Huth] 1153a07875fSThomas Huth 1164c0a2df8SThomas Huthtests_ppc_system_quick = [ 1174c0a2df8SThomas Huth 'ppc_74xx', 1184c0a2df8SThomas Huth] 1194c0a2df8SThomas Huth 1204c0a2df8SThomas Huthtests_ppc_system_thorough = [ 1214c0a2df8SThomas Huth 'ppc_405', 122407a6883SThomas Huth 'ppc_40p', 123cef1becbSThomas Huth 'ppc_amiga', 124e3fc99b1SThomas Huth 'ppc_bamboo', 12512c0b407SThomas Huth 'ppc_mac', 126407a6883SThomas Huth 'ppc_mpc8544ds', 127407a6883SThomas Huth 'ppc_virtex_ml507', 128407a6883SThomas Huth] 129407a6883SThomas Huth 130407a6883SThomas Huthtests_ppc64_system_thorough = [ 13153a62fdeSThomas Huth 'ppc64_e500', 13288c90719SThomas Huth 'ppc64_hv', 133407a6883SThomas Huth 'ppc64_powernv', 134407a6883SThomas Huth 'ppc64_pseries', 135e3fc99b1SThomas Huth] 136e3fc99b1SThomas Huth 137d5674412SThomas Huthtests_rx_system_thorough = [ 138d5674412SThomas Huth 'rx_gdbsim', 139d5674412SThomas Huth] 140d5674412SThomas Huth 14177bc76c7SThomas Huthtests_riscv32_system_thorough = [ 14277bc76c7SThomas Huth 'riscv32_tuxrun', 14377bc76c7SThomas Huth] 14477bc76c7SThomas Huth 1457746a6c4SThomas Huthtests_riscv64_system_thorough = [ 1467746a6c4SThomas Huth 'riscv64_tuxrun', 1477746a6c4SThomas Huth] 1487746a6c4SThomas Huth 149e2e9fd25SThomas Huthtests_s390x_system_thorough = [ 150e2e9fd25SThomas Huth 's390x_ccw_virtio', 151e2e9fd25SThomas Huth 's390x_topology', 152e2e9fd25SThomas Huth] 153e2e9fd25SThomas Huth 154a94bfe1bSThomas Huthtests_sh4_system_thorough = [ 155a94bfe1bSThomas Huth 'sh4_r2d', 156a94bfe1bSThomas Huth] 157a94bfe1bSThomas Huth 158f90527d3SThomas Huthtests_sparc_system_thorough = [ 159f90527d3SThomas Huth 'sparc_sun4m', 160f90527d3SThomas Huth] 161f90527d3SThomas Huth 162e3fc99b1SThomas Huthtests_sparc64_system_thorough = [ 163e3fc99b1SThomas Huth 'sparc64_sun4u', 164116667aaSThomas Huth 'sparc64_tuxrun', 1654c0a2df8SThomas Huth] 1664c0a2df8SThomas Huth 16714973778SThomas Huthtests_x86_64_system_quick = [ 168cce85725SThomas Huth 'cpu_queries', 169cce85725SThomas Huth 'mem_addr_space', 170cce85725SThomas Huth 'pc_cpu_hotplug_props', 171cce85725SThomas Huth 'virtio_version', 172be849ef7SThomas Huth 'x86_cpu_model_versions', 17314973778SThomas Huth] 17414973778SThomas Huth 17514973778SThomas Huthtests_x86_64_system_thorough = [ 17605caa062SThomas Huth 'acpi_bits', 1777cea8fe3SThomas Huth 'x86_64_tuxrun', 1788dcac1cfSThomas Huth 'linux_initrd', 17969e4fbd0SThomas Huth 'multiprocess', 1804c0a2df8SThomas Huth 'netdev_ethtool', 181239d08aaSThomas Huth 'virtio_gpu', 18214973778SThomas Huth] 18314973778SThomas Huth 184d1939097SThomas Huthtests_xtensa_system_thorough = [ 185d1939097SThomas Huth 'xtensa_lx60', 186d1939097SThomas Huth] 187d1939097SThomas Huth 188f57213f8SDaniel P. Berrangéprecache_all = [] 18914973778SThomas Huthforeach speed : ['quick', 'thorough'] 19014973778SThomas Huth foreach dir : target_dirs 19114973778SThomas Huth 19214973778SThomas Huth target_base = dir.split('-')[0] 19314973778SThomas Huth 19414973778SThomas Huth if dir.endswith('-softmmu') 19514973778SThomas Huth sysmode = 'system' 19614973778SThomas Huth test_emulator = emulators['qemu-system-' + target_base] 19714973778SThomas Huth elif dir.endswith('-linux-user') 19814973778SThomas Huth sysmode = 'linuxuser' 19914973778SThomas Huth test_emulator = emulators['qemu-' + target_base] 20014973778SThomas Huth elif dir.endswith('-bsd-user') 20114973778SThomas Huth sysmode = 'bsduser' 20214973778SThomas Huth test_emulator = emulators['qemu-' + target_base] 20314973778SThomas Huth else 20414973778SThomas Huth continue 20514973778SThomas Huth endif 20614973778SThomas Huth 20714973778SThomas Huth if speed == 'quick' 20814973778SThomas Huth suites = ['func-quick', 'func-' + target_base] 20914973778SThomas Huth target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_quick', []) \ 21014973778SThomas Huth + get_variable('tests_generic_' + sysmode) 21114973778SThomas Huth else 21214973778SThomas Huth suites = ['func-' + speed, 'func-' + target_base + '-' + speed, speed] 21314973778SThomas Huth target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_' + speed, []) 21414973778SThomas Huth endif 21514973778SThomas Huth 21614973778SThomas Huth test_deps = roms 21714973778SThomas Huth test_env = environment() 21814973778SThomas Huth if have_tools 21914973778SThomas Huth test_env.set('QEMU_TEST_QEMU_IMG', meson.global_build_root() / 'qemu-img') 22014973778SThomas Huth test_deps += [qemu_img] 22114973778SThomas Huth endif 22214973778SThomas Huth test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path()) 22314973778SThomas Huth test_env.set('QEMU_BUILD_ROOT', meson.project_build_root()) 22414973778SThomas Huth test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' + 22514973778SThomas Huth meson.current_source_dir()) 22614973778SThomas Huth 22714973778SThomas Huth foreach test : target_tests 228f57213f8SDaniel P. Berrangé testname = '@0@-@1@'.format(target_base, test) 229f57213f8SDaniel P. Berrangé testfile = 'test_' + test + '.py' 230f57213f8SDaniel P. Berrangé testpath = meson.current_source_dir() / testfile 231f57213f8SDaniel P. Berrangé teststamp = testname + '.tstamp' 232f57213f8SDaniel P. Berrangé test_precache_env = environment() 233f57213f8SDaniel P. Berrangé test_precache_env.set('QEMU_TEST_PRECACHE', meson.current_build_dir() / teststamp) 234f57213f8SDaniel P. Berrangé test_precache_env.set('PYTHONPATH', meson.project_source_root() / 'python:' + 235f57213f8SDaniel P. Berrangé meson.current_source_dir()) 236f57213f8SDaniel P. Berrangé precache = custom_target('func-precache-' + testname, 237f57213f8SDaniel P. Berrangé output: teststamp, 238f57213f8SDaniel P. Berrangé command: [python, testpath], 239f57213f8SDaniel P. Berrangé depend_files: files(testpath), 240f57213f8SDaniel P. Berrangé build_by_default: false, 241f57213f8SDaniel P. Berrangé env: test_precache_env) 242f57213f8SDaniel P. Berrangé precache_all += precache 243f57213f8SDaniel P. Berrangé 244f57213f8SDaniel P. Berrangé # Ideally we would add 'precache' to 'depends' here, such that 245f57213f8SDaniel P. Berrangé # 'build_by_default: false' lets the pre-caching automatically 246f57213f8SDaniel P. Berrangé # run immediately before the test runs. In practice this is 247f57213f8SDaniel P. Berrangé # broken in meson, with it running the pre-caching in the normal 248f57213f8SDaniel P. Berrangé # compile phase https://github.com/mesonbuild/meson/issues/2518 249f57213f8SDaniel P. Berrangé # If the above bug ever gets fixed, when QEMU changes the min 250f57213f8SDaniel P. Berrangé # meson version, add the 'depends' and remove the custom 251f57213f8SDaniel P. Berrangé # 'run_target' logic below & in Makefile.include 252f57213f8SDaniel P. Berrangé test('func-' + testname, 25314973778SThomas Huth python, 25414973778SThomas Huth depends: [test_deps, test_emulator, emulator_modules], 25514973778SThomas Huth env: test_env, 256f57213f8SDaniel P. Berrangé args: [testpath], 25714973778SThomas Huth protocol: 'tap', 25814973778SThomas Huth timeout: test_timeouts.get(test, 60), 25914973778SThomas Huth priority: test_timeouts.get(test, 60), 26014973778SThomas Huth suite: suites) 26114973778SThomas Huth endforeach 26214973778SThomas Huth endforeach 26314973778SThomas Huthendforeach 264f57213f8SDaniel P. Berrangé 265f57213f8SDaniel P. Berrangérun_target('precache-functional', 266f57213f8SDaniel P. Berrangé depends: precache_all, 267f57213f8SDaniel P. Berrangé command: ['true']) 268