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