Skip to content

Commit

Permalink
fix: add installBcc test, change variable name, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Bailey committed Apr 19, 2024
1 parent 8cf4db0 commit 3bbb8b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 44 deletions.
8 changes: 4 additions & 4 deletions vhdbuilder/packer/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ ls -ltr /opt/gpu/* >> ${VHD_LOGS_FILEPATH}
installBpftrace
echo " - $(bpftrace --version)" >> ${VHD_LOGS_FILEPATH}

PARENT_DIR=$(pwd)

PRESENT_DIR=$(pwd)
# run installBcc in a subshell and continue on with container image pull in order to decrease total build time
(
cd $PARENT_DIR || { echo "Subshell in the wrong directory" >&2; exit 1; }
cd $PRESENT_DIR || { echo "Subshell in the wrong directory" >&2; exit 1; }

installBcc

exit $?
) > /tmp/bcc.log 2>&1 &
) > /var/log/bcc_installation.log 2>&1 &

BCC_PID=$!

Expand Down
51 changes: 11 additions & 40 deletions vhdbuilder/packer/test/linux-vhd-content-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -858,48 +858,19 @@ testContainerImagePrefetchScript() {
return 0
}

testBccTools() {

os="$1"
executable=0
not_executable=0
declare -a notExecutableTools=()

for tool in /usr/share/bcc/tools/*; do
if [ -x "$tool" ]; then
executable=$((executable + 1))
testBccTools () {
result=0
for line in '- bcc-tools' '- libbcc-examples'; do
if ! grep -F -x -e "$line" vhd-logs.log; then
echo "$line is missing"
result=1
fi
done
if [ $result -eq 0 ]; then
exit 0
else
not_executable=$((not_executable + 1))
notExecutableTools+=("$tool")
echo "Not Executable: $tool"
fi
done

echo "Total tools: $((not_executable + executable))"
echo "Executable Tools: $executable"
echo "Not Executable Tools: $not_executable"

if [ "$os" == "Ubuntu" ]; then
if [ "$executable" -ne 127 ] || [ "$not_executable" -ne 2 ]; then
echo "Tool numbers don't match expected output."
return 1
fi
else
if [ "$executable" -ne 131 ] || [ "$not_executable" -ne 2 ]; then
echo "Tool numbers don't match expected output."
return 1
fi
fi

for tool in "${notExecutableTools[@]}"; do
if [[ ! "$tool" == *.c ]]; then
echo "Failed: tool $tool is not a .c file"
return 1
exit 1
fi
done

echo "All Bcc tools tests passed."
return 0
}


Expand Down

0 comments on commit 3bbb8b5

Please sign in to comment.