From 6dae05651fd5329f12b01b02249556bdf6ee5d26 Mon Sep 17 00:00:00 2001 From: Thomas Roos Date: Mon, 27 Jan 2025 11:05:55 +0000 Subject: [PATCH] aws-iot-fleetwise, amazon-s3-gst-plugin, aws-crt-cpp, aws-iot-device-sdk-cpp-v2,s2n: improve tests --- .github/workflows/build-test-recipe.yml | 6 +-- .../aws-iot-fleetwise-edge_1.2.0.bb | 40 +++++++++++++++---- ...rd.patch => 001-remove-cxx-standard.patch} | 0 .../files/002-fleetwise-config-test.patch | 38 ++++++++++++++++++ .../aws-iot-fleetwise/files/ptest_result.py | 16 ++++++++ recipes-iot/aws-iot-fleetwise/files/run-ptest | 33 ++++++++++++++- .../amazon-s3-gst-plugin_git.bb | 10 +++++ .../amazon-s3-gst-plugin/files/run-ptest | 3 ++ recipes-sdk/aws-crt-cpp/aws-crt-cpp_0.29.9.bb | 2 +- ...-device-sdk-cpp-v2-samples-mqtt5-pubsub.bb | 10 +++++ .../aws-iot-device-sdk-cpp-v2/run-ptest | 2 + .../aws-iot-device-sdk-cpp-v2_1.34.0.bb | 14 ++++++- .../aws-sdk-cpp/aws-sdk-cpp_1.11.491.bb | 4 +- recipes-sdk/s2n/s2n_1.5.11.bb | 4 +- 14 files changed, 164 insertions(+), 18 deletions(-) rename recipes-iot/aws-iot-fleetwise/files/{remove-cxx-standard.patch => 001-remove-cxx-standard.patch} (100%) create mode 100644 recipes-iot/aws-iot-fleetwise/files/002-fleetwise-config-test.patch create mode 100644 recipes-iot/aws-iot-fleetwise/files/ptest_result.py diff --git a/.github/workflows/build-test-recipe.yml b/.github/workflows/build-test-recipe.yml index a7d910a39..39881a72b 100644 --- a/.github/workflows/build-test-recipe.yml +++ b/.github/workflows/build-test-recipe.yml @@ -112,7 +112,7 @@ jobs: source poky/oe-init-build-env build echo QEMU_USE_KVM = \"\" >> conf/local.conf # set to the same as core-image-ptest - echo QB_MEM = \"-m 1024\" >> conf/local.conf + echo QB_MEM = \"-m 2G\" >> conf/local.conf # use slirp networking instead of TAP interface (require root rights) echo QEMU_USE_SLIRP = \"1\" >> conf/local.conf echo TEST_RUNQEMUPARAMS += \"slirp\" >> conf/local.conf @@ -121,7 +121,7 @@ jobs: echo DISTRO = \"poky-altcfg\" >> conf/local.conf # this will specify what test should run when running testimage cmd - oeqa layer tests + ptests: # Ping and SSH are not required, but do help in debugging. ptest will discover all ptest packages. - echo TEST_SUITES = \" ping ssh ptest\" >> conf/local.conf + echo TEST_SUITES = \" ping ssh ptest parselogs\" >> conf/local.conf # this will allow - running testimage cmd: bitbake core-image-minimal -c testimage echo IMAGE_CLASSES += \"testimage\" >> conf/local.conf cat conf/local.conf @@ -141,7 +141,7 @@ jobs: if grep -A3 -E ' failed| ERROR:' "build/${{ matrix.machine }}-build.log"; then echo "Found failed or ERROR in build log" exit 1 - fi + fi else echo "Build log file not found: build/${{ matrix.machine }}-build.log" exit 1 diff --git a/recipes-iot/aws-iot-fleetwise/aws-iot-fleetwise-edge_1.2.0.bb b/recipes-iot/aws-iot-fleetwise/aws-iot-fleetwise-edge_1.2.0.bb index e34b64a19..92997f95b 100644 --- a/recipes-iot/aws-iot-fleetwise/aws-iot-fleetwise-edge_1.2.0.bb +++ b/recipes-iot/aws-iot-fleetwise/aws-iot-fleetwise-edge_1.2.0.bb @@ -17,25 +17,37 @@ DEPENDS = "\ # nooelint: oelint.file.patchsignedoff SRC_URI = "\ - git://github.com/aws/aws-iot-fleetwise-edge.git;protocol=https;branch=main \ - file://remove-cxx-standard.patch \ - file://run-ptest \ - " + git://github.com/aws/aws-iot-fleetwise-edge.git;protocol=https;branch=main \ + file://001-remove-cxx-standard.patch \ + file://002-fleetwise-config-test.patch \ + file://run-ptest \ + " SRCREV = "4c74c61a5001037f3979f6dbe74a72abd2ec4e76" S = "${WORKDIR}/git" -inherit cmake systemd ptest +inherit cmake systemd ptest pkgconfig FILES:${PN} += "${systemd_system_unitdir}" -RDEPENDS:${PN} = "protobuf" +PACKAGECONFIG ?= "\ + ${@bb.utils.contains('PTEST_ENABLED', '1', 'with-tests', '', d)} \ + " -EXTRA_OECMAKE += "-DBUILD_TESTING=OFF" +PACKAGECONFIG:append:x86-64 = " ${@bb.utils.contains('PTEST_ENABLED', '1', 'sanitize', '', d)}" + +PACKAGECONFIG[pulseaudio] = "-DPULSEAUDIO=TRUE, -DPULSEAUDIO=FALSE, pulseaudio" + +# CMAKE_CROSSCOMPILING=OFF will enable build of unit tests +PACKAGECONFIG[with-tests] = "-DBUILD_TESTING=ON,-DBUILD_TESTING=OFF, googlebenchmark" + +RDEPENDS:${PN} = "protobuf" EXTRA_OECMAKE += "-DFWE_AWS_SDK_SHARED_LIBS=ON" +EXTRA_OECMAKE:append = " -DCMAKE_BUILD_TYPE=RelWithDebInfo" + SYSTEMD_SERVICE:${PN} = "fwe@.service" # Default values for configure-fwe @@ -86,5 +98,19 @@ do_install() { } do_install_ptest() { + install -d ${D}${PTEST_PATH}/tests install -m 0755 ${S}/configuration/static-config.json ${D}${PTEST_PATH}/config-0.json + install -m 0755 ${B}/fwe-gtest ${D}${PTEST_PATH}/tests/ + install -m 0755 ${B}/fwe-benchmark ${D}${PTEST_PATH}/tests/ } + +RDEPENDS:${PN}-ptest += "\ + python3 \ +" + +# -fsanitize=address does cause this +# nooelint: oelint.vars.insaneskip:INSANE_SKIP +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-iot/aws-iot-fleetwise/files/remove-cxx-standard.patch b/recipes-iot/aws-iot-fleetwise/files/001-remove-cxx-standard.patch similarity index 100% rename from recipes-iot/aws-iot-fleetwise/files/remove-cxx-standard.patch rename to recipes-iot/aws-iot-fleetwise/files/001-remove-cxx-standard.patch diff --git a/recipes-iot/aws-iot-fleetwise/files/002-fleetwise-config-test.patch b/recipes-iot/aws-iot-fleetwise/files/002-fleetwise-config-test.patch new file mode 100644 index 000000000..893b756c6 --- /dev/null +++ b/recipes-iot/aws-iot-fleetwise/files/002-fleetwise-config-test.patch @@ -0,0 +1,38 @@ +Upstream-Status: Submitted [author] + +Index: git/test/unit/IoTFleetWiseConfigTest.cpp +=================================================================== +--- git.orig/test/unit/IoTFleetWiseConfigTest.cpp ++++ git/test/unit/IoTFleetWiseConfigTest.cpp +@@ -6,6 +6,7 @@ + #include "Testing.h" + #include + #include ++#include + #include + #include + #include +Index: git/test/unit/RawDataManagerTest.cpp +=================================================================== +--- git.orig/test/unit/RawDataManagerTest.cpp ++++ git/test/unit/RawDataManagerTest.cpp +@@ -7,6 +7,7 @@ + #include "TimeTypes.h" + #include + #include ++#include + #include + #include + #include +Index: git/test/unit/ROS2DataSourceTest.cpp +=================================================================== +--- git.orig/test/unit/ROS2DataSourceTest.cpp ++++ git/test/unit/ROS2DataSourceTest.cpp +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/recipes-iot/aws-iot-fleetwise/files/ptest_result.py b/recipes-iot/aws-iot-fleetwise/files/ptest_result.py new file mode 100644 index 000000000..c1e3625ee --- /dev/null +++ b/recipes-iot/aws-iot-fleetwise/files/ptest_result.py @@ -0,0 +1,16 @@ +# Copyright (c) 2022 Amazon.com, Inc. or its affiliates. +# SPDX-License-Identifier: MIT + +import json +import sys + +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']}") diff --git a/recipes-iot/aws-iot-fleetwise/files/run-ptest b/recipes-iot/aws-iot-fleetwise/files/run-ptest index b1cc20f81..d90a3dded 100755 --- a/recipes-iot/aws-iot-fleetwise/files/run-ptest +++ b/recipes-iot/aws-iot-fleetwise/files/run-ptest @@ -9,4 +9,35 @@ if [ $RETVAL -eq 0 ] ; then echo "PASS: aws-iot-fleetwise startup test" else echo "FAIL: aws-iot-fleetwise startup test" -fi \ No newline at end of file +fi + +### fwe-gtest +tests/fwe-gtest --gtest_filter=\ +-AwsIotConnectivityModuleTest*:\ +-CANDecoderTest*:\ +-CANDataSourceTest.*:\ +-CollectionInspectionEngine*:\ +-CollectionInspectionWorkerThreadTest.*:\ +-IoTFleetWiseConfigTest.ReadOk:\ +-IoTFleetWiseEngineTest.*:\ +-CollectionInspectionEngineDoubleTest.RandomDataTest\ +-ISOTPOverCANProtocolTest.*:\ +-OBDOverCANModuleTest.* \ +--gtest_fail_fast --gtest_output=json:result.json > /dev/null ; python3 ptest_result.py result.json + + +### fwe-benchmark +cd tests + +rm -rf tests.log + +./fwe-benchmark >> tests.log 2>&1 + +RETVAL=$? +sed -e '/\[\s\|==.*==\|runtime error:/!d ; /OK/ s/^/PASS: / ; /FAILED\|ERROR: .*Sanitizer\|runtime error:/ s/^/FAIL: /' tests.log + +if [ $RETVAL -eq 0 ] ; then + echo "PASS: fwe-benchmark test" +else + echo "FAIL: fwe-benchmark test" +fi diff --git a/recipes-multimedia/amazon-s3-gst-plugin/amazon-s3-gst-plugin_git.bb b/recipes-multimedia/amazon-s3-gst-plugin/amazon-s3-gst-plugin_git.bb index 85137be11..76fac633f 100644 --- a/recipes-multimedia/amazon-s3-gst-plugin/amazon-s3-gst-plugin_git.bb +++ b/recipes-multimedia/amazon-s3-gst-plugin/amazon-s3-gst-plugin_git.bb @@ -23,6 +23,8 @@ S = "${WORKDIR}/git" CXXFLAGS:append = " -Wno-missing-field-initializers" +EXTRA_OECMAKE:append = " -DCMAKE_BUILD_TYPE=RelWithDebInfo" + inherit meson pkgconfig ptest FILES:${PN} += "\ @@ -30,3 +32,11 @@ FILES:${PN} += "\ ${libdir}/libgstawscredentials-1.0.so \ " FILES_SOLIBSDEV = "" + +PACKAGECONFIG:append:x86-64 = " ${@bb.utils.contains('PTEST_ENABLED', '1', 'sanitize', '', d)}" +# -fsanitize=address does cause this +# nooelint: oelint.vars.insaneskip:INSANE_SKIP +# INSANE_SKIP += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', 'buildpaths', '', d)}" + +PACKAGECONFIG[sanitize] = ",, gcc-sanitizers" +OECMAKE_CXX_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-fsanitize=address,undefined -fno-omit-frame-pointer', '', d)}" \ No newline at end of file diff --git a/recipes-multimedia/amazon-s3-gst-plugin/files/run-ptest b/recipes-multimedia/amazon-s3-gst-plugin/files/run-ptest index a77dda6cb..e6f5a5e20 100644 --- a/recipes-multimedia/amazon-s3-gst-plugin/files/run-ptest +++ b/recipes-multimedia/amazon-s3-gst-plugin/files/run-ptest @@ -1,4 +1,7 @@ #!/bin/sh + +export LD_PRELOAD=$(find /usr/lib /lib -type f -name "libasan.so*") + gst-inspect-1.0 s3sink > test.log RETVAL=$? cat test.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 143950832..4502df6ee 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 @@ -79,4 +79,4 @@ do_install_ptest () { 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)}" +OECMAKE_CXX_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-fsanitize=address,undefined -fno-omit-frame-pointer', '', d)}" diff --git a/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2-samples-mqtt5-pubsub.bb b/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2-samples-mqtt5-pubsub.bb index eb849b0c4..3d41d5397 100644 --- a/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2-samples-mqtt5-pubsub.bb +++ b/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2-samples-mqtt5-pubsub.bb @@ -10,3 +10,13 @@ do_install() { # nooelint: oelint.vars.insaneskip:INSANE_SKIP INSANE_SKIP:${PN}-dbg += "buildpaths" + +EXTRA_OECMAKE:append = " -DCMAKE_BUILD_TYPE=RelWithDebInfo" + +PACKAGECONFIG:append:x86-64 = " ${@bb.utils.contains('PTEST_ENABLED', '1', 'sanitize', '', d)}" +# -fsanitize=address does cause this +# nooelint: oelint.vars.insaneskip:INSANE_SKIP +# INSANE_SKIP += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', 'buildpaths', '', d)}" + +PACKAGECONFIG[sanitize] = ",, gcc-sanitizers" +OECMAKE_CXX_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-fsanitize=address,undefined -fno-omit-frame-pointer', '', d)}" diff --git a/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2/run-ptest b/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2/run-ptest index 24d73b8d3..c0f703b27 100644 --- a/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2/run-ptest +++ b/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2/run-ptest @@ -1,5 +1,7 @@ #!/bin/sh +export LD_PRELOAD=$(find /usr/lib /lib -type f -name "libasan.so*") + mqtt5_pubsub --help RETVAL=$? if [ $RETVAL -eq 255 ] ; then diff --git a/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2_1.34.0.bb b/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2_1.34.0.bb index 0b7a95171..a0311dea8 100644 --- a/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2_1.34.0.bb +++ b/recipes-sdk/aws-iot-device-sdk-cpp-v2/aws-iot-device-sdk-cpp-v2_1.34.0.bb @@ -36,9 +36,10 @@ FILES_SOLIBSDEV = "" PACKAGECONFIG[static] = "-DBUILD_SHARED_LIBS=OFF,-DBUILD_SHARED_LIBS=ON" PACKAGECONFIG ??= "\ - ${@bb.utils.contains('PTEST_ENABLED', '1', 'with-tests', '', d)} \ - " + ${@bb.utils.contains('PTEST_ENABLED', '1', 'with-tests', '', d)} \ + " PACKAGECONFIG[with-tests] = "-DBUILD_TESTING=ON,-DBUILD_TESTING=OFF," +PACKAGECONFIG:append:x86-64 = " ${@bb.utils.contains('PTEST_ENABLED', '1', 'sanitize', '', d)}" FILES:${PN}-dev += "${libdir}/*/cmake" @@ -47,3 +48,12 @@ RDEPENDS:${PN}-ptest:prepend = "\ " BBCLASSEXTEND = "native nativesdk" + +EXTRA_OECMAKE:append = " -DCMAKE_BUILD_TYPE=RelWithDebInfo" + +# -fsanitize=address does cause this +# nooelint: oelint.vars.insaneskip:INSANE_SKIP +INSANE_SKIP += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', 'buildpaths', '', d)}" + +PACKAGECONFIG[sanitize] = ",, gcc-sanitizers" +OECMAKE_CXX_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-fsanitize=address,undefined -fno-omit-frame-pointer', '', d)}" diff --git a/recipes-sdk/aws-sdk-cpp/aws-sdk-cpp_1.11.491.bb b/recipes-sdk/aws-sdk-cpp/aws-sdk-cpp_1.11.491.bb index 8c0b51df8..b8b160242 100644 --- a/recipes-sdk/aws-sdk-cpp/aws-sdk-cpp_1.11.491.bb +++ b/recipes-sdk/aws-sdk-cpp/aws-sdk-cpp_1.11.491.bb @@ -71,7 +71,7 @@ EXTRA_OECMAKE += "\ -DCMAKE_MODULE_PATH=${STAGING_LIBDIR}/cmake \ " -EXTRA_OECMAKE += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_BUILD_TYPE=Release', d)}" +EXTRA_OECMAKE:append = " -DCMAKE_BUILD_TYPE=RelWithDebInfo" RDEPENDS:${PN}-ptest += "\ bash \ @@ -97,4 +97,4 @@ INSANE_SKIP:${PN}-src:append:class-target:arm = " buildpaths" # nooelint: oelint.vars.insaneskip:INSANE_SKIP 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)}" +OECMAKE_CXX_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-fsanitize=address,undefined -fno-omit-frame-pointer', '', d)}" diff --git a/recipes-sdk/s2n/s2n_1.5.11.bb b/recipes-sdk/s2n/s2n_1.5.11.bb index 88afea742..383b0a214 100644 --- a/recipes-sdk/s2n/s2n_1.5.11.bb +++ b/recipes-sdk/s2n/s2n_1.5.11.bb @@ -39,7 +39,7 @@ PACKAGECONFIG[with-tests] = "-DBUILD_TESTING=ON,-DBUILD_TESTING=OFF," 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)}" +EXTRA_OECMAKE:append = " -DCMAKE_BUILD_TYPE=RelWithDebInfo" # Fix "doesn't have GNU_HASH (didn't pass LDFLAGS?)" issue TARGET_CC_ARCH += "${LDFLAGS}" @@ -62,4 +62,4 @@ do_install_ptest () { BBCLASSEXTEND = "native nativesdk" -OECMAKE_CXX_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-fsanitize=address', '', d)}" +OECMAKE_CXX_FLAGS += "${@bb.utils.contains('PACKAGECONFIG', 'sanitize', '-fsanitize=address,undefined', '', d)}"