]> Cypherpunks repositories - gostls13.git/commitdiff
net: simplify sync.Once calls in tests
authorMikio Hara <mikioh.mikioh@gmail.com>
Thu, 14 May 2015 00:25:24 +0000 (09:25 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Thu, 14 May 2015 01:47:35 +0000 (01:47 +0000)
Change-Id: I0c2e1a4a8261887a696e585dda46e72d691191e0
Reviewed-on: https://go-review.googlesource.com/10070
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/dnsclient_unix_test.go
src/net/dnsname_test.go
src/net/interface_test.go
src/net/ip_test.go
src/net/main_test.go
src/net/tcp_test.go

index 1b88e7762b5055472890fadff9b090b88fe11982..4ea24b6014af2547a4d557d890dd35b3fbb1e185 100644 (file)
@@ -227,7 +227,7 @@ func TestReloadResolvConfChange(t *testing.T) {
 }
 
 func BenchmarkGoLookupIP(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        for i := 0; i < b.N; i++ {
                goLookupIP("www.example.com")
@@ -235,7 +235,7 @@ func BenchmarkGoLookupIP(b *testing.B) {
 }
 
 func BenchmarkGoLookupIPNoSuchHost(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        for i := 0; i < b.N; i++ {
                goLookupIP("some.nonexistent")
@@ -243,7 +243,7 @@ func BenchmarkGoLookupIPNoSuchHost(b *testing.B) {
 }
 
 func BenchmarkGoLookupIPWithBrokenNameServer(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        onceLoadConfig.Do(loadDefaultConfig)
 
index cc660c9d42174d2eaeab13775ccbf42a97e16fea..be07dc6a16f1870e2e9c277a301ee1867c94171e 100644 (file)
@@ -68,7 +68,7 @@ func TestDNSName(t *testing.T) {
 }
 
 func BenchmarkDNSName(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        benchmarks := append(dnsNameTests, []dnsNameTest{
                {strings.Repeat("a", 63), true},
index 0e5c2e3ddf88defc1603ea1f3b114406ccd9ea3a..567d18de448cb8a959b80c989fd2dc7db52ffecd 100644 (file)
@@ -229,7 +229,7 @@ func testMulticastAddrs(t *testing.T, ifmat []Addr) (nmaf4, nmaf6 int) {
 }
 
 func BenchmarkInterfaces(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        for i := 0; i < b.N; i++ {
                if _, err := Interfaces(); err != nil {
@@ -239,7 +239,7 @@ func BenchmarkInterfaces(b *testing.B) {
 }
 
 func BenchmarkInterfaceByIndex(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        ifi := loopbackInterface()
        if ifi == nil {
@@ -253,7 +253,7 @@ func BenchmarkInterfaceByIndex(b *testing.B) {
 }
 
 func BenchmarkInterfaceByName(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        ifi := loopbackInterface()
        if ifi == nil {
@@ -267,7 +267,7 @@ func BenchmarkInterfaceByName(b *testing.B) {
 }
 
 func BenchmarkInterfaceAddrs(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        for i := 0; i < b.N; i++ {
                if _, err := InterfaceAddrs(); err != nil {
@@ -277,7 +277,7 @@ func BenchmarkInterfaceAddrs(b *testing.B) {
 }
 
 func BenchmarkInterfacesAndAddrs(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        ifi := loopbackInterface()
        if ifi == nil {
@@ -291,7 +291,7 @@ func BenchmarkInterfacesAndAddrs(b *testing.B) {
 }
 
 func BenchmarkInterfacesAndMulticastAddrs(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        ifi := loopbackInterface()
        if ifi == nil {
index 24f67cac9750aef6f085815d4458fa57534d7fd9..b1939cd08f00b45da7a62345e5ceee9fecbb61dd 100644 (file)
@@ -53,7 +53,7 @@ func TestParseIP(t *testing.T) {
 }
 
 func BenchmarkParseIP(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        for i := 0; i < b.N; i++ {
                for _, tt := range parseIPTests {
@@ -110,7 +110,7 @@ func TestIPString(t *testing.T) {
 }
 
 func BenchmarkIPString(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        for i := 0; i < b.N; i++ {
                for _, tt := range ipStringTests {
@@ -162,7 +162,7 @@ func TestIPMaskString(t *testing.T) {
 }
 
 func BenchmarkIPMaskString(b *testing.B) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        for i := 0; i < b.N; i++ {
                for _, tt := range ipMaskStringTests {
index 4288e2add25133513672d292d8e164e202ef7911..5e2f3da0e6a4c0cdc5c3befda6997fd7407a7fb0 100644 (file)
@@ -43,7 +43,7 @@ func TestMain(m *testing.M) {
 
        st := m.Run()
 
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
        if !testing.Short() {
                printLeakedGoroutines()
                printLeakedSockets()
index 6229df286947539c7e8413cb92e143bec7970488..64117449bdcf53c057db9a07235377fd9583a991 100644 (file)
@@ -58,7 +58,7 @@ func BenchmarkTCP6PersistentTimeout(b *testing.B) {
 }
 
 func benchmarkTCP(b *testing.B, persistent, timeout bool, laddr string) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        const msgLen = 512
        conns := b.N
@@ -168,7 +168,7 @@ func BenchmarkTCP6ConcurrentReadWrite(b *testing.B) {
 }
 
 func benchmarkTCPConcurrentReadWrite(b *testing.B, laddr string) {
-       testHookUninstaller.Do(func() { uninstallTestHooks() })
+       testHookUninstaller.Do(uninstallTestHooks)
 
        // The benchmark creates GOMAXPROCS client/server pairs.
        // Each pair creates 4 goroutines: client reader/writer and server reader/writer.