• Brad Fitzpatrick's avatar
    ipv4: deflake TestConnUnicastSocketOptions on Windows · 944c58e9
    Brad Fitzpatrick authored
    TestConnUnicastSocketOptions doesn't work on nacl, plan9, or windows,
    but the t.Skip at the top was missing the GOOS == "windows" check. (It
    was present in the ipv6 version of the test)
    
    The test than proceeded to try to run and set up a connection pair
    for testing. Here's what was happening.
    
    Goroutines are M (main, the client) and S (server, doing the Accept):
    
       M: net.Listen("tcp4", "127.0.0.1:0"), succeeds.
       M: defer ln.Close() enqueued.
       M: go acceptor() (start "S" (server) goroutine)
       M: net.Dial("tcp4", ln.Addr().String()), succeeds.
          Notably, it's connected to the kernel's TCP stack at this point.
          The userspace Accept hasn't run. Go's listen backlog is
          syscall.SOMAXCONN on Windows (which is fine).
       M: testUnicastSocketOptions:
          - finds that it's GOOS == "windows",
          - calls t.Skipf, which calls runtime.Goexit, runs deferred goroutines
       M: ln.Close() (previously deferred runs)
       M: test completes
    
    Then:
    
       S: server goroutine finally schedules
       S: c, err := ln.Accept(), gets an error (because it's closed)
          if err != nil {
               t.Error(err)   // setting an error after test is done; bogus
    
    So, fix it both ways: skip the test earlier on "windows", and simplify
    the server goroutine and move the failing into the main goroutine.
    Also skip other tests earlier on Windows that will also t.Skip. They
    don't have goroutines, but might as well skip earlier.
    
    Fixes golang/go#17655
    
    Change-Id: I5d910d70943be37b2b4b56542ee98e42fc3acd71
    Reviewed-on: https://go-review.googlesource.com/34021
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    Reviewed-by: 's avatarBryan Mills <bcmills@google.com>
    944c58e9
Name
Last commit
Last update
bpf Loading commit data...
context Loading commit data...
dict Loading commit data...
html Loading commit data...
http2 Loading commit data...
icmp Loading commit data...
idna Loading commit data...
internal Loading commit data...
ipv4 Loading commit data...
ipv6 Loading commit data...
lex/httplex Loading commit data...
lif Loading commit data...
nettest Loading commit data...
netutil Loading commit data...
proxy Loading commit data...
publicsuffix Loading commit data...
route Loading commit data...
trace Loading commit data...
webdav Loading commit data...
websocket Loading commit data...
xsrftoken Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README Loading commit data...
codereview.cfg Loading commit data...