Introduce a helper to get the default shared library
suffix used on the host.
Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
tests/functional/qemu_test/__init__.py | 2 +-
tests/functional/qemu_test/cmd.py | 1 -
tests/functional/qemu_test/config.py | 6 ++++++
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
index 5c972843a6d..45f7befa374 100644
--- a/tests/functional/qemu_test/__init__.py
+++ b/tests/functional/qemu_test/__init__.py
@@ -7,7 +7,7 @@
from .asset import Asset
-from .config import BUILD_DIR
+from .config import BUILD_DIR, dso_suffix
from .cmd import is_readable_executable_file, \
interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
exec_command, exec_command_and_wait_for_pattern, get_qemu_img, which
diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py
index dc5f422b77d..254e23ef748 100644
--- a/tests/functional/qemu_test/cmd.py
+++ b/tests/functional/qemu_test/cmd.py
@@ -15,7 +15,6 @@
import os
import os.path
-
def which(tool):
""" looks up the full path for @tool, returns None if not found
or if @tool does not have executable permissions.
diff --git a/tests/functional/qemu_test/config.py b/tests/functional/qemu_test/config.py
index edd75b7fd06..0eab1baa541 100644
--- a/tests/functional/qemu_test/config.py
+++ b/tests/functional/qemu_test/config.py
@@ -13,6 +13,7 @@
import os
from pathlib import Path
+import platform
def _source_dir():
@@ -34,3 +35,8 @@ def _build_dir():
raise Exception("Cannot identify build dir, set QEMU_BUILD_ROOT")
BUILD_DIR = _build_dir()
+
+def dso_suffix():
+ '''Return the dynamic libraries suffix for the current platform'''
+ DSO_SUFFIXES = { 'Linux': 'so', 'Darwin': 'dylib', 'Windows': 'dll' }
+ return DSO_SUFFIXES[platform.system()]
--
2.47.1
On Thu, Feb 20, 2025 at 09:02:14AM +0100, Philippe Mathieu-Daudé wrote:
> Introduce a helper to get the default shared library
> suffix used on the host.
>
> Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> tests/functional/qemu_test/__init__.py | 2 +-
> tests/functional/qemu_test/cmd.py | 1 -
> tests/functional/qemu_test/config.py | 6 ++++++
> 3 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
> index 5c972843a6d..45f7befa374 100644
> --- a/tests/functional/qemu_test/__init__.py
> +++ b/tests/functional/qemu_test/__init__.py
> @@ -7,7 +7,7 @@
>
>
> from .asset import Asset
> -from .config import BUILD_DIR
> +from .config import BUILD_DIR, dso_suffix
> from .cmd import is_readable_executable_file, \
> interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
> exec_command, exec_command_and_wait_for_pattern, get_qemu_img, which
> diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py
> index dc5f422b77d..254e23ef748 100644
> --- a/tests/functional/qemu_test/cmd.py
> +++ b/tests/functional/qemu_test/cmd.py
> @@ -15,7 +15,6 @@
> import os
> import os.path
>
> -
> def which(tool):
> """ looks up the full path for @tool, returns None if not found
> or if @tool does not have executable permissions.
> diff --git a/tests/functional/qemu_test/config.py b/tests/functional/qemu_test/config.py
> index edd75b7fd06..0eab1baa541 100644
> --- a/tests/functional/qemu_test/config.py
> +++ b/tests/functional/qemu_test/config.py
> @@ -13,6 +13,7 @@
>
> import os
> from pathlib import Path
> +import platform
>
>
> def _source_dir():
> @@ -34,3 +35,8 @@ def _build_dir():
> raise Exception("Cannot identify build dir, set QEMU_BUILD_ROOT")
>
> BUILD_DIR = _build_dir()
> +
> +def dso_suffix():
> + '''Return the dynamic libraries suffix for the current platform'''
> + DSO_SUFFIXES = { 'Linux': 'so', 'Darwin': 'dylib', 'Windows': 'dll' }
> + return DSO_SUFFIXES[platform.system()]
Windows and Darwin are the two odd-ball platforms we target, Linux and
all the BSDs use .so, so it makes sense to use .so as the general
fallback, at which point I'm not sure the lookup table is worthwhile
compared to:
if platform.system() == "Darwin"
return "dylib"
elif platform.system() == "Windows"
return "dll"
else
return "so"
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
On 2025/02/20 17:02, Philippe Mathieu-Daudé wrote:
> Introduce a helper to get the default shared library
> suffix used on the host.
>
> Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> tests/functional/qemu_test/__init__.py | 2 +-
> tests/functional/qemu_test/cmd.py | 1 -
> tests/functional/qemu_test/config.py | 6 ++++++
> 3 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py
> index 5c972843a6d..45f7befa374 100644
> --- a/tests/functional/qemu_test/__init__.py
> +++ b/tests/functional/qemu_test/__init__.py
> @@ -7,7 +7,7 @@
>
>
> from .asset import Asset
> -from .config import BUILD_DIR
> +from .config import BUILD_DIR, dso_suffix
> from .cmd import is_readable_executable_file, \
> interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
> exec_command, exec_command_and_wait_for_pattern, get_qemu_img, which
> diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py
> index dc5f422b77d..254e23ef748 100644
> --- a/tests/functional/qemu_test/cmd.py
> +++ b/tests/functional/qemu_test/cmd.py
> @@ -15,7 +15,6 @@
> import os
> import os.path
>
> -
> def which(tool):
> """ looks up the full path for @tool, returns None if not found
> or if @tool does not have executable permissions.
> diff --git a/tests/functional/qemu_test/config.py b/tests/functional/qemu_test/config.py
> index edd75b7fd06..0eab1baa541 100644
> --- a/tests/functional/qemu_test/config.py
> +++ b/tests/functional/qemu_test/config.py
> @@ -13,6 +13,7 @@
>
> import os
> from pathlib import Path
> +import platform
>
>
> def _source_dir():
> @@ -34,3 +35,8 @@ def _build_dir():
> raise Exception("Cannot identify build dir, set QEMU_BUILD_ROOT")
>
> BUILD_DIR = _build_dir()
> +
> +def dso_suffix():
> + '''Return the dynamic libraries suffix for the current platform'''
> + DSO_SUFFIXES = { 'Linux': 'so', 'Darwin': 'dylib', 'Windows': 'dll' }> + return DSO_SUFFIXES[platform.system()]
It may be too late to comment, but:
I'm a bit worried that this can break tests on platforms (BSDs?) not
listed here though I don't know if plugin tests work on BSDs in the
first place.
Akihiko Odaki <akihiko.odaki@daynix.com> writes:
> On 2025/02/20 17:02, Philippe Mathieu-Daudé wrote:
>> Introduce a helper to get the default shared library
>> suffix used on the host.
>> Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>> tests/functional/qemu_test/__init__.py | 2 +-
>> tests/functional/qemu_test/cmd.py | 1 -
>> tests/functional/qemu_test/config.py | 6 ++++++
>> 3 files changed, 7 insertions(+), 2 deletions(-)
>> diff --git a/tests/functional/qemu_test/__init__.py
>> b/tests/functional/qemu_test/__init__.py
>> index 5c972843a6d..45f7befa374 100644
>> --- a/tests/functional/qemu_test/__init__.py
>> +++ b/tests/functional/qemu_test/__init__.py
>> @@ -7,7 +7,7 @@
>> from .asset import Asset
>> -from .config import BUILD_DIR
>> +from .config import BUILD_DIR, dso_suffix
>> from .cmd import is_readable_executable_file, \
>> interrupt_interactive_console_until_pattern, wait_for_console_pattern, \
>> exec_command, exec_command_and_wait_for_pattern, get_qemu_img, which
>> diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py
>> index dc5f422b77d..254e23ef748 100644
>> --- a/tests/functional/qemu_test/cmd.py
>> +++ b/tests/functional/qemu_test/cmd.py
>> @@ -15,7 +15,6 @@
>> import os
>> import os.path
>> -
>> def which(tool):
>> """ looks up the full path for @tool, returns None if not found
>> or if @tool does not have executable permissions.
>> diff --git a/tests/functional/qemu_test/config.py b/tests/functional/qemu_test/config.py
>> index edd75b7fd06..0eab1baa541 100644
>> --- a/tests/functional/qemu_test/config.py
>> +++ b/tests/functional/qemu_test/config.py
>> @@ -13,6 +13,7 @@
>> import os
>> from pathlib import Path
>> +import platform
>> def _source_dir():
>> @@ -34,3 +35,8 @@ def _build_dir():
>> raise Exception("Cannot identify build dir, set QEMU_BUILD_ROOT")
>> BUILD_DIR = _build_dir()
>> +
>> +def dso_suffix():
>> + '''Return the dynamic libraries suffix for the current platform'''
>> + DSO_SUFFIXES = { 'Linux': 'so', 'Darwin': 'dylib', 'Windows': 'dll' }> + return DSO_SUFFIXES[platform.system()]
>
> It may be too late to comment, but:
> I'm a bit worried that this can break tests on platforms (BSDs?) not
> listed here though I don't know if plugin tests work on BSDs in the
> first place.
Currently we don't run any of the check-tcg tests on BSD. Mostly because
I couldn't find cross compilers packaged for BSD (and there is no
docker-like thing to bring them in) and for the "native" cross compiler
we currently block clang - although there are some fixes for that in my
current maintainer series.
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
On 20/02/2025 09.02, Philippe Mathieu-Daudé wrote: > Introduce a helper to get the default shared library > suffix used on the host. > > Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> > --- > tests/functional/qemu_test/__init__.py | 2 +- > tests/functional/qemu_test/cmd.py | 1 - > tests/functional/qemu_test/config.py | 6 ++++++ > 3 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py > index 5c972843a6d..45f7befa374 100644 > --- a/tests/functional/qemu_test/__init__.py > +++ b/tests/functional/qemu_test/__init__.py > @@ -7,7 +7,7 @@ > > > from .asset import Asset > -from .config import BUILD_DIR > +from .config import BUILD_DIR, dso_suffix > from .cmd import is_readable_executable_file, \ > interrupt_interactive_console_until_pattern, wait_for_console_pattern, \ > exec_command, exec_command_and_wait_for_pattern, get_qemu_img, which > diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py > index dc5f422b77d..254e23ef748 100644 > --- a/tests/functional/qemu_test/cmd.py > +++ b/tests/functional/qemu_test/cmd.py > @@ -15,7 +15,6 @@ > import os > import os.path > > - > def which(tool): > """ looks up the full path for @tool, returns None if not found > or if @tool does not have executable permissions. Please drop the change to cmd.py now. With that fixed: Reviewed-by: Thomas Huth <thuth@redhat.com>
On 20/2/25 09:02, Philippe Mathieu-Daudé wrote: > Introduce a helper to get the default shared library > suffix used on the host. > > Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> > --- > tests/functional/qemu_test/__init__.py | 2 +- > tests/functional/qemu_test/cmd.py | 1 - > tests/functional/qemu_test/config.py | 6 ++++++ > 3 files changed, 7 insertions(+), 2 deletions(-) > diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py > index dc5f422b77d..254e23ef748 100644 > --- a/tests/functional/qemu_test/cmd.py > +++ b/tests/functional/qemu_test/cmd.py > @@ -15,7 +15,6 @@ > import os > import os.path > > - Oops, Alex, should I respin a v3 removing this change? > def which(tool): > """ looks up the full path for @tool, returns None if not found > or if @tool does not have executable permissions.
© 2016 - 2026 Red Hat, Inc.