88package monitor
99
1010import (
11- "os"
1211 "os/exec"
1312 "sync"
1413 "testing"
@@ -21,7 +20,6 @@ import (
2120
2221 "github.com/DataDog/datadog-agent/pkg/eventmonitor/consumers/testutil"
2322 "github.com/DataDog/datadog-agent/pkg/network/protocols/telemetry"
24- "github.com/DataDog/datadog-agent/pkg/util/filesystem"
2523 netnsutil "github.com/DataDog/datadog-agent/pkg/util/kernel/netns"
2624)
2725
@@ -113,17 +111,6 @@ func registerCallback(t *testing.T, pm *ProcessMonitor, isExec bool, callback *P
113111 return unsubscribe
114112}
115113
116- func getTestBinaryPath (t * testing.T ) string {
117- tmpFile , err := os .CreateTemp ("" , "echo" )
118- require .NoError (t , err )
119- t .Cleanup (func () {
120- os .Remove (tmpFile .Name ())
121- })
122- require .NoError (t , filesystem .CopyFile ("/bin/echo" , tmpFile .Name ()))
123-
124- return tmpFile .Name ()
125- }
126-
127114func TestProcessMonitorSingleton (t * testing.T ) {
128115 // Making sure we get the same process monitor if we call it twice.
129116 pm := getProcessMonitor (t )
@@ -140,7 +127,6 @@ type processMonitorSuite struct {
140127func (s * processMonitorSuite ) TestProcessMonitorSanity () {
141128 t := s .T ()
142129 pm := getProcessMonitor (t )
143- testBinaryPath := getTestBinaryPath (t )
144130
145131 execRecorder := newPidRecorder ()
146132 registerCallback (t , pm , true , getProcessCallback (execRecorder ))
@@ -149,7 +135,7 @@ func (s *processMonitorSuite) TestProcessMonitorSanity() {
149135 registerCallback (t , pm , false , getProcessCallback (exitRecorder ))
150136
151137 initializePM (t , pm , s .useEventStream )
152- cmd := exec .Command (testBinaryPath , "test" )
138+ cmd := exec .Command ("/bin/echo" , "test" )
153139 require .NoError (t , cmd .Run ())
154140 require .EventuallyWithT (t , func (ct * assert.CollectT ) {
155141 assert .Truef (ct , execRecorder .has (uint32 (cmd .Process .Pid )), "didn't capture exec event %d" , cmd .Process .Pid )
0 commit comments