Skip to content

Commit 1ed8049

Browse files
authored
Handle go test generated executable name in itest/kprobe_test.go (#69)
When newer `go test` runs, it writes the executable to a temporary path (under `/tmp`) under the name `itest.test`. However, if the same test executable is compiled and executed from the project directory the executable name has an underscore. This PR updates the itest to accept both. Signed-off-by: Dan Fuhry <[email protected]>
1 parent 0f54c5f commit 1ed8049

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

itest/kprobe_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ func (ts *kprobeTestSuite) TestKprobeEvents() {
134134
case data := <-perfCh:
135135
switch i {
136136
case 0:
137-
ts.Require().Equal("itest_test", cstring(data)) // parent comm
137+
// Allow both an underscore and dot here.
138+
// When `go test` runs this, it's written to a temporary path
139+
// like `/tmp/go-build3999159532/b001/itest.test`.
140+
// If directly compiled, the executable will be
141+
// named `./itest_test`.
142+
ts.Require().Regexp("^itest[_\\.]test$", cstring(data)) // parent comm
138143
case 1:
139144
ts.Require().Equal("whoami", cstring(data)) // child comm
140145
}

0 commit comments

Comments
 (0)