Skip to content

Commit a2a826e

Browse files
try to get timing info
1 parent 44dc5bc commit a2a826e

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

testing/scripts/gen_initramfs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ invoke_bluebox() {
7878

7979
local cmd="bluebox"
8080
cmd+=" -a $goarch"
81-
cmd+=" -e testrunner/testrunner"
81+
cmd+=" -e testrunner/testrunner:-test.v"
8282
cmd+=" -r $eventstrace"
8383
cmd+=" -r $tcfiltertests"
8484
cmd+=" -r $tcfilterbpf"

testing/testrunner/ebpf_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ func TestEbpf(t *testing.T) {
636636
t.Skip("tests already failed")
637637
}
638638

639-
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*3)
639+
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
640640
defer cancel()
641641
run := NewEbpfRunner(ctx, t, test.args...)
642642
// on return, check for failure. If we've failed, dump stderr and stdout

testing/testrunner/ebpfrunner.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"bufio"
1414
"context"
1515
"encoding/json"
16+
"fmt"
1617
"io"
1718
"os/exec"
1819
"strings"
@@ -32,6 +33,7 @@ type Runner struct {
3233
StderrChan chan string
3334
readChan chan string
3435
doneChan chan struct{}
36+
errChan chan error
3537

3638
InitMsg InitMsg
3739
t *testing.T
@@ -42,7 +44,7 @@ type Runner struct {
4244
readCursor int
4345
}
4446

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

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

6267
}
@@ -96,8 +101,8 @@ func (runner *Runner) Start() {
96101
stderrStream := bufio.NewScanner(runner.Stderr)
97102
stdoutStream := bufio.NewScanner(runner.Stdout)
98103

99-
runStreamChannel(runner.t, runner.StdoutChan, stdoutStream)
100-
runStreamChannel(runner.t, runner.StderrChan, stderrStream)
104+
runStreamChannel(runner.StdoutChan, runner.errChan, stdoutStream)
105+
runStreamChannel(runner.StderrChan, runner.errChan, stderrStream)
101106

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

0 commit comments

Comments
 (0)