2e0118d1a6
## Description This PR continues the refactoring of `netx` under the following principles: 1. do not break the rest of the tree and do not engage in extensive tree-wide refactoring yet 2. move under `netxlite` clearly related subpackages (e.g., `iox`, `netxmocks`) 3. move into `internal/netxlite/internal` stuff that is clearly private of `netxlite` 4. hide implementation details in `netxlite` pending new factories 5. refactor `tls` code in `netxlite` to clearly separate `crypto/tls` code from `utls` code After each commit, I run `go test -short -race ./...` locally. Each individual commit explains what it does. I will squash, but this operation will preserve the original commit titles, so this will give further insight on each step. ## Commits * refactor: rename netxmocks -> netxlite/mocks Part of https://github.com/ooni/probe/issues/1591 * refactor: rename quicx -> netxlite/quicx See https://github.com/ooni/probe/issues/1591 * refactor: rename iox -> netxlite/iox Regenerate sources and make sure the tests pass. See https://github.com/ooni/probe/issues/1591. * refactor(iox): move MockableReader to netxlite/mocks See https://github.com/ooni/probe/issues/1591 * refactor(netxlite): generator is an implementation detail See https://github.com/ooni/probe/issues/1591 * refactor(netxlite): separate tls and utls code See https://github.com/ooni/probe/issues/1591 * refactor(netxlite): hide most types but keep old names as legacy With this change we avoid breaking the rest of the tree, but we start hiding some implementation details a bit. Factories will follow. See https://github.com/ooni/probe/issues/1591
104 lines
4.1 KiB
Go
104 lines
4.1 KiB
Go
// Code generated by go generate; DO NOT EDIT.
|
|
// Generated: 2021-09-05 13:54:14.695896 +0200 CEST m=+0.183167084
|
|
|
|
package errorsx
|
|
|
|
import (
|
|
"io"
|
|
"syscall"
|
|
"testing"
|
|
)
|
|
|
|
func TestToSyscallErr(t *testing.T) {
|
|
if v := toSyscallErr(io.EOF); v != "" {
|
|
t.Fatalf("expected empty string, got '%s'", v)
|
|
}
|
|
if v := toSyscallErr(ECANCELED); v != FailureOperationCanceled {
|
|
t.Fatalf("expected '%s', got '%s'", FailureOperationCanceled, v)
|
|
}
|
|
if v := toSyscallErr(ECONNREFUSED); v != FailureConnectionRefused {
|
|
t.Fatalf("expected '%s', got '%s'", FailureConnectionRefused, v)
|
|
}
|
|
if v := toSyscallErr(ECONNRESET); v != FailureConnectionReset {
|
|
t.Fatalf("expected '%s', got '%s'", FailureConnectionReset, v)
|
|
}
|
|
if v := toSyscallErr(EHOSTUNREACH); v != FailureHostUnreachable {
|
|
t.Fatalf("expected '%s', got '%s'", FailureHostUnreachable, v)
|
|
}
|
|
if v := toSyscallErr(ETIMEDOUT); v != FailureTimedOut {
|
|
t.Fatalf("expected '%s', got '%s'", FailureTimedOut, v)
|
|
}
|
|
if v := toSyscallErr(EAFNOSUPPORT); v != FailureAddressFamilyNotSupported {
|
|
t.Fatalf("expected '%s', got '%s'", FailureAddressFamilyNotSupported, v)
|
|
}
|
|
if v := toSyscallErr(EADDRINUSE); v != FailureAddressInUse {
|
|
t.Fatalf("expected '%s', got '%s'", FailureAddressInUse, v)
|
|
}
|
|
if v := toSyscallErr(EADDRNOTAVAIL); v != FailureAddressNotAvailable {
|
|
t.Fatalf("expected '%s', got '%s'", FailureAddressNotAvailable, v)
|
|
}
|
|
if v := toSyscallErr(EISCONN); v != FailureAlreadyConnected {
|
|
t.Fatalf("expected '%s', got '%s'", FailureAlreadyConnected, v)
|
|
}
|
|
if v := toSyscallErr(EFAULT); v != FailureBadAddress {
|
|
t.Fatalf("expected '%s', got '%s'", FailureBadAddress, v)
|
|
}
|
|
if v := toSyscallErr(EBADF); v != FailureBadFileDescriptor {
|
|
t.Fatalf("expected '%s', got '%s'", FailureBadFileDescriptor, v)
|
|
}
|
|
if v := toSyscallErr(ECONNABORTED); v != FailureConnectionAborted {
|
|
t.Fatalf("expected '%s', got '%s'", FailureConnectionAborted, v)
|
|
}
|
|
if v := toSyscallErr(EALREADY); v != FailureConnectionAlreadyInProgress {
|
|
t.Fatalf("expected '%s', got '%s'", FailureConnectionAlreadyInProgress, v)
|
|
}
|
|
if v := toSyscallErr(EDESTADDRREQ); v != FailureDestinationAddressRequired {
|
|
t.Fatalf("expected '%s', got '%s'", FailureDestinationAddressRequired, v)
|
|
}
|
|
if v := toSyscallErr(EINTR); v != FailureInterrupted {
|
|
t.Fatalf("expected '%s', got '%s'", FailureInterrupted, v)
|
|
}
|
|
if v := toSyscallErr(EINVAL); v != FailureInvalidArgument {
|
|
t.Fatalf("expected '%s', got '%s'", FailureInvalidArgument, v)
|
|
}
|
|
if v := toSyscallErr(EMSGSIZE); v != FailureMessageSize {
|
|
t.Fatalf("expected '%s', got '%s'", FailureMessageSize, v)
|
|
}
|
|
if v := toSyscallErr(ENETDOWN); v != FailureNetworkDown {
|
|
t.Fatalf("expected '%s', got '%s'", FailureNetworkDown, v)
|
|
}
|
|
if v := toSyscallErr(ENETRESET); v != FailureNetworkReset {
|
|
t.Fatalf("expected '%s', got '%s'", FailureNetworkReset, v)
|
|
}
|
|
if v := toSyscallErr(ENETUNREACH); v != FailureNetworkUnreachable {
|
|
t.Fatalf("expected '%s', got '%s'", FailureNetworkUnreachable, v)
|
|
}
|
|
if v := toSyscallErr(ENOBUFS); v != FailureNoBufferSpace {
|
|
t.Fatalf("expected '%s', got '%s'", FailureNoBufferSpace, v)
|
|
}
|
|
if v := toSyscallErr(ENOPROTOOPT); v != FailureNoProtocolOption {
|
|
t.Fatalf("expected '%s', got '%s'", FailureNoProtocolOption, v)
|
|
}
|
|
if v := toSyscallErr(ENOTSOCK); v != FailureNotASocket {
|
|
t.Fatalf("expected '%s', got '%s'", FailureNotASocket, v)
|
|
}
|
|
if v := toSyscallErr(ENOTCONN); v != FailureNotConnected {
|
|
t.Fatalf("expected '%s', got '%s'", FailureNotConnected, v)
|
|
}
|
|
if v := toSyscallErr(EWOULDBLOCK); v != FailureOperationWouldBlock {
|
|
t.Fatalf("expected '%s', got '%s'", FailureOperationWouldBlock, v)
|
|
}
|
|
if v := toSyscallErr(EACCES); v != FailurePermissionDenied {
|
|
t.Fatalf("expected '%s', got '%s'", FailurePermissionDenied, v)
|
|
}
|
|
if v := toSyscallErr(EPROTONOSUPPORT); v != FailureProtocolNotSupported {
|
|
t.Fatalf("expected '%s', got '%s'", FailureProtocolNotSupported, v)
|
|
}
|
|
if v := toSyscallErr(EPROTOTYPE); v != FailureWrongProtocolType {
|
|
t.Fatalf("expected '%s', got '%s'", FailureWrongProtocolType, v)
|
|
}
|
|
if v := toSyscallErr(syscall.Errno(0)); v != "" {
|
|
t.Fatalf("expected empty string, got '%s'", v)
|
|
}
|
|
}
|