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