Skip to content

Commit

Permalink
try to get timing info
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry committed Sep 20, 2024
1 parent 44dc5bc commit a2a826e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion testing/scripts/gen_initramfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ invoke_bluebox() {

local cmd="bluebox"
cmd+=" -a $goarch"
cmd+=" -e testrunner/testrunner"
cmd+=" -e testrunner/testrunner:-test.v"
cmd+=" -r $eventstrace"
cmd+=" -r $tcfiltertests"
cmd+=" -r $tcfilterbpf"
Expand Down
2 changes: 1 addition & 1 deletion testing/testrunner/ebpf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ func TestEbpf(t *testing.T) {
t.Skip("tests already failed")
}

ctx, cancel := context.WithTimeout(context.Background(), time.Minute*3)
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
defer cancel()
run := NewEbpfRunner(ctx, t, test.args...)
// on return, check for failure. If we've failed, dump stderr and stdout
Expand Down
16 changes: 12 additions & 4 deletions testing/testrunner/ebpfrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"bufio"
"context"
"encoding/json"
"fmt"
"io"
"os/exec"
"strings"
Expand All @@ -32,6 +33,7 @@ type Runner struct {
StderrChan chan string
readChan chan string
doneChan chan struct{}
errChan chan error

InitMsg InitMsg
t *testing.T
Expand All @@ -42,7 +44,7 @@ type Runner struct {
readCursor int
}

func runStreamChannel(t *testing.T, sender chan string, buffer *bufio.Scanner) {
func runStreamChannel(sender chan string, errChan chan error, buffer *bufio.Scanner) {
buf := make([]byte, 0, 64*1024)
buffer.Buffer(buf, 1024*1024)
go func() {
Expand All @@ -55,8 +57,11 @@ func runStreamChannel(t *testing.T, sender chan string, buffer *bufio.Scanner) {

}
}
// the go testing libraries don't like it when you call
// t.Fail() in a child thread; so we have to trickle down the failure
if err := buffer.Err(); err != nil {
t.Logf("scanner error: %s", err)
errChan <- fmt.Errorf("error in buffer: %w", err)
return
}

}
Expand Down Expand Up @@ -96,8 +101,8 @@ func (runner *Runner) Start() {
stderrStream := bufio.NewScanner(runner.Stderr)
stdoutStream := bufio.NewScanner(runner.Stdout)

runStreamChannel(runner.t, runner.StdoutChan, stdoutStream)
runStreamChannel(runner.t, runner.StderrChan, stderrStream)
runStreamChannel(runner.StdoutChan, runner.errChan, stdoutStream)
runStreamChannel(runner.StderrChan, runner.errChan, stderrStream)

go func() {
runner.runIORead()
Expand Down Expand Up @@ -125,6 +130,8 @@ func (runner *Runner) GetNextEventOut(types ...string) string {
select {
case <-ctx.Done():
runner.t.Fatalf("timed out waiting for %v events", types)
case err := <-runner.errChan:
require.NoError(runner.t, err, "error reading from stdout/stderr in buffer")
case line := <-runner.readChan:
var resp baseEvent
err := json.Unmarshal([]byte(line), &resp)
Expand Down Expand Up @@ -171,6 +178,7 @@ func NewEbpfRunner(ctx context.Context, t *testing.T, args ...string) *Runner {
StderrChan: make(chan string, 1024),
readChan: make(chan string, 1024),
doneChan: make(chan struct{}),
errChan: make(chan error, 1),
t: t,
}
args = append(args, "--print-features-on-init", "--unbuffer-stdout", "--libbpf-verbose")
Expand Down

0 comments on commit a2a826e

Please sign in to comment.