type MakePipe … // TestConn tests that a net.Conn implementation properly satisfies the interface. // The tests should not produce any false positives, but may experience // false negatives. Thus, some issues may only be detected when the test is // run multiple times. For maximal effectiveness, run the tests under the // race detector. func TestConn(t *testing.T, mp MakePipe) { … } type connTester … func timeoutWrapper(t *testing.T, mp MakePipe, f connTester) { … } // testBasicIO tests that the data sent on c1 is properly received on c2. func testBasicIO(t *testing.T, c1, c2 net.Conn) { … } // testPingPong tests that the two endpoints can synchronously send data to // each other in a typical request-response pattern. func testPingPong(t *testing.T, c1, c2 net.Conn) { … } // testRacyRead tests that it is safe to mutate the input Read buffer // immediately after cancelation has occurred. func testRacyRead(t *testing.T, c1, c2 net.Conn) { … } // testRacyWrite tests that it is safe to mutate the input Write buffer // immediately after cancelation has occurred. func testRacyWrite(t *testing.T, c1, c2 net.Conn) { … } // testReadTimeout tests that Read timeouts do not affect Write. func testReadTimeout(t *testing.T, c1, c2 net.Conn) { … } // testWriteTimeout tests that Write timeouts do not affect Read. func testWriteTimeout(t *testing.T, c1, c2 net.Conn) { … } // testPastTimeout tests that a deadline set in the past immediately times out // Read and Write requests. func testPastTimeout(t *testing.T, c1, c2 net.Conn) { … } // testPresentTimeout tests that a past deadline set while there are pending // Read and Write operations immediately times out those operations. func testPresentTimeout(t *testing.T, c1, c2 net.Conn) { … } // testFutureTimeout tests that a future deadline will eventually time out // Read and Write operations. func testFutureTimeout(t *testing.T, c1, c2 net.Conn) { … } // testCloseTimeout tests that calling Close immediately times out pending // Read and Write operations. func testCloseTimeout(t *testing.T, c1, c2 net.Conn) { … } // testConcurrentMethods tests that the methods of net.Conn can safely // be called concurrently. func testConcurrentMethods(t *testing.T, c1, c2 net.Conn) { … } // checkForTimeoutError checks that the error satisfies the Error interface // and that Timeout returns true. func checkForTimeoutError(t *testing.T, err error) { … } // testRoundtrip writes something into c and reads it back. // It assumes that everything written into c is echoed back to itself. func testRoundtrip(t *testing.T, c net.Conn) { … } // resyncConn resynchronizes the connection into a sane state. // It assumes that everything written into c is echoed back to itself. // It assumes that 0xff is not currently on the wire or in the read buffer. func resyncConn(t *testing.T, c net.Conn) { … } // chunkedCopy copies from r to w in fixed-width chunks to avoid // causing a Write that exceeds the maximum packet size for packet-based // connections like "unixpacket". // We assume that the maximum packet size is at least 1024. func chunkedCopy(w io.Writer, r io.Reader) error { … }