(t *testing.T)
| 56 | } |
| 57 | |
| 58 | func TestConnectionWrite(t *testing.T) { |
| 59 | cycle, caps := 10000, 256 |
| 60 | msg, buf := make([]byte, caps), make([]byte, caps) |
| 61 | var wg sync.WaitGroup |
| 62 | wg.Add(1) |
| 63 | var count int32 |
| 64 | expect := int32(cycle * caps) |
| 65 | opts := &options{} |
| 66 | opts.onRequest = func(ctx context.Context, connection Connection) error { |
| 67 | n, err := connection.Read(buf) |
| 68 | MustNil(t, err) |
| 69 | if atomic.AddInt32(&count, int32(n)) >= expect { |
| 70 | wg.Done() |
| 71 | } |
| 72 | return nil |
| 73 | } |
| 74 | |
| 75 | r, w := GetSysFdPairs() |
| 76 | rconn, wconn := &connection{}, &connection{} |
| 77 | rconn.init(&netFD{fd: r}, opts) |
| 78 | wconn.init(&netFD{fd: w}, opts) |
| 79 | |
| 80 | for i := 0; i < cycle; i++ { |
| 81 | n, err := wconn.Write(msg) |
| 82 | MustNil(t, err) |
| 83 | Equal(t, n, len(msg)) |
| 84 | } |
| 85 | wg.Wait() |
| 86 | Equal(t, atomic.LoadInt32(&count), expect) |
| 87 | rconn.Close() |
| 88 | } |
| 89 | |
| 90 | func TestConnectionLargeWrite(t *testing.T) { |
| 91 | // ci machine don't have 4GB memory, so skip test |
nothing calls this directly
no test coverage detected
searching dependent graphs…