MCPcopy
hub / github.com/tailscale/tailscale / waitLogLine

Function waitLogLine

cmd/containerboot/main_test.go:1415–1429  ·  view source on GitHub ↗

waitLogLine looks for want in the contents of b. Only lines starting with 'boot: ' (the output of containerboot itself) are considered, and the logged timestamp is ignored. waitLogLine fails the entire test if path doesn't contain want before the timeout.

(t *testing.T, timeout time.Duration, b *lockingBuffer, want string)

Source from the content-addressed store, hash-verified

1413// waitLogLine fails the entire test if path doesn't contain want
1414// before the timeout.
1415func waitLogLine(t *testing.T, timeout time.Duration, b *lockingBuffer, want string) {
1416 deadline := time.Now().Add(timeout)
1417 for time.Now().Before(deadline) {
1418 for line := range strings.SplitSeq(b.String(), "\n") {
1419 if !strings.HasPrefix(line, "boot: ") {
1420 continue
1421 }
1422 if strings.HasSuffix(line, " "+want) {
1423 return
1424 }
1425 }
1426 time.Sleep(100 * time.Millisecond)
1427 }
1428 t.Fatalf("timed out waiting for wanted output line %q. Output:\n%s", want, b.String())
1429}
1430
1431// waitArgs waits until the contents of path matches wantArgs, a set
1432// of command lines recorded by test_tailscale.sh and

Callers 1

TestContainerBootFunction · 0.85

Calls 5

BeforeMethod · 0.80
AddMethod · 0.65
NowMethod · 0.65
StringMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…