mirror of
https://github.com/golang/go
synced 2024-11-24 08:00:12 -07:00
net: add test cases for the both of netgo, cgo DNS lookups
Update #4078 R=golang-dev, rsc CC=golang-dev https://golang.org/cl/14638043
This commit is contained in:
parent
2b693b7c19
commit
2b3ad827a6
24
src/pkg/net/cgo_unix_test.go
Normal file
24
src/pkg/net/cgo_unix_test.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2013 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build cgo,!netgo
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestCgoLookupIP(t *testing.T) {
|
||||||
|
host := "localhost"
|
||||||
|
_, err, ok := cgoLookupIP(host)
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("cgoLookupIP must not be a placeholder")
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("cgoLookupIP failed: %v", err)
|
||||||
|
}
|
||||||
|
if _, err := goLookupIP(host); err != nil {
|
||||||
|
t.Errorf("goLookupIP failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
24
src/pkg/net/netgo_unix_test.go
Normal file
24
src/pkg/net/netgo_unix_test.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2013 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !cgo netgo
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestGoLookupIP(t *testing.T) {
|
||||||
|
host := "localhost"
|
||||||
|
_, err, ok := cgoLookupIP(host)
|
||||||
|
if ok {
|
||||||
|
t.Errorf("cgoLookupIP must be a placeholder")
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("cgoLookupIP failed: %v", err)
|
||||||
|
}
|
||||||
|
if _, err := goLookupIP(host); err != nil {
|
||||||
|
t.Errorf("goLookupIP failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user