nettest

Imports

Imports #

"syscall"
"syscall"
"bytes"
"encoding/binary"
"io"
"math/rand"
"net"
"runtime"
"sync"
"testing"
"time"
"errors"
"fmt"
"net"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
"sync"
"time"

Constants & Variables

aLongTimeAgo var #

var aLongTimeAgo = *ast.CallExpr

canListenTCP4OnLoopback var #

var canListenTCP4OnLoopback bool

canListenTCP6OnLoopback var #

var canListenTCP6OnLoopback bool

errNoAvailableAddress var #

var errNoAvailableAddress = *ast.CallExpr

errNoAvailableInterface var #

var errNoAvailableInterface = *ast.CallExpr

ipv4Enabled var #

var ipv4Enabled bool

ipv6Enabled var #

var ipv6Enabled bool

neverTimeout var #

var neverTimeout = time.Time{...}

rawSocketSess var #

var rawSocketSess bool

stackOnce var #

var stackOnce sync.Once

unStrmDgramEnabled var #

var unStrmDgramEnabled bool

Type Aliases

MakePipe type #

MakePipe creates a connection between two endpoints and returns the pair as c1 and c2, such that anything written to c1 is read by c2 and vice-versa. The stop function closes all resources, including c1, c2, and the underlying net.Listener (if there is one), and should not be nil.

type MakePipe func() (c1 net.Conn, c2 net.Conn, stop func(), err error)

connTester type #

type connTester func(t *testing.T, c1 net.Conn, c2 net.Conn)

Functions

LocalPath function #

LocalPath returns a local path that can be used for Unix-domain protocol testing.

func LocalPath() (string, error)

LoopbackInterface function #

LoopbackInterface returns an available logical network interface for loopback test.

func LoopbackInterface() (*net.Interface, error)

MulticastSource function #

MulticastSource returns a unicast IP address on ifi when ifi is an IP multicast-capable network interface. The provided network must be "ip", "ip4" or "ip6".

func MulticastSource(network string, ifi *net.Interface) (net.IP, error)

NewLocalListener function #

NewLocalListener returns a listener which listens to a loopback IP address or local file system path. The provided network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".

func NewLocalListener(network string) (net.Listener, error)

NewLocalPacketListener function #

NewLocalPacketListener returns a packet listener which listens to a loopback IP address or local file system path. The provided network must be "udp", "udp4", "udp6" or "unixgram".

func NewLocalPacketListener(network string) (net.PacketConn, error)

RoutedInterface function #

RoutedInterface returns a network interface that can route IP traffic and satisfies flags. The provided network must be "ip", "ip4" or "ip6".

func RoutedInterface(network string, flags net.Flags) (*net.Interface, error)

SupportsIPv4 function #

SupportsIPv4 reports whether the platform supports IPv4 networking functionality.

func SupportsIPv4() bool

SupportsIPv6 function #

SupportsIPv6 reports whether the platform supports IPv6 networking functionality.

func SupportsIPv6() bool

SupportsRawSocket function #

SupportsRawSocket reports whether the current session is available to use raw sockets.

func SupportsRawSocket() bool

checkForTimeoutError function #

checkForTimeoutError checks that the error satisfies the Error interface and that Timeout returns true.

func checkForTimeoutError(t *testing.T, err error)

chunkedCopy function #

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

hasRoutableIP function #

func hasRoutableIP(network string, ifi *net.Interface) (net.IP, bool)

probeStack function #

func probeStack()

resyncConn function #

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)

routableIP function #

func routableIP(network string, ip net.IP) (net.IP, bool)

supportsRawSocket function #

func supportsRawSocket() bool

supportsRawSocket function #

func supportsRawSocket() bool

supportsRawSocket function #

func supportsRawSocket() bool

testBasicIO function #

testBasicIO tests that the data sent on c1 is properly received on c2.

func testBasicIO(t *testing.T, c1 net.Conn, c2 net.Conn)

testCloseTimeout function #

testCloseTimeout tests that calling Close immediately times out pending Read and Write operations.

func testCloseTimeout(t *testing.T, c1 net.Conn, c2 net.Conn)

testConcurrentMethods function #

testConcurrentMethods tests that the methods of net.Conn can safely be called concurrently.

func testConcurrentMethods(t *testing.T, c1 net.Conn, c2 net.Conn)

testFutureTimeout function #

testFutureTimeout tests that a future deadline will eventually time out Read and Write operations.

func testFutureTimeout(t *testing.T, c1 net.Conn, c2 net.Conn)

testPastTimeout function #

testPastTimeout tests that a deadline set in the past immediately times out Read and Write requests.

func testPastTimeout(t *testing.T, c1 net.Conn, c2 net.Conn)

testPingPong function #

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 net.Conn, c2 net.Conn)

testPresentTimeout function #

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 net.Conn, c2 net.Conn)

testRacyRead function #

testRacyRead tests that it is safe to mutate the input Read buffer immediately after cancelation has occurred.

func testRacyRead(t *testing.T, c1 net.Conn, c2 net.Conn)

testRacyWrite function #

testRacyWrite tests that it is safe to mutate the input Write buffer immediately after cancelation has occurred.

func testRacyWrite(t *testing.T, c1 net.Conn, c2 net.Conn)

testReadTimeout function #

testReadTimeout tests that Read timeouts do not affect Write.

func testReadTimeout(t *testing.T, c1 net.Conn, c2 net.Conn)

testRoundtrip function #

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)

testWriteTimeout function #

testWriteTimeout tests that Write timeouts do not affect Read.

func testWriteTimeout(t *testing.T, c1 net.Conn, c2 net.Conn)

timeoutWrapper function #

func timeoutWrapper(t *testing.T, mp MakePipe, f connTester)

unixStrmDgramEnabled function #

func unixStrmDgramEnabled() bool

Generated with Arrow