From e8fd396155e1f8a5cdb57e7abd0c1eb698635371 Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Fri, 14 Oct 2022 15:29:41 +0200 Subject: bcc: Add ptest support Use bcc cc and python test suites and parse their results in ptest form. Running whole suite on qemu may take up to 25 minutes, so running it with "ptest-runner -t 1800 bcc" is recommended. Signed-off-by: Michal Wojcik --- .../recipes-devtools/bcc/bcc/ptest_wrapper.sh | 16 +++++++++ .../recipes-devtools/bcc/bcc/run-ptest | 42 ++++++++++++++++++++++ .../recipes-devtools/bcc/bcc_0.25.0.bb | 13 ++++++- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/ptest_wrapper.sh create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/run-ptest (limited to 'dynamic-layers') diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/ptest_wrapper.sh b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/ptest_wrapper.sh new file mode 100644 index 0000000..92d0156 --- /dev/null +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/ptest_wrapper.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# Simple OE specific wrapper for bcc python tests + +name=$1 +kind=$2 +cmd=$3 +shift 3 + +case $kind in + simple|sudo) + $cmd "$@" + ;; + *) + echo "Invalid kind $kind of test $name" + exit 1 +esac diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/run-ptest b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/run-ptest new file mode 100644 index 0000000..a27f697 --- /dev/null +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/run-ptest @@ -0,0 +1,42 @@ +#!/bin/sh + +cd tests || exit 1 + +PASS_CNT=0 +FAIL_CNT=0 +FAILED="" + +print_test_result() { + if [ $? -eq 0 ]; then + echo PASS: "$1" + PASS_CNT=$((PASS_CNT + 1)) + else + echo FAIL: "$1" + FAIL_CNT=$((FAIL_CNT + 1)) + FAILED="$FAILED $1;" + fi +} + +# Run CC tests, set IFS as test names have spaces +IFS=$(printf '\n\t') +for test_name in $(./cc/test_libbcc_no_libbpf --list-test-names-only); do + ./cc/test_libbcc_no_libbpf "$test_name" > /dev/null 2>&1 + print_test_result "cc $test_name" +done +unset IFS + +# Run python tests, skip namespace tests as they currently don't work +if cmake -DCMAKE_TESTING_ENABLED=ON -DTEST_WRAPPER="$(pwd)/ptest_wrapper.sh" python > /dev/null 2>&1; then + for test_name in $(awk -F '[( ]' '/^add_test/ && !/namespace/ {print $2}' CTestTestfile.cmake); do + ctest -Q -R "$test_name" + print_test_result "python $test_name" + done +else + print_test_result "cmake error, couldn't start python tests" +fi + +echo "#### bcc tests summary ####" +echo "# TOTAL: $((PASS_CNT + FAIL_CNT))" +echo "# PASS: $PASS_CNT" +echo "# FAIL: $FAIL_CNT ($FAILED)" +echo "###########################" diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.25.0.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.25.0.bb index 31ef5c2..cdacbb2 100644 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.25.0.bb +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.25.0.bb @@ -3,7 +3,7 @@ HOMEPAGE = "https://github.com/iovisor/bcc" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c29e" -inherit cmake python3native manpages +inherit cmake python3native manpages ptest DEPENDS += "bison-native \ flex-native \ @@ -20,12 +20,15 @@ LUAJIT:powerpc64 = "" LUAJIT:riscv64 = "" RDEPENDS:${PN} += "bash python3 python3-core python3-setuptools xz" +RDEPENDS:${PN}-ptest = "cmake python3 python3-distutils python3-netaddr python3-pyroute2" SRC_URI = "gitsm://github.com/iovisor/bcc;branch=master;protocol=https \ file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \ file://0001-tools-trace.py-Fix-failing-to-exit.patch \ file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \ file://0001-Vendor-just-enough-extra-headers-to-allow-libbpf-to-.patch \ + file://run-ptest \ + file://ptest_wrapper.sh \ " SRCREV = "711f03024d776d174874b1f833dac0597f22a49a" @@ -54,6 +57,14 @@ do_install:append() { -i $(find ${D}${datadir}/${PN} -type f) } +do_install_ptest() { + install -d ${D}${PTEST_PATH}/tests/cc + install ${B}/tests/cc/test_libbcc_no_libbpf ${B}/tests/cc/libusdt_test_lib.so ${D}${PTEST_PATH}/tests/cc + cp -rf ${S}/tests/python ${D}${PTEST_PATH}/tests/python + install ${WORKDIR}/ptest_wrapper.sh ${D}${PTEST_PATH}/tests + install ${S}/examples/networking/simulation.py ${D}${PTEST_PATH}/tests/python +} + FILES:${PN} += "${PYTHON_SITEPACKAGES_DIR}" FILES:${PN}-doc += "${datadir}/${PN}/man" -- cgit v1.2.3-54-g00ecf