From a7d40d6a985c8c9a74d04318d937a810cdfa9be0 Mon Sep 17 00:00:00 2001 From: Kholiavin Nikolai Date: Tue, 21 Mar 2023 17:38:43 +0000 Subject: [PATCH 1/3] [OHOS][lldb][test] Fixes to run lldb tests on remote target This commit finishes porting bca5d477b57d7e1b8b41029cc925260b4f768e60. Also, after removing platform instance usage from category skipping logic (see https://reviews.llvm.org/D121605), our ohos ("linux" platform) detection from target triple does not work, because there is no triple. For now override android with "linux". Signed-off-by: Kholiavin Nikolai --- .../Python/lldbsuite/test/builders/builder.py | 18 ++-- .../Python/lldbsuite/test/lldbplatformutil.py | 85 ++++++++++--------- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py index cb82dd4c9881..fdd3b35ca5de 100644 --- a/lldb/packages/Python/lldbsuite/test/builders/builder.py +++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py @@ -68,17 +68,19 @@ class Builder: make system. """ - # If d is None or an empty mapping, just return an empty list. + # OHOS_LOCAL begin if not d: - return [] + d = {} - def setOrAppendVariable(k, v): - append_vars = ["CFLAGS", "CFLAGS_EXTRAS", "LD_EXTRAS"] - if k in append_vars and k in os.environ: - v = os.environ[k] + " " + v - return '%s=%s' % (k, v) + pattern = '%s=%s' + append_vars = ["CFLAGS", "CFLAGS_EXTRAS", "LD_EXTRAS"] + for var in append_vars: + val = (d.get(var, '') + ' ' + os.getenv(var, '')).strip() + if val: + d[var] = val - cmdline = [setOrAppendVariable(k, v) for k, v in list(d.items())] + cmdline = [pattern % (k, v) for k, v in d.items()] + # OHOS_LOCAL end return cmdline diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index 317f19bd712f..fbd6e809ef70 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -54,9 +54,51 @@ def _run_adb_command(cmd, device_id): stdout, stderr = p.communicate() return p.returncode, stdout, stderr +# OHOS_LOCAL begin + +def getHostPlatform(): + """Returns the host platform running the test suite.""" + # Attempts to return a platform name matching a target Triple platform. + if sys.platform.startswith('linux'): + return 'linux' + elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): + return 'windows' + elif sys.platform.startswith('darwin'): + return 'macosx' + elif sys.platform.startswith('freebsd'): + return 'freebsd' + elif sys.platform.startswith('netbsd'): + return 'netbsd' + else: + return sys.platform + +def getPlatform(): + """Returns the target platform which the tests are running on.""" + # Use the Apple SDK to determine the platform if set. + if configuration.apple_sdk: + platform = configuration.apple_sdk + dot = platform.find('.') + if dot != -1: + platform = platform[:dot] + if platform == 'iphoneos': + platform = 'ios' + return platform + + platform = configuration.lldb_platform_name + if platform is None: + platform = "host" + if platform == "qemu-user": + platform = "host" + if platform == "host": + return getHostPlatform() + if platform.startswith("remote-"): + if platform == "remote-android": + return "linux" + return platform[7:] + return platform def target_is_android(): - return configuration.lldb_platform_name == "remote-android" + return getPlatform() == "android" def android_device_api(): if not hasattr(android_device_api, 'result'): @@ -101,49 +143,10 @@ def finalize_build_dictionary(dictionary): return dictionary -def getHostPlatform(): - """Returns the host platform running the test suite.""" - # Attempts to return a platform name matching a target Triple platform. - if sys.platform.startswith('linux'): - return 'linux' - elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): - return 'windows' - elif sys.platform.startswith('darwin'): - return 'macosx' - elif sys.platform.startswith('freebsd'): - return 'freebsd' - elif sys.platform.startswith('netbsd'): - return 'netbsd' - else: - return sys.platform - - def getDarwinOSTriples(): return lldbplatform.translate(lldbplatform.darwin_all) -def getPlatform(): - """Returns the target platform which the tests are running on.""" - # Use the Apple SDK to determine the platform if set. - if configuration.apple_sdk: - platform = configuration.apple_sdk - dot = platform.find('.') - if dot != -1: - platform = platform[:dot] - if platform == 'iphoneos': - platform = 'ios' - return platform - - platform = configuration.lldb_platform_name - if platform is None: - platform = "host" - if platform == "qemu-user": - platform = "host" - if platform == "host": - return getHostPlatform() - if platform.startswith("remote-"): - return platform[7:] - return platform - +# OHOS_LOCAL end def platformIsDarwin(): """Returns true if the OS triple for the selected platform is any valid apple OS""" -- Gitee From d8bcf0f7812e6fce6661610fac83086fd8b371d9 Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Tue, 29 Nov 2022 04:34:40 -0800 Subject: [PATCH 2/3] [test] Allow libc++ namespaces besides `__1` The libc++ data formatter for `std::shared_ptr` allows any namespace, but the test asserts that it must be the default `__1` namespace. Relax the regex to allow anything that looks like `__.*` (although we use `__[^:]*` so we don't match arbitrarily long text). Reviewed By: labath Differential Revision: https://reviews.llvm.org/D129898 Signed-off-by: Kholiavin Nikolai --- .../forward_decl_from_module/TestForwardDeclFromStdModule.py | 2 +- .../libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py index 943aa5b77725..6adf016727cc 100644 --- a/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py @@ -37,4 +37,4 @@ class TestCase(TestBase): # Both `std::vector` and the type of the member have forward # declarations before their definitions. self.expect("expr --raw -- v", - substrs=['(std::__1::vector) $0 = {', 'f = nullptr', '}']) + patterns=[r'\(std::__[^:]*::vector\) \$0 = {', 'f = nullptr', '}']) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py index 663058e07653..c646fccc2f5e 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py @@ -68,7 +68,7 @@ class TestCase(TestBase): valobj = self.expect_var_path("sp_user", type="std::shared_ptr") self.assertRegex( valobj.summary, - "^std(::__1)?::shared_ptr::element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=1", + "^std(::__[^:]*)?::shared_ptr::element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=1", ) self.assertNotEqual(valobj.child[0].unsigned, 0) -- Gitee From c4fc35f98accab0bd05cd624b955549991488240 Mon Sep 17 00:00:00 2001 From: Kholiavin Nikolai Date: Mon, 27 Mar 2023 13:40:50 +0000 Subject: [PATCH 3/3] [lldb][test] Disable step signal tests on aarch64 This commit disables signal stepping tests on aarch64 until the issue is resolved (i.e., either some patch is upstreamed or another solution is presented). Please see https://gitee.com/openharmony/third_party_llvm-project/pulls/126 for more information. Signed-off-by: Kholiavin Nikolai --- .../TestSignalStepOverHandlerWithBreakpoint.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lldb/test/API/functionalities/thread/signal_during_breakpoint_step/TestSignalStepOverHandlerWithBreakpoint.py b/lldb/test/API/functionalities/thread/signal_during_breakpoint_step/TestSignalStepOverHandlerWithBreakpoint.py index ddafffdbd39d..84445b868b88 100644 --- a/lldb/test/API/functionalities/thread/signal_during_breakpoint_step/TestSignalStepOverHandlerWithBreakpoint.py +++ b/lldb/test/API/functionalities/thread/signal_during_breakpoint_step/TestSignalStepOverHandlerWithBreakpoint.py @@ -104,6 +104,9 @@ class TestSignalStepOverHandlerWithBreakpoint(SignalDuringBreakpointStepTestCase # Atomic sequences are not supported yet for MIPS in LLDB. # (Copied from concurrent_events/TestConcurrentSignalBreak.py) @skipIf(triple='^mips') + # Currently, lldb might skip the next stop when stepping out of the func, + # if the single-stepping is not emulated + @skipIf(archs=no_match(['arm'])) # Currently on arm, lldb might get wrong return addresses from a signal handler # and fail with 'could not create return address breakpoint' @skipIf(archs='arm') @@ -114,6 +117,9 @@ class TestSignalStepOverHandlerWithBreakpoint(SignalDuringBreakpointStepTestCase # Atomic sequences are not supported yet for MIPS in LLDB. # (Copied from concurrent_events/TestConcurrentSignalBreak.py) @skipIf(triple='^mips') + # Currently, lldb might skip the next stop when stepping out of the func, + # if the single-stepping is not emulated + @skipIf(archs=no_match(['arm'])) def test_breakpoint_inside_handler_continue(self): self.set_up_step_over_handler_with_breakpoint() self.set_up_and_iterate(self.action, True, self.check_handler_bp_continue) @@ -121,6 +127,9 @@ class TestSignalStepOverHandlerWithBreakpoint(SignalDuringBreakpointStepTestCase # Atomic sequences are not supported yet for MIPS in LLDB. # (Copied from concurrent_events/TestConcurrentSignalBreak.py) @skipIf(triple='^mips') + # Currently, lldb might skip the next stop when stepping out of the func, + # if the single-stepping is not emulated + @skipIf(archs=no_match(['arm'])) def test_breakpoint_inside_handler_continue_to_breakpoint(self): self.set_up_step_over_handler_with_breakpoint() self.set_up_and_iterate(self.action, False, self.check_handler_bp_continue) -- Gitee