1# Test class and utilities for functional tests 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 14import os 15from pathlib import Path 16import platform 17 18 19def _source_dir(): 20 # Determine top-level directory of the QEMU sources 21 return Path(__file__).parent.parent.parent.parent 22 23def _build_dir(): 24 root = os.getenv('QEMU_BUILD_ROOT') 25 if root is not None: 26 return Path(root) 27 # Makefile.mtest only exists in build dir, so if it is available, use CWD 28 if os.path.exists('Makefile.mtest'): 29 return Path(os.getcwd()) 30 31 root = os.path.join(_source_dir(), 'build') 32 if os.path.exists(root): 33 return Path(root) 34 35 raise Exception("Cannot identify build dir, set QEMU_BUILD_ROOT") 36 37BUILD_DIR = _build_dir() 38 39def dso_suffix(): 40 '''Return the dynamic libraries suffix for the current platform''' 41 42 if platform.system() == "Darwin": 43 return "dylib" 44 45 if platform.system() == "Windows": 46 return "dll" 47 48 return "so" 49