Commit 15648d2e authored by Mikio Hara's avatar Mikio Hara

net: replace server tests

This change replaces server tests with new ones that require features
introduced after go1 release, such as runtime-integrated network poller,
Dialer, etc.

Change-Id: Icf1f94f08f33caacd499cfccbe74cda8d05eed30
Reviewed-on: https://go-review.googlesource.com/9195Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 72e867ed
This diff is collapsed.
...@@ -307,15 +307,14 @@ func TestTimeoutUDP(t *testing.T) { ...@@ -307,15 +307,14 @@ func TestTimeoutUDP(t *testing.T) {
t.Skipf("skipping test on %q", runtime.GOOS) t.Skipf("skipping test on %q", runtime.GOOS)
} }
// set up a listener that won't talk back c, err := newLocalPacketListener("udp") // a listener that won't talk back
listening := make(chan string) if err != nil {
done := make(chan int) t.Fatal(err)
go runDatagramPacketConnServer(t, "udp", "127.0.0.1:0", listening, done) }
addr := <-listening
testTimeout(t, "udp", c.LocalAddr().String(), false)
testTimeout(t, "udp", addr, false) testTimeout(t, "udp", c.LocalAddr().String(), true)
testTimeout(t, "udp", addr, true) c.Close()
<-done
} }
func TestTimeoutTCP(t *testing.T) { func TestTimeoutTCP(t *testing.T) {
...@@ -324,14 +323,25 @@ func TestTimeoutTCP(t *testing.T) { ...@@ -324,14 +323,25 @@ func TestTimeoutTCP(t *testing.T) {
t.Skipf("skipping test on %q", runtime.GOOS) t.Skipf("skipping test on %q", runtime.GOOS)
} }
// set up a listener that won't talk back handler := func(ls *localServer, ln Listener) { // a listener that won't talk back
listening := make(chan string) for {
done := make(chan int) c, err := ln.Accept()
go runStreamConnServer(t, "tcp", "127.0.0.1:0", listening, done) if err != nil {
addr := <-listening break
}
defer c.Close()
}
}
ls, err := newLocalServer("tcp")
if err != nil {
t.Fatal(err)
}
defer ls.teardown()
if err := ls.buildup(handler); err != nil {
t.Fatal(err)
}
testTimeout(t, "tcp", addr, false) testTimeout(t, "tcp", ls.Listener.Addr().String(), false)
<-done
} }
func TestDeadlineReset(t *testing.T) { func TestDeadlineReset(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment