https://github.com/dzhidzhoev updated https://github.com/llvm/llvm-project/pull/96654
>From d47f7306c913336529a01a401e41ce688d0c6b46 Mon Sep 17 00:00:00 2001 From: Vladislav Dzhidzhoev <vdzhidzh...@accesssoftek.com> Date: Wed, 19 Jun 2024 23:50:18 +0000 Subject: [PATCH] [lldb][test] Set target and host OS for API tests in case of remote testing Makefile.rules uses HOST_OS and OS variables for determining host and target OSes for API tests compilation. This commit starts moving the platform detection logic from Makefile to Python lldb test suite. When lldb's target is set to remote-linux, Makefile.rules script should be executed with the target OS variable set to Linux. This is useful for the case of Windows-to-Linux cross-testing. --- .../Python/lldbsuite/test/lldbplatformutil.py | 29 +++++++++++++++++-- .../Python/lldbsuite/test/make/Makefile.rules | 5 +++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index 21f2095db90f8..e4de298fb11ae 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -56,6 +56,10 @@ def target_is_android(): return configuration.lldb_platform_name == "remote-android" +def target_is_remote_linux(): + return configuration.lldb_platform_name == "remote-linux" + + def android_device_api(): if not hasattr(android_device_api, "result"): assert configuration.lldb_platform_url is not None @@ -92,11 +96,28 @@ def match_android_device(device_arch, valid_archs=None, valid_api_levels=None): def finalize_build_dictionary(dictionary): + # Provide uname-like platform name + platform_name_to_uname = { "linux": "Linux", + "netbsd": "NetBSD", + "freebsd": "FreeBSD", + "windows": "Windows_NT", + } + + if dictionary is None: + dictionary = {} if target_is_android(): - if dictionary is None: - dictionary = {} dictionary["OS"] = "Android" dictionary["PIE"] = 1 + elif platformIsDarwin(): + dictionary["OS"] = "Darwin" + else: + dictionary["OS"] = platform_name_to_uname[getPlatform()] + + if platformIsDarwin(): + dictionary["HOST_OS"] = "Darwin" + else: + dictionary["HOST_OS"] = platform_name_to_uname[getHostPlatform()] + return dictionary @@ -113,6 +134,10 @@ def _get_platform_os(p): platform = "openbsd" return platform + # Triple is not available if we're not connected yet + if p.GetName() == "remote-linux": + return "linux" + return "" diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index bd8eea3d6f5a0..c101d84a9b959 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -55,7 +55,10 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ # When running tests from Visual Studio, the environment variable isn't # inherited all the way down to the process spawned for make. #---------------------------------------------------------------------- -HOST_OS := $(shell uname -s) +ifeq "$(OS)" "" + HOST_OS := $(shell uname -s) +endif + ifneq (,$(findstring windows32,$(HOST_OS))) HOST_OS := Windows_NT endif _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits