From 7a1d80cc545ae4855aa4c637c0b36da6cb68f427 Mon Sep 17 00:00:00 2001 From: wuyuanchao Date: Thu, 14 Nov 2024 15:00:12 +0800 Subject: [PATCH 1/2] Issue: https://gitee.com/openharmony/third_party_llvm-project/issues/IB4C3K enable lldb-api for ohos Signed-off-by: wuyuanchao --- .../Python/lldbsuite/test/decorators.py | 36 +++++++++++++++++++ lldb/packages/Python/lldbsuite/test/dotest.py | 2 +- .../Python/lldbsuite/test/lldbplatformutil.py | 17 ++++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index dc553938e1cc..95964f2056ca 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -324,6 +324,14 @@ def _skip_for_android(reason, api_levels, archs): return impl +def _skip_for_ohos(reason, archs): + def impl(obj): + result = lldbplatformutil.match_ohos_device( + obj.getArchitecture(), valid_archs=archs) + return reason if result else None + return impl + + def add_test_categories(cat): """Add test categories to a TestCase method""" cat = test_categories.validate(cat, True) @@ -446,6 +454,21 @@ def expectedFailureAndroid(bugnumber=None, api_levels=None, archs=None): bugnumber) +def expectedFailureOHOS(bugnumber=None, archs=None): + """ Mark a test as xfail for OHOS. + + Arguments: + bugnumber - The LLVM pr associated with the problem. + arch - A sequence of architecture names specifying the architectures + for which a test is expected to fail. None means all architectures. + """ + return expectedFailureIfFn( + _skip_for_ohos( + "xfailing on ohos", + archs), + bugnumber) + + def expectedFailureNetBSD(bugnumber=None): return expectedFailureOS( ['netbsd'], @@ -634,6 +657,10 @@ def skipUnlessTargetAndroid(func): return unittest2.skipUnless(lldbplatformutil.target_is_android(), "requires target to be Android")(func) +def skipUnlessTargetOHOS(func): + return unittest2.skipUnless(lldbplatformutil.target_is_ohos(), + "requires target to be ohos")(func) + def skipIfHostIncompatibleWithRemote(func): """Decorate the item to skip tests if binaries built on this host are incompatible.""" @@ -652,6 +679,8 @@ def skipIfHostIncompatibleWithRemote(func): target_platform, host_platform) if lldbplatformutil.match_android_device(target_arch): return "skipping because target is android" + if lldbplatformutil.match_ohos_device(target_arch): + return "skipping because target is ohos" return None return skipTestIfFn(is_host_incompatible_with_remote)(func) @@ -701,6 +730,13 @@ def skipIfTargetAndroid(bugnumber=None, api_levels=None, archs=None): archs), bugnumber) +def skipIfTargetOHOS(bugnumber=None, archs=None): + return skipTestIfFn( + _skip_for_ohos( + "skipping for ohos", + archs), + bugnumber) + def skipUnlessSupportedTypeAttribute(attr): """Decorate the item to skip test unless Clang supports type __attribute__(attr).""" def compiler_doesnt_support_struct_attribute(self): diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index ee59500a4fc7..82928c5a3f89 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -743,7 +743,7 @@ def canRunLibcxxTests(): platform = lldbplatformutil.getPlatform() - if lldbplatformutil.target_is_android() or lldbplatformutil.platformIsDarwin(): + if lldbplatformutil.target_is_android() or lldbplatformutil.target_is_ohos() or lldbplatformutil.platformIsDarwin(): return True, "libc++ always present" if platform == "linux": diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index fbd6e809ef70..ea4c389c15c7 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -97,6 +97,10 @@ def getPlatform(): return platform[7:] return platform + +def target_is_ohos(): + return getPlatform() == "ohos" + def target_is_android(): return getPlatform() == "android" @@ -133,6 +137,15 @@ def match_android_device(device_arch, valid_archs=None, valid_api_levels=None): return True +def match_ohos_device(device_arch, valid_archs=None): + if not target_is_ohos(): + return False + if valid_archs is not None and device_arch not in valid_archs: + return False + + return True + + def finalize_build_dictionary(dictionary): if target_is_android(): @@ -184,7 +197,7 @@ class _PlatformContext(object): def createPlatformContext(): if platformIsDarwin(): return _PlatformContext('DYLD_LIBRARY_PATH', ':', 'lib', 'dylib') - elif getPlatform() in ("freebsd", "linux", "netbsd"): + elif getPlatform() in ("freebsd", "linux", "netbsd", "ohos"): return _PlatformContext('LD_LIBRARY_PATH', ':', 'lib', 'so') else: return _PlatformContext('PATH', ';', '', 'dll') @@ -195,4 +208,6 @@ def hasChattyStderr(test_case): determines whether the tests can be strict about the expected stderr contents.""" if match_android_device(test_case.getArchitecture(), ['aarch64'], range(22, 25+1)): return True # The dynamic linker on the device will complain about unknown DT entries + if match_ohos_device(test_case.getArchitecture(), ['aarch64']): + return True return False -- Gitee From f455f369d9d99f7931c01fc6fa8f41acf6176d63 Mon Sep 17 00:00:00 2001 From: wuyuanchao Date: Thu, 14 Nov 2024 16:51:12 +0800 Subject: [PATCH 2/2] enable lldb-api for ohos Signed-off-by: wuyuanchao --- lldb/packages/Python/lldbsuite/test/decorators.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index 95964f2056ca..7b7c4c1ddf8f 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -323,7 +323,7 @@ def _skip_for_android(reason, api_levels, archs): return reason if result else None return impl - +# OHOS_LOCAL begin def _skip_for_ohos(reason, archs): def impl(obj): result = lldbplatformutil.match_ohos_device( @@ -737,6 +737,8 @@ def skipIfTargetOHOS(bugnumber=None, archs=None): archs), bugnumber) +# OHOS_LOCAL end + def skipUnlessSupportedTypeAttribute(attr): """Decorate the item to skip test unless Clang supports type __attribute__(attr).""" def compiler_doesnt_support_struct_attribute(self): -- Gitee