Skip to content

Commit b6e1aa2

Browse files
committed
[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.
1 parent 19cc461 commit b6e1aa2

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

lldb/packages/Python/lldbsuite/test/lldbplatformutil.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,28 @@ def match_android_device(device_arch, valid_archs=None, valid_api_levels=None):
9292

9393

9494
def finalize_build_dictionary(dictionary):
95+
# Provide uname-like platform name
96+
platform_name_to_uname = {
97+
"linux": "Linux",
98+
"netbsd": "NetBSD",
99+
"freebsd": "FreeBSD",
100+
"windows": "Windows_NT",
101+
"macosx": "Darwin",
102+
"darwin": "Darwin",
103+
}
104+
105+
if dictionary is None:
106+
dictionary = {}
95107
if target_is_android():
96-
if dictionary is None:
97-
dictionary = {}
98108
dictionary["OS"] = "Android"
99109
dictionary["PIE"] = 1
110+
elif platformIsDarwin():
111+
dictionary["OS"] = "Darwin"
112+
else:
113+
dictionary["OS"] = platform_name_to_uname[getPlatform()]
114+
115+
dictionary["HOST_OS"] = platform_name_to_uname[getHostPlatform()]
116+
100117
return dictionary
101118

102119

@@ -113,6 +130,10 @@ def _get_platform_os(p):
113130
platform = "openbsd"
114131
return platform
115132

133+
# Triple is not available if we're not connected yet
134+
if p.GetName() == "remote-linux":
135+
return "linux"
136+
116137
return ""
117138

118139

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
5555
# When running tests from Visual Studio, the environment variable isn't
5656
# inherited all the way down to the process spawned for make.
5757
#----------------------------------------------------------------------
58-
HOST_OS := $(shell uname -s)
58+
ifeq "$(HOST_OS)" ""
59+
HOST_OS := $(shell uname -s)
60+
endif
61+
5962
ifneq (,$(findstring windows32,$(HOST_OS)))
6063
HOST_OS := Windows_NT
6164
endif

0 commit comments

Comments
 (0)