-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow customizing the base path and don't mount the BPF fs if it is a…
…lready mounted (#741)
- Loading branch information
Showing
12 changed files
with
450 additions
and
7 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
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
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
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
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
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
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,55 @@ | ||
//go:build linux | ||
|
||
package discover | ||
|
||
import ( | ||
"log/slog" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMountBpfPinPath(t *testing.T) { | ||
if os.Getenv(privilegedEnv) == "" { | ||
t.Skipf("Set %s to run this test", privilegedEnv) | ||
} | ||
tmpDir := "path" | ||
ta := &TraceAttacher{ | ||
log: slog.With("component", "discover.TraceAttacher"), | ||
pinPath: tmpDir, | ||
} | ||
|
||
// Nothing there to start the test | ||
mounted, matched, err := IsMountFS(FilesystemTypeBPFFS, tmpDir) | ||
assert.NoError(t, err) | ||
assert.False(t, mounted) | ||
assert.False(t, matched) | ||
|
||
err = ta.mountBpfPinPath() | ||
assert.NoError(t, err) | ||
|
||
// Check that it is mounted | ||
mounted, matched, err = IsMountFS(FilesystemTypeBPFFS, tmpDir) | ||
assert.NoError(t, err) | ||
assert.True(t, mounted) | ||
assert.True(t, matched) | ||
|
||
// Ensure mounting the same path twice does not fail | ||
err = ta.mountBpfPinPath() | ||
assert.NoError(t, err) | ||
|
||
// Check that it is mounted | ||
mounted, matched, err = IsMountFS(FilesystemTypeBPFFS, tmpDir) | ||
assert.NoError(t, err) | ||
assert.True(t, mounted) | ||
assert.True(t, matched) | ||
|
||
ta.unmountBpfPinPath() | ||
|
||
// Check that it is cleaned up | ||
mounted, matched, err = IsMountFS(FilesystemTypeBPFFS, tmpDir) | ||
assert.NoError(t, err) | ||
assert.False(t, mounted) | ||
assert.False(t, matched) | ||
} |
Oops, something went wrong.