From 55ca242314858c0146eccfc5fe7cdbad75d665bd Mon Sep 17 00:00:00 2001 From: Thomas Roos Date: Tue, 21 Jan 2025 12:44:20 +0000 Subject: [PATCH] aws-crt-cpp, aws-lc, aws-sdk-cpp, s2n: improve sanitizer tests Still just enabled for x86-64, but patch to fix it for aarch64 is send out CXXFLAGS:append:aarch64 = " -DSANITIZER_CAN_USE_ALLOCATOR64=0" in gcc-sanitizers.inc (cherry picked from commit 0b56d8f96aa88eb31b3b18ca7b4b9183e244d6ec) --- recipes-sdk/aws-crt-cpp/aws-crt-cpp/run-ptest | 2 +- recipes-sdk/aws-crt-cpp/aws-crt-cpp_0.29.9.bb | 8 +++-- recipes-sdk/aws-lc/aws-lc_1.36.0.bb | 3 ++ .../aws-sdk-cpp/aws-sdk-cpp_1.11.488.bb | 8 +++-- recipes-sdk/aws-sdk-cpp/files/ptest_result.py | 35 +++++++++++++++---- recipes-sdk/s2n/s2n_1.5.11.bb | 13 ++++--- 6 files changed, 50 insertions(+), 19 deletions(-) diff --git a/recipes-sdk/aws-crt-cpp/aws-crt-cpp/run-ptest b/recipes-sdk/aws-crt-cpp/aws-crt-cpp/run-ptest index 4890646e2..b44dde2ff 100644 --- a/recipes-sdk/aws-crt-cpp/aws-crt-cpp/run-ptest +++ b/recipes-sdk/aws-crt-cpp/aws-crt-cpp/run-ptest @@ -68,4 +68,4 @@ do ./aws-crt-cpp-tests $TEST >> tests.log 2>&1 done -sed -e '/\[\s/!d ; /OK/ s/^/PASS: / ; /FAILED/ s/^/FAIL: /' tests.log +sed -e '/\[\s\|==.*==\|runtime error:/!d ; /OK/ s/^/PASS: / ; /FAILED\|ERROR: .*Sanitizer\|runtime error:/ s/^/FAIL: /' tests.log diff --git a/recipes-sdk/aws-crt-cpp/aws-crt-cpp_0.29.9.bb b/recipes-sdk/aws-crt-cpp/aws-crt-cpp_0.29.9.bb index 42eb966e3..ec418441d 100644 --- a/recipes-sdk/aws-crt-cpp/aws-crt-cpp_0.29.9.bb +++ b/recipes-sdk/aws-crt-cpp/aws-crt-cpp_0.29.9.bb @@ -50,6 +50,8 @@ PACKAGECONFIG ?= "\ PACKAGECONFIG:append:x86-64 = " ${@bb.utils.contains('PTEST_ENABLED', '1', 'sanitize', '', d)}" +EXTRA_OECMAKE += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_BUILD_TYPE=Release', d)}" + # enable PACKAGECONFIG = "static" to build static instead of shared libs PACKAGECONFIG[static] = "-DBUILD_SHARED_LIBS=OFF,-DBUILD_SHARED_LIBS=ON,," @@ -75,5 +77,7 @@ do_install_ptest () { # -fsanitize=address does cause this # nooelint: oelint.vars.insaneskip:INSANE_SKIP -INSANE_SKIP:x86-64 += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', 'buildpaths', '', d)}" -PACKAGECONFIG[sanitize] = "-DENABLE_SANITIZERS=ON -DSANITIZERS=address, -DENABLE_SANITIZERS=OFF,gcc-sanitizers" +INSANE_SKIP += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', 'buildpaths', '', d)}" + +PACKAGECONFIG[sanitize] = ",, gcc-sanitizers" +OECMAKE_CXX_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-fsanitize=address -fno-omit-frame-pointer', '', d)}" diff --git a/recipes-sdk/aws-lc/aws-lc_1.36.0.bb b/recipes-sdk/aws-lc/aws-lc_1.36.0.bb index 513c06adf..adf62c07e 100644 --- a/recipes-sdk/aws-lc/aws-lc_1.36.0.bb +++ b/recipes-sdk/aws-lc/aws-lc_1.36.0.bb @@ -29,6 +29,9 @@ PACKAGECONFIG ??= "\ PACKAGECONFIG[with-tests] = "-DBUILD_TESTING=ON -DCMAKE_CROSSCOMPILING=OFF,-DBUILD_TESTING=OFF," # enable PACKAGECONFIG = "static" to build static instead of shared libs +# this will conflict with PTESTS, do disable them in your local.conf +# by setting +# PTEST_ENABLED:pn-aws-lc = "0" PACKAGECONFIG[static] = "-DBUILD_SHARED_LIBS=OFF,-DBUILD_SHARED_LIBS=ON" do_install_ptest () { diff --git a/recipes-sdk/aws-sdk-cpp/aws-sdk-cpp_1.11.488.bb b/recipes-sdk/aws-sdk-cpp/aws-sdk-cpp_1.11.488.bb index 26852666a..f59e4dcbb 100644 --- a/recipes-sdk/aws-sdk-cpp/aws-sdk-cpp_1.11.488.bb +++ b/recipes-sdk/aws-sdk-cpp/aws-sdk-cpp_1.11.488.bb @@ -71,6 +71,8 @@ EXTRA_OECMAKE += "\ -DCMAKE_MODULE_PATH=${STAGING_LIBDIR}/cmake \ " +EXTRA_OECMAKE += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_BUILD_TYPE=Release', d)}" + RDEPENDS:${PN}-ptest += "\ bash \ python3 \ @@ -93,6 +95,6 @@ INSANE_SKIP:${PN}-src:append:class-target:arm = " buildpaths" # -fsanitize=address does cause this # nooelint: oelint.vars.insaneskip:INSANE_SKIP -INSANE_SKIP:x86-64 += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', 'buildpaths', '', d)}" - -PACKAGECONFIG[sanitize] = "'-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer',,gcc-sanitizers" +INSANE_SKIP += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', 'buildpaths', '', d)}" +PACKAGECONFIG[sanitize] = ",,gcc-sanitizers" +OECMAKE_CXX_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-fsanitize=address -fno-omit-frame-pointer', '', d)}" diff --git a/recipes-sdk/aws-sdk-cpp/files/ptest_result.py b/recipes-sdk/aws-sdk-cpp/files/ptest_result.py index c1e3625ee..c4ca92dbc 100644 --- a/recipes-sdk/aws-sdk-cpp/files/ptest_result.py +++ b/recipes-sdk/aws-sdk-cpp/files/ptest_result.py @@ -3,14 +3,37 @@ import json import sys +import re + +def check_sanitizer_failure(test): + # Look for sanitizer errors in system-out or system-err if they exist + system_out = test.get('system-out', '') + system_err = test.get('system-err', '') + + sanitizer_patterns = [ + r'==\d+==ERROR: .*Sanitizer', + r'runtime error:', + r'SUMMARY: .*Sanitizer', + r'ERROR: .*Sanitizer detected' + ] + + for pattern in sanitizer_patterns: + if (re.search(pattern, system_out) or + re.search(pattern, system_err)): + return True + return False if len(sys.argv) != 2: print(f"usage: {sys.argv[0]} [result file]") sys.exit(1) -with open (sys.argv[1], 'rb') as json_file: - data = json.load(json_file) - for testsuite in data['testsuites']: - for test in testsuite['testsuite']: - result = 'PASS' if not 'failures' in test else 'FAIL' - print(f"{result}: {test['classname']}_{test['name']}") +with open(sys.argv[1], 'rb') as json_file: + data = json.load(json_file) + for testsuite in data['testsuites']: + for test in testsuite['testsuite']: + # Check both regular test failures and sanitizer failures + has_failures = 'failures' in test + has_sanitizer_failure = check_sanitizer_failure(test) + + result = 'FAIL' if (has_failures or has_sanitizer_failure) else 'PASS' + print(f"{result}: {test['classname']}_{test['name']}") \ No newline at end of file diff --git a/recipes-sdk/s2n/s2n_1.5.11.bb b/recipes-sdk/s2n/s2n_1.5.11.bb index 038699430..88afea742 100644 --- a/recipes-sdk/s2n/s2n_1.5.11.bb +++ b/recipes-sdk/s2n/s2n_1.5.11.bb @@ -30,18 +30,17 @@ PACKAGECONFIG ?= "\ ${@bb.utils.contains('PTEST_ENABLED', '1', 'with-tests', '', d)} \ " -PACKAGECONFIG:append:x86-64 = "\ - ${@bb.utils.contains('PTEST_ENABLED', '1', 'sanitize', '', d)} \ - " +PACKAGECONFIG:append:x86-64 = " ${@bb.utils.contains('PTEST_ENABLED', '1', 'sanitize', '', d)}" # enable PACKAGECONFIG = "static" to build static instead of shared libs PACKAGECONFIG[static] = "-DBUILD_SHARED_LIBS=OFF,-DBUILD_SHARED_LIBS=ON" PACKAGECONFIG[with-tests] = "-DBUILD_TESTING=ON,-DBUILD_TESTING=OFF," -EXTRA_OECMAKE += "\ - -DCMAKE_BUILD_TYPE=Release \ -" +PACKAGECONFIG[sanitize] = "-DS2N_ADDRESS_SANITIZER=ON, -DS2N_ADDRESS_SANITIZER=OFF, gcc-sanitizers" + +EXTRA_OECMAKE += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_BUILD_TYPE=Release', d)}" + # Fix "doesn't have GNU_HASH (didn't pass LDFLAGS?)" issue TARGET_CC_ARCH += "${LDFLAGS}" @@ -63,4 +62,4 @@ do_install_ptest () { BBCLASSEXTEND = "native nativesdk" -PACKAGECONFIG[sanitize] = "-DS2N_ADDRESS_SANITIZER=ON, -DS2N_ADDRESS_SANITIZER=OFF, gcc-sanitizers" +OECMAKE_CXX_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-fsanitize=address', '', d)}"