From 6b2dc79d07f7c67684b82e46c9665f78eca0d021 Mon Sep 17 00:00:00 2001 From: DmitrievVadim Date: Wed, 3 Apr 2024 11:54:02 +0300 Subject: [PATCH] [OHOS][compiler-rt][test] Enable UBSan testing remotely on OHOS devices Issue: https://gitee.com/openharmony/third_party_llvm-project/issues/I9D4T3 Signed-off-by: DmitrievVadim --- .../test/sanitizer_common/ohos_family_commands/ohos_run.py | 4 ++-- .../test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py | 2 +- compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp | 3 ++- compiler-rt/test/ubsan/TestCases/Misc/no-interception.cpp | 6 ++++++ .../test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg.py | 2 +- compiler-rt/test/ubsan/lit.common.cfg.py | 2 +- compiler-rt/test/ubsan_minimal/lit.common.cfg.py | 2 +- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_run.py b/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_run.py index 675e064fa8ff..1bdd8ea33771 100755 --- a/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_run.py +++ b/compiler-rt/test/sanitizer_common/ohos_family_commands/ohos_run.py @@ -45,8 +45,8 @@ def build_env(): if san_opt: value += ':abort_on_error=0' if key in ['ASAN_ACTIVATION_OPTIONS', 'SCUDO_OPTIONS'] or san_opt or key == 'LD_LIBRARY_PATH': - if key == 'TSAN_OPTIONS': - # Map TSan suppressions file to device + if key in ['TSAN_OPTIONS', 'UBSAN_OPTIONS']: + # Map TSan or UBSan suppressions file to device value = map_list(value, ':', r'(?<=suppressions=)(.+)', lambda m: (m.group(1), True)) elif key == 'LD_LIBRARY_PATH': # Map LD_LIBRARY_PATH to device diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py b/compiler-rt/test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py index 57271b8078a4..ce7ce5ddde93 100644 --- a/compiler-rt/test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py +++ b/compiler-rt/test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py @@ -5,5 +5,5 @@ def getRoot(config): root = getRoot(config) -if root.host_os not in ['Linux']: +if root.host_os not in ['Linux', 'OHOS']: # OHOS_LOCAL config.unsupported = True diff --git a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp index 4a94350ec162..e80552ec7434 100644 --- a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp +++ b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp @@ -21,7 +21,8 @@ // RUN: %env_ubsan_opts=coverage=1:verbosity=1:coverage_dir='"%t-dir"' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN // Coverage is not yet implemented in TSan. -// XFAIL: ubsan-tsan +// OHOS_LOCAL +// XFAIL: ubsan-tsan && !ohos_family // UNSUPPORTED: ubsan-standalone-static // No coverage support // UNSUPPORTED: openbsd diff --git a/compiler-rt/test/ubsan/TestCases/Misc/no-interception.cpp b/compiler-rt/test/ubsan/TestCases/Misc/no-interception.cpp index c82fed3bf3f6..23ec69459616 100644 --- a/compiler-rt/test/ubsan/TestCases/Misc/no-interception.cpp +++ b/compiler-rt/test/ubsan/TestCases/Misc/no-interception.cpp @@ -10,6 +10,12 @@ // RUN: %clangxx %s -lc -o %t %ld_flags_rpath_exe // RUN: %run %t 2>&1 | FileCheck %s +// OHOS_LOCAL begin +// For OHOS the test build commands result in a runtime error with a missing +// symbol message. +// UNSUPPORTED: ohos_family +// OHOS_LOCAL end + #include int dso_function(int); diff --git a/compiler-rt/test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg.py b/compiler-rt/test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg.py index 57271b8078a4..ce7ce5ddde93 100644 --- a/compiler-rt/test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg.py +++ b/compiler-rt/test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg.py @@ -5,5 +5,5 @@ def getRoot(config): root = getRoot(config) -if root.host_os not in ['Linux']: +if root.host_os not in ['Linux', 'OHOS']: # OHOS_LOCAL config.unsupported = True diff --git a/compiler-rt/test/ubsan/lit.common.cfg.py b/compiler-rt/test/ubsan/lit.common.cfg.py index 7108561a92c4..214833e240d6 100644 --- a/compiler-rt/test/ubsan/lit.common.cfg.py +++ b/compiler-rt/test/ubsan/lit.common.cfg.py @@ -68,7 +68,7 @@ config.substitutions.append( ("%gmlt ", " ".join(config.debug_info_flags) + " ") config.suffixes = ['.c', '.cpp', '.m'] # Check that the host supports UndefinedBehaviorSanitizer tests -if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'Windows', 'NetBSD', 'SunOS', 'OpenBSD']: +if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'Windows', 'NetBSD', 'SunOS', 'OpenBSD', 'OHOS']: # OHOS_LOCAL config.unsupported = True config.available_features.add('arch=' + config.target_arch) diff --git a/compiler-rt/test/ubsan_minimal/lit.common.cfg.py b/compiler-rt/test/ubsan_minimal/lit.common.cfg.py index 39800c968dbf..3455908413f4 100644 --- a/compiler-rt/test/ubsan_minimal/lit.common.cfg.py +++ b/compiler-rt/test/ubsan_minimal/lit.common.cfg.py @@ -30,7 +30,7 @@ config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags config.suffixes = ['.c', '.cpp'] # Check that the host supports UndefinedBehaviorSanitizerMinimal tests -if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD', 'SunOS']: # TODO: Windows +if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD', 'SunOS', 'OHOS']: # OHOS_LOCAL # TODO: Windows config.unsupported = True # Don't target x86_64h if the test machine can't execute x86_64h binaries. -- Gitee