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 'netdev_ethtool' : 180, 15 's390x_ccw_virtio' : 180, 16} 17 18tests_generic_system = [ 19 'empty_cpu_model', 20 'info_usernet', 21 'version', 22] 23 24tests_generic_linuxuser = [ 25] 26 27tests_generic_bsduser = [ 28] 29 30tests_arm_system_thorough = [ 31 'arm_canona1100', 32] 33 34tests_avr_system_thorough = [ 35 'avr_mega2560', 36] 37 38tests_loongarch64_system_thorough = [ 39 'loongarch64_virt', 40] 41 42tests_mips64el_system_thorough = [ 43 'mips64el_loongson3v', 44] 45 46tests_ppc_system_quick = [ 47 'ppc_74xx', 48] 49 50tests_ppc_system_thorough = [ 51 'ppc_405', 52 'ppc_bamboo', 53] 54 55tests_s390x_system_thorough = [ 56 's390x_ccw_virtio', 57 's390x_topology', 58] 59 60tests_sparc64_system_thorough = [ 61 'sparc64_sun4u', 62] 63 64tests_x86_64_system_quick = [ 65 'cpu_queries', 66 'mem_addr_space', 67 'pc_cpu_hotplug_props', 68 'virtio_version', 69] 70 71tests_x86_64_system_thorough = [ 72 'netdev_ethtool', 73] 74 75precache_all = [] 76foreach speed : ['quick', 'thorough'] 77 foreach dir : target_dirs 78 79 target_base = dir.split('-')[0] 80 81 if dir.endswith('-softmmu') 82 sysmode = 'system' 83 test_emulator = emulators['qemu-system-' + target_base] 84 elif dir.endswith('-linux-user') 85 sysmode = 'linuxuser' 86 test_emulator = emulators['qemu-' + target_base] 87 elif dir.endswith('-bsd-user') 88 sysmode = 'bsduser' 89 test_emulator = emulators['qemu-' + target_base] 90 else 91 continue 92 endif 93 94 if speed == 'quick' 95 suites = ['func-quick', 'func-' + target_base] 96 target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_quick', []) \ 97 + get_variable('tests_generic_' + sysmode) 98 else 99 suites = ['func-' + speed, 'func-' + target_base + '-' + speed, speed] 100 target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_' + speed, []) 101 endif 102 103 test_deps = roms 104 test_env = environment() 105 if have_tools 106 test_env.set('QEMU_TEST_QEMU_IMG', meson.global_build_root() / 'qemu-img') 107 test_deps += [qemu_img] 108 endif 109 test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path()) 110 test_env.set('QEMU_BUILD_ROOT', meson.project_build_root()) 111 test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' + 112 meson.current_source_dir()) 113 114 foreach test : target_tests 115 testname = '@0@-@1@'.format(target_base, test) 116 testfile = 'test_' + test + '.py' 117 testpath = meson.current_source_dir() / testfile 118 teststamp = testname + '.tstamp' 119 test_precache_env = environment() 120 test_precache_env.set('QEMU_TEST_PRECACHE', meson.current_build_dir() / teststamp) 121 test_precache_env.set('PYTHONPATH', meson.project_source_root() / 'python:' + 122 meson.current_source_dir()) 123 precache = custom_target('func-precache-' + testname, 124 output: teststamp, 125 command: [python, testpath], 126 depend_files: files(testpath), 127 build_by_default: false, 128 env: test_precache_env) 129 precache_all += precache 130 131 # Ideally we would add 'precache' to 'depends' here, such that 132 # 'build_by_default: false' lets the pre-caching automatically 133 # run immediately before the test runs. In practice this is 134 # broken in meson, with it running the pre-caching in the normal 135 # compile phase https://github.com/mesonbuild/meson/issues/2518 136 # If the above bug ever gets fixed, when QEMU changes the min 137 # meson version, add the 'depends' and remove the custom 138 # 'run_target' logic below & in Makefile.include 139 test('func-' + testname, 140 python, 141 depends: [test_deps, test_emulator, emulator_modules], 142 env: test_env, 143 args: [testpath], 144 protocol: 'tap', 145 timeout: test_timeouts.get(test, 60), 146 priority: test_timeouts.get(test, 60), 147 suite: suites) 148 endforeach 149 endforeach 150endforeach 151 152run_target('precache-functional', 153 depends: precache_all, 154 command: ['true']) 155