diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index dc553938e1cceabfb4b31bb993cc0ae25fc4edc0..7b7c4c1ddf8f9c8a0fa440a59209be9f514b0426 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -323,6 +323,14 @@ 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( + 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""" @@ -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,15 @@ 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) + +# 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): diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index ee59500a4fc7f11e7a999d06d02e37781314832d..82928c5a3f896437495f49ee36e2c809ebf21fe9 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 fbd6e809ef708097ef63d593a9e86a89cf65c7cc..ea4c389c15c7d82a1ac04149c9d4a0646ed3839b 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