| 1 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | # |
| 3 | # Copyright 2018, 2024 Red Hat, Inc. |
| 4 | # |
| 5 | # Original Author (Avocado-based tests): |
| 6 | # Cleber Rosa <crosa@redhat.com> |
| 7 | # |
| 8 | # Adaption for standalone version: |
| 9 | # Thomas Huth <thuth@redhat.com> |
| 10 | # |
| 11 | # This work is licensed under the terms of the GNU GPL, version 2 or |
| 12 | # later. See the COPYING file in the top-level directory. |
| 13 | ''' |
| 14 | Functions related to the configuration of the tests and of the host system |
| 15 | ''' |
| 16 | |
| 17 | import os |
| 18 | from pathlib import Path |
| 19 | import platform |
| 20 | |
| 21 | |
| 22 | def _source_dir(): |
| 23 | # Determine top-level directory of the QEMU sources |
| 24 | return Path(__file__).parent.parent.parent.parent |
| 25 | |
| 26 | def _build_dir(): |
| 27 | root = os.getenv('MESON_BUILD_ROOT') |
| 28 | if root is not None: |
| 29 | return Path(root) |
| 30 | |
| 31 | raise RuntimeError("Missing MESON_BUILD_ROOT environment variable. " + |
| 32 | "Please use the '<BUILD-DIR>/run' script if invoking " + |
| 33 | "directly instead of via make/meson") |
| 34 | |
| 35 | BUILD_DIR = _build_dir() |
| 36 | |
| 37 | def dso_suffix(): |
| 38 | '''Return the dynamic libraries suffix for the current platform''' |
| 39 | |
| 40 | if platform.system() == "Darwin": |
| 41 | return "dylib" |
| 42 | |
| 43 | if platform.system() == "Windows": |
| 44 | return "dll" |
| 45 | |
| 46 | return "so" |