From b062a1f718d19aa1fc8e3d923d11d7117628ecba Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Fri, 30 Sep 2022 13:19:41 +0200 Subject: bpftrace: Add ptest support Use existing bpftrace unit and runtime tests and parse their results in ptest form. Running whole suite may take up to 40 minutes, so running it with "ptest-runner -t 2400 bpftrace" is recommended. Signed-off-by: Michal Wojcik --- .../recipes-devtools/bpftrace/bpftrace/run-ptest | 53 ++++++++++++++++++++++ .../recipes-devtools/bpftrace/bpftrace_0.16.0.bb | 17 +++++-- 2 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/run-ptest (limited to 'dynamic-layers') diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/run-ptest b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/run-ptest new file mode 100644 index 0000000..aa582e4 --- /dev/null +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/run-ptest @@ -0,0 +1,53 @@ +#!/bin/bash + +# The whole test suite may take up to 40 minutes to run, so setting -t 2400 +# parameter in ptest-runner is necessary to not kill it before completion + +cd tests +export BPFTRACE_RUNTIME_TEST_EXECUTABLE=/usr/bin + +PASS_CNT=0 +FAIL_CNT=0 +SKIP_CNT=0 +FAILED=() + +# Start unit tests +for test_case in $(./bpftrace_test --gtest_list_tests | grep -v "^ "); do + if ./bpftrace_test --gtest_filter="${test_case}*" > /dev/null 2>&1 ; then + echo PASS: Unit test $test_case + PASS_CNT=$(($PASS_CNT + 1)) + else + echo FAIL: Unit test $test_case + FAIL_CNT=$(($FAIL_CNT + 1)) + FAILED+=("unit:${test_case}") + fi +done + +# Start runtime tests +for test_case in $(ls runtime); do + # Ignore test cases that hang the suite forever (bpftrace v0.16.0) + case $test_case in + signals) + ;& + watchpoint) + echo SKIP: Runtime test $test_case + SKIP_CNT=$(($SKIP_CNT + 1)) + continue + ;; + esac + if ./runtime-tests.sh --filter="${test_case}.*" > /dev/null 2>&1 ; then + echo PASS: Runtime test $test_case + PASS_CNT=$(($PASS_CNT + 1)) + else + echo FAIL: Runtime test $test_case + FAIL_CNT=$(($FAIL_CNT + 1)) + FAILED+=("runtime:${test_case}") + fi +done + +echo "#### bpftrace tests summary ####" +echo "# TOTAL: $(($PASS_CNT + $FAIL_CNT + $SKIP_CNT))" +echo "# PASS: $PASS_CNT" +echo "# FAIL: $FAIL_CNT (${FAILED[*]})" +echo "# SKIP: $SKIP_CNT" +echo "################################" diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb index 7e8ec73..556722c 100644 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb @@ -13,15 +13,26 @@ DEPENDS += "bison-native \ libbpf \ " +DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'gtest xxd-native', '', d)}" PV .= "+git${SRCREV}" RDEPENDS:${PN} += "bash python3 xz" +RDEPENDS:${PN}-ptest += "bash" -SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https" +SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ + file://run-ptest \ +" SRCREV = "a277ec42102c463d656df8f64eb2f7e87e322210" S = "${WORKDIR}/git" -inherit cmake +inherit cmake ptest + +do_install_ptest() { + install -d ${D}${PTEST_PATH}/tests + install -m 755 ${B}/tests/bpftrace_test ${D}${PTEST_PATH}/tests + cp -rf ${B}/tests/runtime* ${D}${PTEST_PATH}/tests + cp -rf ${B}/tests/test* ${D}${PTEST_PATH}/tests +} def llvm_major_version(d): pvsplit = d.getVar('LLVMVERSION').split('.') @@ -33,9 +44,9 @@ EXTRA_OECMAKE = " \ -DCMAKE_ENABLE_EXPORTS=1 \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_REQUESTED_VERSION=${LLVM_MAJOR_VERSION} \ - -DBUILD_TESTING=OFF \ -DENABLE_MAN=OFF \ " +EXTRA_OECMAKE += "${@bb.utils.contains('PTEST_ENABLED', '1', '-DBUILD_TESTING=ON', '-DBUILD_TESTING=OFF', d)}" COMPATIBLE_HOST = "(x86_64.*|aarch64.*|powerpc64.*|riscv64.*)-linux" COMPATIBLE_HOST:libc-musl = "null" -- cgit v1.2.3-54-g00ecf