1{
2 lib,
3 tracee,
4 makeWrapper,
5}:
6tracee.overrideAttrs (oa: {
7 pname = oa.pname + "-integration";
8 postPatch = oa.postPatch or "" + ''
9 # fix the test to look at nixos paths for running programs
10 # --replace-fail '"integration.tes"' '"tracee-integrat"' \
11 substituteInPlace tests/integration/event_filters_test.go \
12 --replace-fail "exec=/usr/bin/dockerd" "comm=dockerd" \
13 --replace-fail "exec=/usr/bin" "exec=/tmp/testdir" \
14 --replace-fail "/usr/bin/tee" "tee" \
15 --replace-fail "/usr/bin" "/run/current-system/sw/bin" \
16 --replace-fail 'syscallerAbsPath := filepath.Join("..", "..", "dist", "syscaller")' "syscallerAbsPath := filepath.Join(\"$out/bin/syscaller\")"
17 substituteInPlace tests/integration/exec_test.go \
18 --replace-fail "/usr/bin" "/run/current-system/sw/bin"
19 substituteInPlace tests/integration/dependencies_test.go \
20 --replace-fail "/bin" "/run/current-system/sw/bin" \
21 --replace-fail "/tmp/test" "/tmp/ls"
22 substituteInPlace tests/testutils/tracee.go \
23 --replace-fail "../../dist/tracee" "${lib.getExe tracee}"
24 '';
25 nativeBuildInputs = oa.nativeBuildInputs or [ ] ++ [ makeWrapper ];
26 buildPhase = ''
27 runHook preBuild
28 # copy existing built object to dist
29 mkdir -p dist/btfhub
30 touch dist/btfhub/.placeholder
31 cp ${lib.getOutput "lib" tracee}/lib/tracee/tracee.bpf.o ./dist/
32
33 # then compile the tests to be ran later
34 mkdir -p $GOPATH/tracee-integration
35 CGO_LDFLAGS="$(pkg-config --libs libbpf)" go build -o $GOPATH/tracee-integration/syscaller ./tests/integration/syscaller/cmd
36 CGO_LDFLAGS="$(pkg-config --libs libbpf)" go test -tags core,ebpf,integration -c -o $GOPATH/tracee-integration/ ./tests/integration/...
37 runHook postBuild
38 '';
39 doCheck = false;
40 installPhase = ''
41 mkdir -p $out/bin
42 mv $GOPATH/tracee-integration/{integration.test,syscaller} $out/bin/
43 # cp -r ${tracee}/bin/signatures $out/bin/
44 '';
45 doInstallCheck = false;
46
47 outputs = [ "out" ];
48 meta = oa.meta // {
49 outputsToInstall = [ "out" ];
50 };
51})