aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikio Hara <mikioh.mikioh@gmail.com>2017-05-19 19:03:35 +0900
committerMikio Hara <mikioh.mikioh@gmail.com>2017-05-20 00:45:56 +0000
commit2d20ded584cc840bf35054b2a5f840fdefb12767 (patch)
tree05ee9c0ebd7080a4b1fc7a964c278a18d52e1b04 /src
parentfd25fe60fac4014dfe09c364c8c73ff2c95251e5 (diff)
downloadgo-2d20ded584cc840bf35054b2a5f840fdefb12767.tar.xz
net: add test for RawConn.Control on Windows
This is a followup to https://go-review.googlesource.com/37039. Updates #19435. Change-Id: Ia795bd5158d26effa56e897698208ccf73f9e0d2 Reviewed-on: https://go-review.googlesource.com/43693 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/net/rawconn.go7
-rw-r--r--src/net/rawconn_unix_test.go (renamed from src/net/rawconn_test.go)0
-rw-r--r--src/net/rawconn_windows_test.go36
3 files changed, 41 insertions, 2 deletions
diff --git a/src/net/rawconn.go b/src/net/rawconn.go
index 486a5e7d9d..d67be644a3 100644
--- a/src/net/rawconn.go
+++ b/src/net/rawconn.go
@@ -9,8 +9,11 @@ import (
"syscall"
)
-// BUG(mikio): On NaCl, Plan 9 and Windows, the Control, Read and
-// Write methods of syscall.RawConn are not implemented.
+// BUG(mikio): On Windows, the Read and Write methods of
+// syscall.RawConn are not implemented.
+
+// BUG(mikio): On NaCl and Plan 9, the Control, Read and Write methods
+// of syscall.RawConn are not implemented.
type rawConn struct {
fd *netFD
diff --git a/src/net/rawconn_test.go b/src/net/rawconn_unix_test.go
index 294249ba5d..294249ba5d 100644
--- a/src/net/rawconn_test.go
+++ b/src/net/rawconn_unix_test.go
diff --git a/src/net/rawconn_windows_test.go b/src/net/rawconn_windows_test.go
new file mode 100644
index 0000000000..5fb6de7539
--- /dev/null
+++ b/src/net/rawconn_windows_test.go
@@ -0,0 +1,36 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package net
+
+import (
+ "syscall"
+ "testing"
+)
+
+func TestRawConn(t *testing.T) {
+ c, err := newLocalPacketListener("udp")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer c.Close()
+ cc, err := c.(*UDPConn).SyscallConn()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ var operr error
+ fn := func(s uintptr) {
+ operr = syscall.SetsockoptInt(syscall.Handle(s), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
+ }
+ err = cc.Control(fn)
+ if err != nil || operr != nil {
+ t.Fatal(err, operr)
+ }
+ c.Close()
+ err = cc.Control(fn)
+ if err == nil {
+ t.Fatal("should fail")
+ }
+}