* feat(errorsx): cover more syscall errors and add tests Part of https://github.com/ooni/probe/issues/1505 * fix tests
		
			
				
	
	
		
			104 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			104 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// Code generated by go generate; DO NOT EDIT.
 | 
						|
// Generated: 2021-07-02 17:54:06.226224 +0200 CEST m=+0.164008293
 | 
						|
 | 
						|
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)
 | 
						|
	}
 | 
						|
}
 |