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 12subdir('aarch64') 13subdir('alpha') 14subdir('arm') 15subdir('avr') 16subdir('hppa') 17subdir('i386') 18subdir('loongarch64') 19subdir('m68k') 20subdir('microblaze') 21subdir('microblazeel') 22subdir('mips') 23subdir('mipsel') 24subdir('mips64') 25subdir('mips64el') 26subdir('or1k') 27subdir('ppc') 28subdir('ppc64') 29subdir('riscv32') 30subdir('riscv64') 31subdir('rx') 32subdir('s390x') 33subdir('sh4') 34subdir('sh4eb') 35subdir('sparc') 36subdir('sparc64') 37subdir('x86_64') 38subdir('xtensa') 39subdir('generic') 40 41precache_all = [] 42foreach speed : ['quick', 'thorough'] 43 foreach dir : target_dirs 44 45 target_base = dir.split('-')[0] 46 47 if dir.endswith('-softmmu') 48 sysmode = 'system' 49 test_emulator = emulators['qemu-system-' + target_base] 50 elif dir.endswith('-linux-user') 51 sysmode = 'linuxuser' 52 test_emulator = emulators['qemu-' + target_base] 53 elif dir.endswith('-bsd-user') 54 sysmode = 'bsduser' 55 test_emulator = emulators['qemu-' + target_base] 56 else 57 continue 58 endif 59 60 if speed == 'quick' 61 suites = ['func-quick', 'func-' + target_base] 62 target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_quick', []) \ 63 + get_variable('tests_generic_' + sysmode) 64 else 65 suites = ['func-' + speed, 'func-' + target_base + '-' + speed, speed] 66 target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_' + speed, []) 67 endif 68 69 test_deps = [roms, keymap_targets] 70 test_env = environment() 71 if have_tools 72 test_env.set('QEMU_TEST_QEMU_IMG', meson.global_build_root() / 'qemu-img') 73 test_deps += [qemu_img] 74 endif 75 test_env.set('QEMU_TEST_QEMU_BINARY', test_emulator.full_path()) 76 test_env.set('QEMU_BUILD_ROOT', meson.project_build_root()) 77 test_env.set('PYTHONPATH', meson.project_source_root() / 'python:' + 78 meson.current_source_dir()) 79 80 # Define the GDB environment variable if gdb is available. 81 gdb = get_option('gdb') 82 if gdb != '' 83 test_env.set('QEMU_TEST_GDB', gdb) 84 endif 85 86 foreach test : target_tests 87 testname = '@0@-@1@'.format(target_base, test) 88 if fs.exists('generic' / 'test_' + test + '.py') 89 testfile = 'generic' / 'test_' + test + '.py' 90 else 91 testfile = target_base / 'test_' + test + '.py' 92 endif 93 testpath = meson.current_source_dir() / testfile 94 teststamp = testname + '.tstamp' 95 test_precache_env = environment() 96 test_precache_env.set('QEMU_TEST_PRECACHE', meson.current_build_dir() / teststamp) 97 test_precache_env.set('PYTHONPATH', meson.project_source_root() / 'python:' + 98 meson.current_source_dir()) 99 precache = custom_target('func-precache-' + testname, 100 output: teststamp, 101 command: [python, testpath], 102 depend_files: files(testpath), 103 build_by_default: false, 104 env: test_precache_env) 105 precache_all += precache 106 if is_variable('test_' + target_base + '_timeouts') 107 time_out = get_variable('test_' + target_base + '_timeouts').get(test, 90) 108 else 109 time_out = 90 110 endif 111 112 # Ideally we would add 'precache' to 'depends' here, such that 113 # 'build_by_default: false' lets the pre-caching automatically 114 # run immediately before the test runs. In practice this is 115 # broken in meson, with it running the pre-caching in the normal 116 # compile phase https://github.com/mesonbuild/meson/issues/2518 117 # If the above bug ever gets fixed, when QEMU changes the min 118 # meson version, add the 'depends' and remove the custom 119 # 'run_target' logic below & in Makefile.include 120 test('func-' + testname, 121 python, 122 depends: [test_deps, test_emulator, emulator_modules, plugin_modules], 123 env: test_env, 124 args: [testpath], 125 protocol: 'tap', 126 timeout: time_out, 127 priority: time_out, 128 suite: suites) 129 endforeach 130 endforeach 131endforeach 132 133run_target('precache-functional', 134 depends: precache_all, 135 command: [python, '-c', '']) 136