From a201c568d82e65ca27ff18ee23eb6a809f3924a7 Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Tue, 18 Oct 2022 11:09:42 +0200 Subject: bpftrace: Simplify ptest script and use posix syntax Signed-off-by: Michal Wojcik --- .../recipes-devtools/bpftrace/bpftrace/run-ptest | 59 ++++++++++------------ .../recipes-devtools/bpftrace/bpftrace_0.16.0.bb | 3 +- 2 files changed, 29 insertions(+), 33 deletions(-) (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 index aa582e4..bab3033 100644 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/run-ptest +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/run-ptest @@ -1,53 +1,50 @@ -#!/bin/bash +#!/bin/sh # 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 +cd tests || exit 1 export BPFTRACE_RUNTIME_TEST_EXECUTABLE=/usr/bin PASS_CNT=0 FAIL_CNT=0 SKIP_CNT=0 -FAILED=() +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:+$FAILED }$1;" + fi + } + +IFS=$(printf '\n\t') # 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 +for test_name in $(./bpftrace_test --gtest_list_tests | grep -v "^ "); do + ./bpftrace_test --gtest_filter="${test_name}*" > /dev/null 2>&1 + print_test_result "unit:$test_name" done # Start runtime tests -for test_case in $(ls runtime); do +for test_name 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}") + if [ "$test_name" = "signals" ] || [ "$test_name" = "watchpoint" ]; then + echo "SKIP: runtime:$test_name" + SKIP_CNT=$((SKIP_CNT + 1)) + continue fi + python3 runtime/engine/main.py --filter="${test_name}.*" > /dev/null 2>&1 + print_test_result "runtime:$test_name" done +unset IFS echo "#### bpftrace tests summary ####" -echo "# TOTAL: $(($PASS_CNT + $FAIL_CNT + $SKIP_CNT))" +echo "# TOTAL: $((PASS_CNT + FAIL_CNT + SKIP_CNT))" echo "# PASS: $PASS_CNT" -echo "# FAIL: $FAIL_CNT (${FAILED[*]})" +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 0c0ea2a..ca324bc 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 @@ -15,7 +15,6 @@ DEPENDS += "bison-native \ PV .= "+git${SRCREV}" RDEPENDS:${PN} += "bash python3 xz" -RDEPENDS:${PN}-ptest += "bash" SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ file://run-ptest \ @@ -37,7 +36,7 @@ PACKAGECONFIG[tests] = "-DBUILD_TESTING=ON,-DBUILD_TESTING=OFF,gtest xxd-native" do_install_ptest() { if [ -e ${B}/tests/bpftrace_test ]; then install -Dm 755 ${B}/tests/bpftrace_test ${D}${PTEST_PATH}/tests/bpftrace_test - cp -rf ${B}/tests/runtime* ${D}${PTEST_PATH}/tests + cp -rf ${B}/tests/runtime ${D}${PTEST_PATH}/tests cp -rf ${B}/tests/test* ${D}${PTEST_PATH}/tests fi } -- cgit v1.2.3-54-g00ecf