Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
geyslan committed Feb 14, 2023
1 parent 21fe7cd commit 08b5956
Show file tree
Hide file tree
Showing 5 changed files with 952 additions and 628 deletions.
15 changes: 13 additions & 2 deletions tests/integration/common.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package integration

import (
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strings"

Expand All @@ -14,9 +16,14 @@ 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, " ")
pattern := `'[^']*'|\S+` // split on spaces, but not spaces inside single quotes
re := regexp.MustCompile(pattern)
vals := re.FindAllString(fullCmd, -1)

cmd := vals[0] // as separator is a space, split will always return at least one element
if len(vals) == 0 {
return nil, nil, fmt.Errorf("no command specified")
}
cmd := vals[0]
cmd, err := exec.LookPath(cmd)
if err != nil {
return nil, nil, err
Expand All @@ -32,6 +39,10 @@ func execCommand(fullCmd string) (*os.Process, []byte, error) {
if len(vals) > 1 {
args = vals[1:]
}
// remove single quotes from args, since they can confuse exec.Command
for i, arg := range args {
args[i] = strings.Trim(arg, "'")
}

// set the affinity of the thread to a specific CPU,
// making sure that the events will be generated in order
Expand Down
Loading

0 comments on commit 08b5956

Please sign in to comment.