MCPcopy
hub / github.com/google/gvisor / TestWait

Function TestWait

pkg/eventfd/eventfd_test.go:44–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestWait(t *testing.T) {
45 efd, err := Create()
46 if err != nil {
47 t.Fatalf("failed to Create(): %v", err)
48 }
49 defer efd.Close()
50
51 // There's no way to test with certainty that Wait() blocks indefinitely, but
52 // as a best-effort we can wait a bit on it.
53 errCh := make(chan error)
54 go func() {
55 errCh <- efd.Wait()
56 }()
57 select {
58 case err := <-errCh:
59 t.Fatalf("Wait() returned without a call to Notify(): %v", err)
60 case <-time.After(500 * time.Millisecond):
61 }
62
63 // Notify and check that Wait() returned.
64 if err := efd.Notify(); err != nil {
65 t.Fatalf("Notify() failed: %v", err)
66 }
67 select {
68 case err := <-errCh:
69 if err != nil {
70 t.Fatalf("Read() failed: %v", err)
71 }
72 case <-time.After(5 * time.Second):
73 t.Fatalf("Read() did not return after Notify()")
74 }
75}

Callers

nothing calls this directly

Calls 6

CreateFunction · 0.70
FatalfMethod · 0.65
CloseMethod · 0.65
WaitMethod · 0.65
AfterMethod · 0.45
NotifyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…