-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dynamic Instrumentation] DI proctracker should not inspect itself (#…
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
pkg/dynamicinstrumentation/proctracker/proctracker_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
//go:build linux_bpf | ||
|
||
package proctracker | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestProcessNotAdded(t *testing.T) { | ||
pt := ProcessTracker{ | ||
processes: make(map[pid]binaryID), | ||
} | ||
|
||
// Use the current process ID for testing | ||
pid := uint32(os.Getpid()) | ||
|
||
// Simulate process start | ||
pt.inspectBinary("", pid) | ||
|
||
// Ensure the process ID is not added to pt.processes | ||
pt.lock.RLock() | ||
defer pt.lock.RUnlock() | ||
_, exists := pt.processes[pid] | ||
assert.False(t, exists, "process ID should not be added to pt.processes") | ||
} |