mirror of
https://github.com/golang/go
synced 2024-11-13 19:00:25 -07:00
src: use internal tests if possible
If a test can be placed in the same package ("internal"), it is placed there. This facilitates testing of package-private details. Because of dependency cycles some packages cannot be tested by internal tests. R=golang-dev, rsc, mikioh.mikioh CC=golang-dev, r https://golang.org/cl/7323044
This commit is contained in:
parent
d251fc39f2
commit
d137a2cb56
@ -2,10 +2,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package heap_test
|
package heap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "container/heap"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package md5_test
|
package md5
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
@ -54,7 +53,7 @@ var golden = []md5Test{
|
|||||||
func TestGolden(t *testing.T) {
|
func TestGolden(t *testing.T) {
|
||||||
for i := 0; i < len(golden); i++ {
|
for i := 0; i < len(golden); i++ {
|
||||||
g := golden[i]
|
g := golden[i]
|
||||||
c := md5.New()
|
c := New()
|
||||||
buf := make([]byte, len(g.in)+4)
|
buf := make([]byte, len(g.in)+4)
|
||||||
for j := 0; j < 3+4; j++ {
|
for j := 0; j < 3+4; j++ {
|
||||||
if j < 2 {
|
if j < 2 {
|
||||||
@ -79,14 +78,14 @@ func TestGolden(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExampleNew() {
|
func ExampleNew() {
|
||||||
h := md5.New()
|
h := New()
|
||||||
io.WriteString(h, "The fog is getting thicker!")
|
io.WriteString(h, "The fog is getting thicker!")
|
||||||
io.WriteString(h, "And Leon's getting laaarger!")
|
io.WriteString(h, "And Leon's getting laaarger!")
|
||||||
fmt.Printf("%x", h.Sum(nil))
|
fmt.Printf("%x", h.Sum(nil))
|
||||||
// Output: e2c569be17396eca2a2e3c11578123ed
|
// Output: e2c569be17396eca2a2e3c11578123ed
|
||||||
}
|
}
|
||||||
|
|
||||||
var bench = md5.New()
|
var bench = New()
|
||||||
var buf = make([]byte, 8192+1)
|
var buf = make([]byte, 8192+1)
|
||||||
var sum = make([]byte, bench.Size())
|
var sum = make([]byte, bench.Size())
|
||||||
|
|
||||||
|
@ -4,10 +4,9 @@
|
|||||||
|
|
||||||
// SHA1 hash algorithm. See RFC 3174.
|
// SHA1 hash algorithm. See RFC 3174.
|
||||||
|
|
||||||
package sha1_test
|
package sha1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha1"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
@ -55,7 +54,7 @@ var golden = []sha1Test{
|
|||||||
func TestGolden(t *testing.T) {
|
func TestGolden(t *testing.T) {
|
||||||
for i := 0; i < len(golden); i++ {
|
for i := 0; i < len(golden); i++ {
|
||||||
g := golden[i]
|
g := golden[i]
|
||||||
c := sha1.New()
|
c := New()
|
||||||
for j := 0; j < 3; j++ {
|
for j := 0; j < 3; j++ {
|
||||||
if j < 2 {
|
if j < 2 {
|
||||||
io.WriteString(c, g.in)
|
io.WriteString(c, g.in)
|
||||||
@ -74,13 +73,13 @@ func TestGolden(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExampleNew() {
|
func ExampleNew() {
|
||||||
h := sha1.New()
|
h := New()
|
||||||
io.WriteString(h, "His money is twice tainted: 'taint yours and 'taint mine.")
|
io.WriteString(h, "His money is twice tainted: 'taint yours and 'taint mine.")
|
||||||
fmt.Printf("% x", h.Sum(nil))
|
fmt.Printf("% x", h.Sum(nil))
|
||||||
// Output: 59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd
|
// Output: 59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd
|
||||||
}
|
}
|
||||||
|
|
||||||
var bench = sha1.New()
|
var bench = New()
|
||||||
var buf = make([]byte, 8192)
|
var buf = make([]byte, 8192)
|
||||||
|
|
||||||
func benchmarkSize(b *testing.B, size int) {
|
func benchmarkSize(b *testing.B, size int) {
|
||||||
|
@ -5,10 +5,9 @@
|
|||||||
// This file exercises the import parser but also checks that
|
// This file exercises the import parser but also checks that
|
||||||
// some low-level packages do not have new dependencies added.
|
// some low-level packages do not have new dependencies added.
|
||||||
|
|
||||||
package build_test
|
package build
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go/build"
|
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -382,7 +381,7 @@ func TestDependencies(t *testing.T) {
|
|||||||
}
|
}
|
||||||
sort.Strings(all)
|
sort.Strings(all)
|
||||||
|
|
||||||
ctxt := build.Default
|
ctxt := Default
|
||||||
test := func(mustImport bool) {
|
test := func(mustImport bool) {
|
||||||
for _, pkg := range all {
|
for _, pkg := range all {
|
||||||
if isMacro(pkg) {
|
if isMacro(pkg) {
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package ioutil_test
|
package ioutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package ioutil_test
|
package ioutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package net_test
|
// This file implements API tests across platforms and will never have a build
|
||||||
|
// tag.
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
@ -35,13 +37,13 @@ func TestConnAndListener(t *testing.T) {
|
|||||||
os.Remove(tt.addr)
|
os.Remove(tt.addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
ln, err := net.Listen(tt.net, tt.addr)
|
ln, err := Listen(tt.net, tt.addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("net.Listen failed: %v", err)
|
t.Errorf("net.Listen failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ln.Addr()
|
ln.Addr()
|
||||||
defer func(ln net.Listener, net, addr string) {
|
defer func(ln Listener, net, addr string) {
|
||||||
ln.Close()
|
ln.Close()
|
||||||
switch net {
|
switch net {
|
||||||
case "unix", "unixpacket":
|
case "unix", "unixpacket":
|
||||||
@ -52,7 +54,7 @@ func TestConnAndListener(t *testing.T) {
|
|||||||
done := make(chan int)
|
done := make(chan int)
|
||||||
go transponder(t, ln, done)
|
go transponder(t, ln, done)
|
||||||
|
|
||||||
c, err := net.Dial(tt.net, ln.Addr().String())
|
c, err := Dial(tt.net, ln.Addr().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("net.Dial failed: %v", err)
|
t.Errorf("net.Dial failed: %v", err)
|
||||||
return
|
return
|
||||||
@ -77,7 +79,7 @@ func TestConnAndListener(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func transponder(t *testing.T, ln net.Listener, done chan<- int) {
|
func transponder(t *testing.T, ln Listener, done chan<- int) {
|
||||||
defer func() { done <- 1 }()
|
defer func() { done <- 1 }()
|
||||||
|
|
||||||
c, err := ln.Accept()
|
c, err := ln.Accept()
|
||||||
|
@ -2,11 +2,10 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package http_test
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
@ -32,9 +31,9 @@ func TestFileTransport(t *testing.T) {
|
|||||||
defer os.Remove(dname)
|
defer os.Remove(dname)
|
||||||
defer os.Remove(fname)
|
defer os.Remove(fname)
|
||||||
|
|
||||||
tr := &http.Transport{}
|
tr := &Transport{}
|
||||||
tr.RegisterProtocol("file", http.NewFileTransport(http.Dir(dname)))
|
tr.RegisterProtocol("file", NewFileTransport(Dir(dname)))
|
||||||
c := &http.Client{Transport: tr}
|
c := &Client{Transport: tr}
|
||||||
|
|
||||||
fooURLs := []string{"file:///foo.txt", "file://../foo.txt"}
|
fooURLs := []string{"file:///foo.txt", "file://../foo.txt"}
|
||||||
for _, urlstr := range fooURLs {
|
for _, urlstr := range fooURLs {
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package net_test
|
// This file implements API tests across platforms and will never have a build
|
||||||
|
// tag.
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -24,7 +26,7 @@ var packetConnTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPacketConn(t *testing.T) {
|
func TestPacketConn(t *testing.T) {
|
||||||
closer := func(c net.PacketConn, net, addr1, addr2 string) {
|
closer := func(c PacketConn, net, addr1, addr2 string) {
|
||||||
c.Close()
|
c.Close()
|
||||||
switch net {
|
switch net {
|
||||||
case "unixgram":
|
case "unixgram":
|
||||||
@ -61,7 +63,7 @@ func TestPacketConn(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
c1, err := net.ListenPacket(tt.net, tt.addr1)
|
c1, err := ListenPacket(tt.net, tt.addr1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ListenPacket failed: %v", err)
|
t.Fatalf("net.ListenPacket failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -71,7 +73,7 @@ func TestPacketConn(t *testing.T) {
|
|||||||
c1.SetWriteDeadline(time.Now().Add(100 * time.Millisecond))
|
c1.SetWriteDeadline(time.Now().Add(100 * time.Millisecond))
|
||||||
defer closer(c1, netstr[0], tt.addr1, tt.addr2)
|
defer closer(c1, netstr[0], tt.addr1, tt.addr2)
|
||||||
|
|
||||||
c2, err := net.ListenPacket(tt.net, tt.addr2)
|
c2, err := ListenPacket(tt.net, tt.addr2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ListenPacket failed: %v", err)
|
t.Fatalf("net.ListenPacket failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -119,7 +121,7 @@ func TestConnAndPacketConn(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
c1, err := net.ListenPacket(tt.net, tt.addr1)
|
c1, err := ListenPacket(tt.net, tt.addr1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ListenPacket failed: %v", err)
|
t.Fatalf("net.ListenPacket failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -129,7 +131,7 @@ func TestConnAndPacketConn(t *testing.T) {
|
|||||||
c1.SetWriteDeadline(time.Now().Add(100 * time.Millisecond))
|
c1.SetWriteDeadline(time.Now().Add(100 * time.Millisecond))
|
||||||
defer c1.Close()
|
defer c1.Close()
|
||||||
|
|
||||||
c2, err := net.Dial(tt.net, c1.LocalAddr().String())
|
c2, err := Dial(tt.net, c1.LocalAddr().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.Dial failed: %v", err)
|
t.Fatalf("net.Dial failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -147,9 +149,9 @@ func TestConnAndPacketConn(t *testing.T) {
|
|||||||
if _, _, err := c1.ReadFrom(rb1); err != nil {
|
if _, _, err := c1.ReadFrom(rb1); err != nil {
|
||||||
t.Fatalf("net.PacetConn.ReadFrom failed: %v", err)
|
t.Fatalf("net.PacetConn.ReadFrom failed: %v", err)
|
||||||
}
|
}
|
||||||
var dst net.Addr
|
var dst Addr
|
||||||
if netstr[0] == "ip" {
|
if netstr[0] == "ip" {
|
||||||
dst = &net.IPAddr{IP: net.IPv4(127, 0, 0, 1)}
|
dst = &IPAddr{IP: IPv4(127, 0, 0, 1)}
|
||||||
} else {
|
} else {
|
||||||
dst = c2.LocalAddr()
|
dst = c2.LocalAddr()
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package net_test
|
// This file implements API tests across platforms and will never have a build
|
||||||
|
// tag.
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"net"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
@ -23,11 +25,11 @@ var condErrorf = func() func(*testing.T, string, ...interface{}) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
func TestTCPListenerSpecificMethods(t *testing.T) {
|
func TestTCPListenerSpecificMethods(t *testing.T) {
|
||||||
la, err := net.ResolveTCPAddr("tcp4", "127.0.0.1:0")
|
la, err := ResolveTCPAddr("tcp4", "127.0.0.1:0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ResolveTCPAddr failed: %v", err)
|
t.Fatalf("net.ResolveTCPAddr failed: %v", err)
|
||||||
}
|
}
|
||||||
ln, err := net.ListenTCP("tcp4", la)
|
ln, err := ListenTCP("tcp4", la)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ListenTCP failed: %v", err)
|
t.Fatalf("net.ListenTCP failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -36,7 +38,7 @@ func TestTCPListenerSpecificMethods(t *testing.T) {
|
|||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
|
|
||||||
if c, err := ln.Accept(); err != nil {
|
if c, err := ln.Accept(); err != nil {
|
||||||
if !err.(net.Error).Timeout() {
|
if !err.(Error).Timeout() {
|
||||||
t.Errorf("net.TCPListener.Accept failed: %v", err)
|
t.Errorf("net.TCPListener.Accept failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -44,7 +46,7 @@ func TestTCPListenerSpecificMethods(t *testing.T) {
|
|||||||
c.Close()
|
c.Close()
|
||||||
}
|
}
|
||||||
if c, err := ln.AcceptTCP(); err != nil {
|
if c, err := ln.AcceptTCP(); err != nil {
|
||||||
if !err.(net.Error).Timeout() {
|
if !err.(Error).Timeout() {
|
||||||
t.Errorf("net.TCPListener.AcceptTCP failed: %v", err)
|
t.Errorf("net.TCPListener.AcceptTCP failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -61,11 +63,11 @@ func TestTCPListenerSpecificMethods(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTCPConnSpecificMethods(t *testing.T) {
|
func TestTCPConnSpecificMethods(t *testing.T) {
|
||||||
la, err := net.ResolveTCPAddr("tcp4", "127.0.0.1:0")
|
la, err := ResolveTCPAddr("tcp4", "127.0.0.1:0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ResolveTCPAddr failed: %v", err)
|
t.Fatalf("net.ResolveTCPAddr failed: %v", err)
|
||||||
}
|
}
|
||||||
ln, err := net.ListenTCP("tcp4", la)
|
ln, err := ListenTCP("tcp4", la)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ListenTCP failed: %v", err)
|
t.Fatalf("net.ListenTCP failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -75,12 +77,12 @@ func TestTCPConnSpecificMethods(t *testing.T) {
|
|||||||
done := make(chan int)
|
done := make(chan int)
|
||||||
go transponder(t, ln, done)
|
go transponder(t, ln, done)
|
||||||
|
|
||||||
ra, err := net.ResolveTCPAddr("tcp4", ln.Addr().String())
|
ra, err := ResolveTCPAddr("tcp4", ln.Addr().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("net.ResolveTCPAddr failed: %v", err)
|
t.Errorf("net.ResolveTCPAddr failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c, err := net.DialTCP("tcp4", nil, ra)
|
c, err := DialTCP("tcp4", nil, ra)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("net.DialTCP failed: %v", err)
|
t.Errorf("net.DialTCP failed: %v", err)
|
||||||
return
|
return
|
||||||
@ -109,11 +111,11 @@ func TestTCPConnSpecificMethods(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUDPConnSpecificMethods(t *testing.T) {
|
func TestUDPConnSpecificMethods(t *testing.T) {
|
||||||
la, err := net.ResolveUDPAddr("udp4", "127.0.0.1:0")
|
la, err := ResolveUDPAddr("udp4", "127.0.0.1:0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ResolveUDPAddr failed: %v", err)
|
t.Fatalf("net.ResolveUDPAddr failed: %v", err)
|
||||||
}
|
}
|
||||||
c, err := net.ListenUDP("udp4", la)
|
c, err := ListenUDP("udp4", la)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ListenUDP failed: %v", err)
|
t.Fatalf("net.ListenUDP failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -128,7 +130,7 @@ func TestUDPConnSpecificMethods(t *testing.T) {
|
|||||||
|
|
||||||
wb := []byte("UDPCONN TEST")
|
wb := []byte("UDPCONN TEST")
|
||||||
rb := make([]byte, 128)
|
rb := make([]byte, 128)
|
||||||
if _, err := c.WriteToUDP(wb, c.LocalAddr().(*net.UDPAddr)); err != nil {
|
if _, err := c.WriteToUDP(wb, c.LocalAddr().(*UDPAddr)); err != nil {
|
||||||
t.Errorf("net.UDPConn.WriteToUDP failed: %v", err)
|
t.Errorf("net.UDPConn.WriteToUDP failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -136,7 +138,7 @@ func TestUDPConnSpecificMethods(t *testing.T) {
|
|||||||
t.Errorf("net.UDPConn.ReadFromUDP failed: %v", err)
|
t.Errorf("net.UDPConn.ReadFromUDP failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, _, err := c.WriteMsgUDP(wb, nil, c.LocalAddr().(*net.UDPAddr)); err != nil {
|
if _, _, err := c.WriteMsgUDP(wb, nil, c.LocalAddr().(*UDPAddr)); err != nil {
|
||||||
condErrorf(t, "net.UDPConn.WriteMsgUDP failed: %v", err)
|
condErrorf(t, "net.UDPConn.WriteMsgUDP failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -162,11 +164,11 @@ func TestIPConnSpecificMethods(t *testing.T) {
|
|||||||
t.Skipf("skipping test; must be root")
|
t.Skipf("skipping test; must be root")
|
||||||
}
|
}
|
||||||
|
|
||||||
la, err := net.ResolveIPAddr("ip4", "127.0.0.1")
|
la, err := ResolveIPAddr("ip4", "127.0.0.1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ResolveIPAddr failed: %v", err)
|
t.Fatalf("net.ResolveIPAddr failed: %v", err)
|
||||||
}
|
}
|
||||||
c, err := net.ListenIP("ip4:icmp", la)
|
c, err := ListenIP("ip4:icmp", la)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ListenIP failed: %v", err)
|
t.Fatalf("net.ListenIP failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -182,7 +184,7 @@ func TestIPConnSpecificMethods(t *testing.T) {
|
|||||||
id := os.Getpid() & 0xffff
|
id := os.Getpid() & 0xffff
|
||||||
wb := newICMPEchoRequest(id, 1, 128, []byte("IPCONN TEST "))
|
wb := newICMPEchoRequest(id, 1, 128, []byte("IPCONN TEST "))
|
||||||
rb := make([]byte, 20+128)
|
rb := make([]byte, 20+128)
|
||||||
if _, err := c.WriteToIP(wb, c.LocalAddr().(*net.IPAddr)); err != nil {
|
if _, err := c.WriteToIP(wb, c.LocalAddr().(*IPAddr)); err != nil {
|
||||||
t.Errorf("net.IPConn.WriteToIP failed: %v", err)
|
t.Errorf("net.IPConn.WriteToIP failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -190,7 +192,7 @@ func TestIPConnSpecificMethods(t *testing.T) {
|
|||||||
t.Errorf("net.IPConn.ReadFromIP failed: %v", err)
|
t.Errorf("net.IPConn.ReadFromIP failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, _, err := c.WriteMsgIP(wb, nil, c.LocalAddr().(*net.IPAddr)); err != nil {
|
if _, _, err := c.WriteMsgIP(wb, nil, c.LocalAddr().(*IPAddr)); err != nil {
|
||||||
condErrorf(t, "net.UDPConn.WriteMsgIP failed: %v", err)
|
condErrorf(t, "net.UDPConn.WriteMsgIP failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -215,11 +217,11 @@ func TestUnixListenerSpecificMethods(t *testing.T) {
|
|||||||
|
|
||||||
p := "/tmp/gotest.net"
|
p := "/tmp/gotest.net"
|
||||||
os.Remove(p)
|
os.Remove(p)
|
||||||
la, err := net.ResolveUnixAddr("unix", p)
|
la, err := ResolveUnixAddr("unix", p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ResolveUnixAddr failed: %v", err)
|
t.Fatalf("net.ResolveUnixAddr failed: %v", err)
|
||||||
}
|
}
|
||||||
ln, err := net.ListenUnix("unix", la)
|
ln, err := ListenUnix("unix", la)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ListenUnix failed: %v", err)
|
t.Fatalf("net.ListenUnix failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -229,7 +231,7 @@ func TestUnixListenerSpecificMethods(t *testing.T) {
|
|||||||
defer os.Remove(p)
|
defer os.Remove(p)
|
||||||
|
|
||||||
if c, err := ln.Accept(); err != nil {
|
if c, err := ln.Accept(); err != nil {
|
||||||
if !err.(net.Error).Timeout() {
|
if !err.(Error).Timeout() {
|
||||||
t.Errorf("net.TCPListener.AcceptTCP failed: %v", err)
|
t.Errorf("net.TCPListener.AcceptTCP failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -237,7 +239,7 @@ func TestUnixListenerSpecificMethods(t *testing.T) {
|
|||||||
c.Close()
|
c.Close()
|
||||||
}
|
}
|
||||||
if c, err := ln.AcceptUnix(); err != nil {
|
if c, err := ln.AcceptUnix(); err != nil {
|
||||||
if !err.(net.Error).Timeout() {
|
if !err.(Error).Timeout() {
|
||||||
t.Errorf("net.TCPListener.AcceptTCP failed: %v", err)
|
t.Errorf("net.TCPListener.AcceptTCP failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -264,11 +266,11 @@ func TestUnixConnSpecificMethods(t *testing.T) {
|
|||||||
os.Remove(p2)
|
os.Remove(p2)
|
||||||
os.Remove(p3)
|
os.Remove(p3)
|
||||||
|
|
||||||
a1, err := net.ResolveUnixAddr("unixgram", p1)
|
a1, err := ResolveUnixAddr("unixgram", p1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.ResolveUnixAddr failed: %v", err)
|
t.Fatalf("net.ResolveUnixAddr failed: %v", err)
|
||||||
}
|
}
|
||||||
c1, err := net.DialUnix("unixgram", a1, nil)
|
c1, err := DialUnix("unixgram", a1, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("net.DialUnix failed: %v", err)
|
t.Fatalf("net.DialUnix failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -282,12 +284,12 @@ func TestUnixConnSpecificMethods(t *testing.T) {
|
|||||||
defer c1.Close()
|
defer c1.Close()
|
||||||
defer os.Remove(p1)
|
defer os.Remove(p1)
|
||||||
|
|
||||||
a2, err := net.ResolveUnixAddr("unixgram", p2)
|
a2, err := ResolveUnixAddr("unixgram", p2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("net.ResolveUnixAddr failed: %v", err)
|
t.Errorf("net.ResolveUnixAddr failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c2, err := net.DialUnix("unixgram", a2, nil)
|
c2, err := DialUnix("unixgram", a2, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("net.DialUnix failed: %v", err)
|
t.Errorf("net.DialUnix failed: %v", err)
|
||||||
return
|
return
|
||||||
@ -302,12 +304,12 @@ func TestUnixConnSpecificMethods(t *testing.T) {
|
|||||||
defer c2.Close()
|
defer c2.Close()
|
||||||
defer os.Remove(p2)
|
defer os.Remove(p2)
|
||||||
|
|
||||||
a3, err := net.ResolveUnixAddr("unixgram", p3)
|
a3, err := ResolveUnixAddr("unixgram", p3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("net.ResolveUnixAddr failed: %v", err)
|
t.Errorf("net.ResolveUnixAddr failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c3, err := net.ListenUnixgram("unixgram", a3)
|
c3, err := ListenUnixgram("unixgram", a3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("net.ListenUnixgram failed: %v", err)
|
t.Errorf("net.ListenUnixgram failed: %v", err)
|
||||||
return
|
return
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package filepath_test
|
package filepath
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "path/filepath"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -2,11 +2,10 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package debug_test
|
package debug
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
. "runtime/debug"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package debug_test
|
package debug
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "runtime/debug"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user