Skip to content

Commit

Permalink
aws-iot-fleetwise, amazon-s3-gst-plugin, aws-crt-cpp, aws-iot-device-…
Browse files Browse the repository at this point in the history
…sdk-cpp-v2,s2n: improve tests
  • Loading branch information
thomas-roos committed Jan 27, 2025
1 parent 6b8eb29 commit 6dae056
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-test-recipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
40 changes: 33 additions & 7 deletions recipes-iot/aws-iot-fleetwise/aws-iot-fleetwise-edge_1.2.0.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)}"
Original file line number Diff line number Diff line change
@@ -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 <boost/none.hpp>
#include <boost/optional/optional.hpp>
+#include <boost/optional/optional_io.hpp>
#include <cstddef>
#include <cstdint>
#include <gtest/gtest.h>
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 <boost/none.hpp>
#include <boost/optional/optional.hpp>
+#include <boost/optional/optional_io.hpp>
#include <cstdint>
#include <cstring>
#include <gtest/gtest.h>
Index: git/test/unit/ROS2DataSourceTest.cpp
===================================================================
--- git.orig/test/unit/ROS2DataSourceTest.cpp
+++ git/test/unit/ROS2DataSourceTest.cpp
@@ -13,6 +13,7 @@
#include <array>
#include <atomic>
#include <boost/optional/optional.hpp>
+#include <boost/optional/optional_io.hpp>
#include <boost/variant.hpp>
#include <chrono>
#include <cstdint>
16 changes: 16 additions & 0 deletions recipes-iot/aws-iot-fleetwise/files/ptest_result.py
Original file line number Diff line number Diff line change
@@ -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']}")
33 changes: 32 additions & 1 deletion recipes-iot/aws-iot-fleetwise/files/run-ptest
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,20 @@ S = "${WORKDIR}/git"

CXXFLAGS:append = " -Wno-missing-field-initializers"

EXTRA_OECMAKE:append = " -DCMAKE_BUILD_TYPE=RelWithDebInfo"

inherit meson pkgconfig ptest

FILES:${PN} += "\
${libdir}/gstreamer-1.0/* \
${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)}"
3 changes: 3 additions & 0 deletions recipes-multimedia/amazon-s3-gst-plugin/files/run-ptest
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion recipes-sdk/aws-crt-cpp/aws-crt-cpp_0.29.9.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)}"
4 changes: 2 additions & 2 deletions recipes-sdk/aws-sdk-cpp/aws-sdk-cpp_1.11.491.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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)}"
4 changes: 2 additions & 2 deletions recipes-sdk/s2n/s2n_1.5.11.bb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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)}"

0 comments on commit 6dae056

Please sign in to comment.