diff options
author | Ian Lance Taylor <iant@google.com> | 2016-02-03 21:58:02 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-02-03 21:58:02 +0000 |
commit | f98dd1a338867a408f7c72d73fbad7fe7fc93e3a (patch) | |
tree | 2f8da9862a9c1fe0df138917f997b03439c02773 /libgo/go/net/unix_test.go | |
parent | b081ed4efc144da0c45a6484aebfd10e0eb9fda3 (diff) | |
download | gcc-f98dd1a338867a408f7c72d73fbad7fe7fc93e3a.zip gcc-f98dd1a338867a408f7c72d73fbad7fe7fc93e3a.tar.gz gcc-f98dd1a338867a408f7c72d73fbad7fe7fc93e3a.tar.bz2 |
libgo: Update to go1.6rc1.
Reviewed-on: https://go-review.googlesource.com/19200
From-SVN: r233110
Diffstat (limited to 'libgo/go/net/unix_test.go')
-rw-r--r-- | libgo/go/net/unix_test.go | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/libgo/go/net/unix_test.go b/libgo/go/net/unix_test.go index 358ff31..f0c5830 100644 --- a/libgo/go/net/unix_test.go +++ b/libgo/go/net/unix_test.go @@ -405,6 +405,42 @@ func TestUnixgramConnLocalAndRemoteNames(t *testing.T) { } } +func TestUnixUnlink(t *testing.T) { + if !testableNetwork("unix") { + t.Skip("unix test") + } + name := testUnixAddr() + l, err := Listen("unix", name) + if err != nil { + t.Fatal(err) + } + if _, err := os.Stat(name); err != nil { + t.Fatalf("cannot stat unix socket after ListenUnix: %v", err) + } + f, _ := l.(*UnixListener).File() + l1, err := FileListener(f) + if err != nil { + t.Fatal(err) + } + if _, err := os.Stat(name); err != nil { + t.Fatalf("cannot stat unix socket after FileListener: %v", err) + } + if err := l1.Close(); err != nil { + t.Fatalf("closing file listener: %v", err) + } + if _, err := os.Stat(name); err != nil { + t.Fatalf("cannot stat unix socket after closing FileListener: %v", err) + } + f.Close() + if _, err := os.Stat(name); err != nil { + t.Fatalf("cannot stat unix socket after closing FileListener and fd: %v", err) + } + l.Close() + if _, err := os.Stat(name); err == nil { + t.Fatal("closing unix listener did not remove unix socket") + } +} + // forceGoDNS forces the resolver configuration to use the pure Go resolver // and returns a fixup function to restore the old settings. func forceGoDNS() func() { @@ -421,11 +457,17 @@ func forceGoDNS() func() { } // forceCgoDNS forces the resolver configuration to use the cgo resolver -// and returns true to indicate that it did so. -// (On non-Unix systems forceCgoDNS returns false.) -func forceCgoDNS() bool { +// and returns a fixup function to restore the old settings. +// (On non-Unix systems forceCgoDNS returns nil.) +func forceCgoDNS() func() { c := systemConf() + oldGo := c.netGo + oldCgo := c.netCgo + fixup := func() { + c.netGo = oldGo + c.netCgo = oldCgo + } c.netGo = false c.netCgo = true - return true + return fixup } |