1fa32a634SThomas Huth# Test class and utilities for functional tests 2fa32a634SThomas Huth# 3fa32a634SThomas Huth# Copyright 2018, 2024 Red Hat, Inc. 4fa32a634SThomas Huth# 5fa32a634SThomas Huth# Original Author (Avocado-based tests): 6fa32a634SThomas Huth# Cleber Rosa <crosa@redhat.com> 7fa32a634SThomas Huth# 8fa32a634SThomas Huth# Adaption for standalone version: 9fa32a634SThomas Huth# Thomas Huth <thuth@redhat.com> 10fa32a634SThomas Huth# 11fa32a634SThomas Huth# This work is licensed under the terms of the GNU GPL, version 2 or 12fa32a634SThomas Huth# later. See the COPYING file in the top-level directory. 13fa32a634SThomas Huth 14fa32a634SThomas Huthimport os 15fa32a634SThomas Huthfrom pathlib import Path 16*3a7b9054SPhilippe Mathieu-Daudéimport platform 17fa32a634SThomas Huth 18fa32a634SThomas Huth 19fa32a634SThomas Huthdef _source_dir(): 20fa32a634SThomas Huth # Determine top-level directory of the QEMU sources 21fa32a634SThomas Huth return Path(__file__).parent.parent.parent.parent 22fa32a634SThomas Huth 23fa32a634SThomas Huthdef _build_dir(): 24fa32a634SThomas Huth root = os.getenv('QEMU_BUILD_ROOT') 25fa32a634SThomas Huth if root is not None: 26fa32a634SThomas Huth return Path(root) 27fa32a634SThomas Huth # Makefile.mtest only exists in build dir, so if it is available, use CWD 28fa32a634SThomas Huth if os.path.exists('Makefile.mtest'): 29fa32a634SThomas Huth return Path(os.getcwd()) 30fa32a634SThomas Huth 31fa32a634SThomas Huth root = os.path.join(_source_dir(), 'build') 32fa32a634SThomas Huth if os.path.exists(root): 33fa32a634SThomas Huth return Path(root) 34fa32a634SThomas Huth 35fa32a634SThomas Huth raise Exception("Cannot identify build dir, set QEMU_BUILD_ROOT") 36fa32a634SThomas Huth 37fa32a634SThomas HuthBUILD_DIR = _build_dir() 38*3a7b9054SPhilippe Mathieu-Daudé 39*3a7b9054SPhilippe Mathieu-Daudédef dso_suffix(): 40*3a7b9054SPhilippe Mathieu-Daudé '''Return the dynamic libraries suffix for the current platform''' 41*3a7b9054SPhilippe Mathieu-Daudé 42*3a7b9054SPhilippe Mathieu-Daudé if platform.system() == "Darwin": 43*3a7b9054SPhilippe Mathieu-Daudé return "dylib" 44*3a7b9054SPhilippe Mathieu-Daudé 45*3a7b9054SPhilippe Mathieu-Daudé if platform.system() == "Windows": 46*3a7b9054SPhilippe Mathieu-Daudé return "dll" 47*3a7b9054SPhilippe Mathieu-Daudé 48*3a7b9054SPhilippe Mathieu-Daudé return "so" 49