Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport styhead-next] aws-crt-cpp, aws-lc, aws-sdk-cpp, s2n: enable sanitizer tests for all… #11166

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion recipes-sdk/aws-crt-cpp/aws-crt-cpp/run-ptest
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions recipes-sdk/aws-crt-cpp/aws-crt-cpp_0.29.9.bb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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"

Expand All @@ -74,5 +76,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)}"
3 changes: 3 additions & 0 deletions recipes-sdk/aws-lc/aws-lc_1.42.0.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
8 changes: 5 additions & 3 deletions recipes-sdk/aws-sdk-cpp/aws-sdk-cpp_1.11.488.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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)}"
35 changes: 29 additions & 6 deletions recipes-sdk/aws-sdk-cpp/files/ptest_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']}")
13 changes: 6 additions & 7 deletions recipes-sdk/s2n/s2n_1.5.11.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand All @@ -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)}"
Loading