1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 "golang.org/x/tools/internal/stack/stacktest"
17 func TestIdleTimeout(t *testing.T) {
19 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
22 ln, err := net.Listen("tcp", "localhost:0")
28 connect := func() net.Conn {
29 conn, err := net.DialTimeout("tcp", ln.Addr().String(), 5*time.Second)
36 server := HandlerServer(MethodNotFound)
37 // connTimer := &fakeTimer{c: make(chan time.Time, 1)}
45 runErr = Serve(ctx, ln, server, 100*time.Millisecond)
48 // Exercise some connection/disconnection patterns, and then assert that when
49 // our timer fires, the server exits.
59 if runErr != ErrIdleTimeout {
60 t.Errorf("run() returned error %v, want %v", runErr, ErrIdleTimeout)