github.com/rsc/go@v0.0.0-20150416155037-e040fd465409/src/net/internal/socktest/main_test.go (about) 1 // Copyright 2015 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. 4 5 // +build !plan9 6 7 package socktest_test 8 9 import ( 10 "net/internal/socktest" 11 "os" 12 "syscall" 13 "testing" 14 ) 15 16 var sw socktest.Switch 17 18 func TestMain(m *testing.M) { 19 installTestHooks() 20 21 st := m.Run() 22 23 for s := range sw.Sockets() { 24 closeFunc(s) 25 } 26 uninstallTestHooks() 27 os.Exit(st) 28 } 29 30 func TestSocket(t *testing.T) { 31 for _, f := range []socktest.Filter{ 32 func(st *socktest.Status) (socktest.AfterFilter, error) { return nil, nil }, 33 nil, 34 } { 35 sw.Set(socktest.FilterSocket, f) 36 for _, family := range []int{syscall.AF_INET, syscall.AF_INET6} { 37 socketFunc(family, syscall.SOCK_STREAM, syscall.IPPROTO_TCP) 38 } 39 } 40 }