Skip to content

Commit

Permalink
tools: allow keeping tools for old kernels
Browse files Browse the repository at this point in the history
Many of the tools rely on kprobes and internal kernel structs which are
not stable. This means that tools may break with newer kernel versions
and bpftrace syntax does not always allow to support all kernels within
a single script.

This introduces a new directory tools/old/ which will contain versions
of tools for older kernels.

Since the container images used in CI may require some of the old tool
versions, this also introduces a new env variable TOOLS_TEST_OLDVERSION
which makes tools-parsing-test.sh use old versions of chosen tools.
  • Loading branch information
viktormalik authored and fbs committed Feb 22, 2022
1 parent 45b951a commit 5db4ea1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ jobs:
-e CC="${CC}"
-e CXX="${CXX}"
-e GTEST_FILTER="$GTEST_FILTER"
-e TOOLS_TEST_OLDVERSION="$TOOLS_TEST_OLDVERSION"
bpftrace-builder-$BASE-llvm-$LLVM_VERSION
${PWD}/build-$TYPE-$BASE
$TYPE
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/embedded.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ jobs:
-e RUNTIME_TEST_DISABLE="${RUNTIME_TEST_DISABLE}"
-e VENDOR_GTEST="${VENDOR_GTEST}"
-e BUILD_LIBBPF="${BUILD_LIBBPF}"
-e TOOLS_TEST_OLDVERSION="$TOOLS_TEST_OLDVERSION"
bpftrace-embedded-${{ matrix.env['BASE'] }}
$(pwd)/build-embedded ${TYPE}
-j`nproc`
Expand Down
15 changes: 11 additions & 4 deletions tests/tools-parsing-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ EXIT_STATUS=0;

TOOLDIR=""

OLDTOOLS=${TOOLS_TEST_OLDVERSION:-}

function tooldir() {
for dir in "../../tools" "/vagrant/tools"; do
if [[ -d "$dir" ]]; then
Expand All @@ -30,11 +32,16 @@ function tooldir() {
tooldir

for f in "$TOOLDIR"/*.bt; do
if $BPFTRACE_EXECUTABLE --unsafe -d $f 2>/dev/null >/dev/null; then
echo "$f passed"
if [[ $OLDTOOLS =~ $(basename $f) ]]; then
tool=$(dirname $f)/old/$(basename $f)
else
tool=$f
fi
if $BPFTRACE_EXECUTABLE --unsafe -d $tool 2>/dev/null >/dev/null; then
echo "$tool passed"
else
echo "$f failed";
$BPFTRACE_EXECUTABLE --unsafe -d $f;
echo "$tool failed";
$BPFTRACE_EXECUTABLE --unsafe -d $tool;
EXIT_STATUS=1;
fi
done
Expand Down
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ file(GLOB TXT_FILES *.txt)
list(REMOVE_ITEM TXT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
install(FILES ${BT_FILES} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/bpftrace/tools)
install(FILES ${TXT_FILES} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/bpftrace/tools/doc)
add_subdirectory(old)
2 changes: 2 additions & 0 deletions tools/old/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
file(GLOB BT_FILES *.bt)
install(FILES ${BT_FILES} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/bpftrace/tools/old)

0 comments on commit 5db4ea1

Please sign in to comment.