-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: mscope: make scopes tests more robust
- add checkEvents generic function to check if all events are received - add common.go with execCommand function that ensures execution of a command in the same cpu - add waitForTraceeOutputEvents function to wait for tracee output events until buffer fills with certain number of events or timeout occurs - remove do_ls_uname tester.sh function as a start to concentrate all scopes tests in scopes_test.go - create syscaller tool to easily generate syscalls from the command line
- Loading branch information
Showing
9 changed files
with
568 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,5 @@ compile_commands.json | |
.vagrant | ||
|
||
# binaries and build files | ||
dist | ||
dist | ||
syscaller |
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,49 @@ | ||
package integration | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"runtime" | ||
"strings" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
const cpuID = 0 // CPU to pin the process to | ||
|
||
// execCommand executes a command pinning it to a specific CPU and returns the process and its stdout | ||
func execCommand(fullCmd string) (*os.Process, []byte, error) { | ||
vals := strings.Split(fullCmd, " ") | ||
|
||
cmd := vals[0] // as separator is a space, split will always return at least one element | ||
cmd, err := exec.LookPath(cmd) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
if !filepath.IsAbs(cmd) { | ||
cmd, err = filepath.Abs(cmd) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
} | ||
|
||
args := []string{} | ||
if len(vals) > 1 { | ||
args = vals[1:] | ||
} | ||
|
||
// set the affinity of the thread to a specific CPU, | ||
// making sure that the events will be generated in order | ||
cpuMask := unix.CPUSet{} | ||
cpuMask.Set(cpuID) | ||
unix.SchedSetaffinity(0, &cpuMask) | ||
runtime.LockOSThread() // also wire the calling goroutine to the same CPU | ||
|
||
c := exec.Command(cmd, args...) | ||
stdout, err := c.Output() | ||
|
||
runtime.UnlockOSThread() | ||
|
||
return c.Process, stdout, err | ||
} |
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
Oops, something went wrong.