Skip to content

Commit

Permalink
vsock: check for ECONNRESET and ENODEV in failed Dial test
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Layher <mdlayher@gmail.com>
  • Loading branch information
mdlayher committed Apr 29, 2023
1 parent 8569e30 commit 76b624c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.18, 1.19]
go-version: ["1.18", "1.19", "1.20"]
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.18, 1.19]
go-version: ["1.18", "1.19", "1.20"]
runs-on: ubuntu-latest

steps:
Expand Down
22 changes: 18 additions & 4 deletions integration_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package vsock_test

import (
"bytes"
"errors"
"fmt"
"io"
"math"
Expand Down Expand Up @@ -212,16 +213,29 @@ func TestIntegrationConnDialNoListener(t *testing.T) {
for _, port := range []uint32{max - 2, max - 1, max} {
_, err := vsock.Dial(vsock.Local, port, nil)
if err == nil {
// It seems local binds don't work in GitHub actions right now.
// Skip for now.
skipOldKernel(t)
t.Fatal("dial succeeded, but should not have")
}

got, ok := err.(*net.OpError)
if !ok {
t.Fatalf("expected *net.OpError, but got %T", err)
}

// Expect one of ECONNRESET or ENODEV depending on the kernel.
switch {
case errors.Is(got.Err, unix.ECONNRESET), errors.Is(got.Err, unix.ENODEV):
// OK.
default:
t.Fatalf("unexpected syscall error: %v", got.Err)
}

// Zero out the error comparison.
got.Err = nil

want := &net.OpError{
Op: "dial",
Net: "vsock",
Addr: &vsock.Addr{ContextID: vsock.Local, Port: port},
Err: os.NewSyscallError("connect", unix.ECONNRESET),
}

if diff := cmp.Diff(want, err); diff != "" {
Expand Down

0 comments on commit 76b624c

Please sign in to comment.