summaryrefslogtreecommitdiff
path: root/libgo/go/net/cgo_unix_test.go
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-05-02 14:43:35 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-05-02 14:43:35 +0000
commit34efdaf078b01a7387007c4e6bde6db86384c4b7 (patch)
treed503eaf41d085669d1481bb46ec038bc866fece6 /libgo/go/net/cgo_unix_test.go
parentf733cf303bcdc952c92b81dd62199a40a1f555ec (diff)
downloadgcc-tarball-master.tar.gz
gcc-7.1.0gcc-7.1.0
Diffstat (limited to 'libgo/go/net/cgo_unix_test.go')
-rw-r--r--libgo/go/net/cgo_unix_test.go66
1 files changed, 62 insertions, 4 deletions
diff --git a/libgo/go/net/cgo_unix_test.go b/libgo/go/net/cgo_unix_test.go
index 4d5ab23fd3..e861c7aa1f 100644
--- a/libgo/go/net/cgo_unix_test.go
+++ b/libgo/go/net/cgo_unix_test.go
@@ -7,18 +7,76 @@
package net
-import "testing"
+import (
+ "context"
+ "testing"
+)
func TestCgoLookupIP(t *testing.T) {
- host := "localhost"
- _, err, ok := cgoLookupIP(host)
+ ctx := context.Background()
+ _, err, ok := cgoLookupIP(ctx, "localhost")
if !ok {
t.Errorf("cgoLookupIP must not be a placeholder")
}
if err != nil {
t.Error(err)
}
- if _, err := goLookupIP(host); err != nil {
+}
+
+func TestCgoLookupIPWithCancel(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ _, err, ok := cgoLookupIP(ctx, "localhost")
+ if !ok {
+ t.Errorf("cgoLookupIP must not be a placeholder")
+ }
+ if err != nil {
+ t.Error(err)
+ }
+}
+
+func TestCgoLookupPort(t *testing.T) {
+ ctx := context.Background()
+ _, err, ok := cgoLookupPort(ctx, "tcp", "smtp")
+ if !ok {
+ t.Errorf("cgoLookupPort must not be a placeholder")
+ }
+ if err != nil {
+ t.Error(err)
+ }
+}
+
+func TestCgoLookupPortWithCancel(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ _, err, ok := cgoLookupPort(ctx, "tcp", "smtp")
+ if !ok {
+ t.Errorf("cgoLookupPort must not be a placeholder")
+ }
+ if err != nil {
+ t.Error(err)
+ }
+}
+
+func TestCgoLookupPTR(t *testing.T) {
+ ctx := context.Background()
+ _, err, ok := cgoLookupPTR(ctx, "127.0.0.1")
+ if !ok {
+ t.Errorf("cgoLookupPTR must not be a placeholder")
+ }
+ if err != nil {
+ t.Error(err)
+ }
+}
+
+func TestCgoLookupPTRWithCancel(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ _, err, ok := cgoLookupPTR(ctx, "127.0.0.1")
+ if !ok {
+ t.Errorf("cgoLookupPTR must not be a placeholder")
+ }
+ if err != nil {
t.Error(err)
}
}