Skip to content

Commit

Permalink
[test] Add no-valgrind run test option
Browse files Browse the repository at this point in the history
Valgrind on ubuntu 22.04 does not handle all eBPF commands.
It's not because there is some kind of issue with valgrind, but rather there is a problem with ubuntu itself.
I created two new virtual machines, one with debian, and the other one with ubuntu.
On both of them, I installed valgrind from source code, following exactly same procedures on both VMs.
On debian valgrind support all eBPF commands (or at least the commands that nhid uses), on ubuntu following error raise:

```
WARNING: unhandled eBPF command 28
```

Therefore I decided not to run nhid via valgrind on github's ubuntu 22.04 VM.
  • Loading branch information
strang1ato committed Feb 16, 2023
1 parent fe43dd9 commit 0f83bb4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
run: make build-test-daemon

- name: Run tests
run: sudo ./run-tests
run: sudo ./run-tests no-valgrind
2 changes: 1 addition & 1 deletion run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -e

./testing/test-cli
./testing/test-daemon
./testing/test-daemon $1
26 changes: 19 additions & 7 deletions testing/test-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,36 @@ touch $testing_dir/nhid.log
touch $testing_dir/db
cat $testing_dir/original_db > $testing_dir/db

sudo -E valgrind $testing_dir/../nhid 2> $testing_dir/nhid.log &
nhid_ppid="$!"
if [[ "$1" != "no-valgrind" ]]; then
sudo -E valgrind $testing_dir/../nhid 2> $testing_dir/nhid.log &
nhid_ppid="$!"
else
sudo -E $testing_dir/../nhid &
nhid_pid="$!"
fi

sleep 5

echo export PS1=\"my_prompt \" \&\& source $PWD/shell/nhi.bash >> ~/.bashrc

$testing_dir/expect-runner || true

sudo pkill -2 -P "$nhid_ppid"
if [[ "$1" != "no-valgrind" ]]; then
sudo pkill -2 -P "$nhid_ppid"
else
sudo kill -2 "$nhid_pid"
fi

sed -i '$ d' ~/.bashrc

sleep 1
leaked_bytes="$(cat $testing_dir/nhid.log | awk '$2 == "definitely" && $3 == "lost:" { print $4; exit }')"
if [[ "$leaked_bytes" != "0" ]]; then
echo Memory leak with "$leaked_bytes" bytes! 1>&2
end

if [[ "$1" != "no-valgrind" ]]; then
leaked_bytes="$(cat $testing_dir/nhid.log | awk '$2 == "definitely" && $3 == "lost:" { print $4; exit }')"
if [[ "$leaked_bytes" != "0" ]]; then
echo Memory leak with "$leaked_bytes" bytes! 1>&2
end
fi
fi

diff_result="$(diff $testing_dir/expected_output/fetch_after_expect-runner <($testing_dir/../nhi fetch -f {-3}) || true)"
Expand Down

0 comments on commit 0f83bb4

Please sign in to comment.