Skip to content

Commit

Permalink
tests: add new test suite for the modern probe
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <[email protected]>
  • Loading branch information
Andreagit97 authored and poiana committed Jan 17, 2023
1 parent 88c7af6 commit 5076613
Show file tree
Hide file tree
Showing 3 changed files with 412 additions and 0 deletions.
6 changes: 6 additions & 0 deletions userspace/libscap/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ set(LIBSCAP_UNIT_TESTS_SOURCES
scap_event.ut.cpp
)

# Modern BPF is supported only on kernel versions >= 5.8.
# To compile these tests you need to use the Cmake option `BUILD_LIBSCAP_MODERN_BPF=On`
if(BUILD_LIBSCAP_MODERN_BPF)
list(APPEND LIBSCAP_UNIT_TESTS_SOURCES ./test_suites/engines/modern_bpf/modern_bpf.cpp)
endif()

if (BUILD_LIBSCAP_GVISOR)
list(APPEND LIBSCAP_UNIT_TESTS_SOURCES scap_gvisor_parsers.ut.cpp)
include_directories(../engine/gvisor)
Expand Down
20 changes: 20 additions & 0 deletions userspace/libscap/test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Scap tests

## Compile tests

```bash
cmake -DUSE_BUNDLED_DEPS=On -DBUILD_BPF=True -DCREATE_TEST_TARGETS=On -DBUILD_LIBSCAP_GVISOR=Off ..
make unit-test-libscap
```

You can add tests for specific engines using their Cmake options:
- `-DBUILD_LIBSCAP_MODERN_BPF=On`
- `-BUILD_LIBSCAP_GVISOR=On`

## Run tests

From the build directory:

```bash
sudo ./libscap/test/unit-test-libscap
```
Loading

0 comments on commit 5076613

Please sign in to comment.