1 import ./make-test-python.nix ({ pkgs, ... }: {
2 name = "tracee-integration";
4 machine = { config, pkgs, ... }: {
5 # EventFilters/trace_only_events_from_new_containers requires docker
6 # podman with docker compat will suffice
7 virtualisation.podman.enable = true;
8 virtualisation.podman.dockerCompat = true;
10 environment.systemPackages = [
11 # build the go integration tests as a binary
12 (pkgs.tracee.overrideAttrs (oa: {
13 pname = oa.pname + "-integration";
14 patches = oa.patches or [] ++ [
15 # change the prefix from /usr/bin to /run to find nix processes
16 ../../pkgs/tools/security/tracee/test-EventFilters-prefix-nix-friendly.patch
20 # just build the static lib we need for the go test binary
21 make $makeFlags ''${enableParallelBuilding:+-j$NIX_BUILD_CORES -l$NIX_BUILD_CORES} bpf-core ./dist/btfhub
23 # remove the /usr/bin prefix to work with the patch above
24 substituteInPlace tests/integration/integration_test.go \
25 --replace "/usr/bin/ls" "ls"
27 # then compile the tests to be ran later
28 CGO_LDFLAGS="$(pkg-config --libs libbpf)" go test -tags core,ebpf,integration -p 1 -c -o $GOPATH/tracee-integration ./tests/integration/...
34 cp $GOPATH/tracee-integration $out/bin
36 doInstallCheck = false;
43 with subtest("run integration tests"):
44 # EventFilters/trace_only_events_from_new_containers also requires a container called "alpine"
45 machine.succeed('tar cv -C ${pkgs.pkgsStatic.busybox} . | podman import - alpine --change ENTRYPOINT=sleep')
47 print(machine.succeed('TRC_BIN="${pkgs.tracee}" tracee-integration -test.v'))