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