...
Source file
src/net/cgo_unix_test.go
Documentation: net
1
2
3
4
5
6
7
8
9
10 package net
11
12 import (
13 "context"
14 "testing"
15 )
16
17 func TestCgoLookupIP(t *testing.T) {
18 defer dnsWaitGroup.Wait()
19 ctx := context.Background()
20 _, err, ok := cgoLookupIP(ctx, "ip", "localhost")
21 if !ok {
22 t.Errorf("cgoLookupIP must not be a placeholder")
23 }
24 if err != nil {
25 t.Error(err)
26 }
27 }
28
29 func TestCgoLookupIPWithCancel(t *testing.T) {
30 defer dnsWaitGroup.Wait()
31 ctx, cancel := context.WithCancel(context.Background())
32 defer cancel()
33 _, err, ok := cgoLookupIP(ctx, "ip", "localhost")
34 if !ok {
35 t.Errorf("cgoLookupIP must not be a placeholder")
36 }
37 if err != nil {
38 t.Error(err)
39 }
40 }
41
42 func TestCgoLookupPort(t *testing.T) {
43 defer dnsWaitGroup.Wait()
44 ctx := context.Background()
45 _, err, ok := cgoLookupPort(ctx, "tcp", "smtp")
46 if !ok {
47 t.Errorf("cgoLookupPort must not be a placeholder")
48 }
49 if err != nil {
50 t.Error(err)
51 }
52 }
53
54 func TestCgoLookupPortWithCancel(t *testing.T) {
55 defer dnsWaitGroup.Wait()
56 ctx, cancel := context.WithCancel(context.Background())
57 defer cancel()
58 _, err, ok := cgoLookupPort(ctx, "tcp", "smtp")
59 if !ok {
60 t.Errorf("cgoLookupPort must not be a placeholder")
61 }
62 if err != nil {
63 t.Error(err)
64 }
65 }
66
67 func TestCgoLookupPTR(t *testing.T) {
68 defer dnsWaitGroup.Wait()
69 ctx := context.Background()
70 _, err, ok := cgoLookupPTR(ctx, "127.0.0.1")
71 if !ok {
72 t.Errorf("cgoLookupPTR must not be a placeholder")
73 }
74 if err != nil {
75 t.Error(err)
76 }
77 }
78
79 func TestCgoLookupPTRWithCancel(t *testing.T) {
80 defer dnsWaitGroup.Wait()
81 ctx, cancel := context.WithCancel(context.Background())
82 defer cancel()
83 _, err, ok := cgoLookupPTR(ctx, "127.0.0.1")
84 if !ok {
85 t.Errorf("cgoLookupPTR must not be a placeholder")
86 }
87 if err != nil {
88 t.Error(err)
89 }
90 }
91
View as plain text