...
Run Format

Source file src/net/cgo_unix_test.go

Documentation: net

     1  // Copyright 2013 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build cgo,!netgo
     6  // +build darwin dragonfly freebsd linux netbsd openbsd solaris
     7  
     8  package net
     9  
    10  import (
    11  	"context"
    12  	"testing"
    13  )
    14  
    15  func TestCgoLookupIP(t *testing.T) {
    16  	defer dnsWaitGroup.Wait()
    17  	ctx := context.Background()
    18  	_, err, ok := cgoLookupIP(ctx, "localhost")
    19  	if !ok {
    20  		t.Errorf("cgoLookupIP must not be a placeholder")
    21  	}
    22  	if err != nil {
    23  		t.Error(err)
    24  	}
    25  }
    26  
    27  func TestCgoLookupIPWithCancel(t *testing.T) {
    28  	defer dnsWaitGroup.Wait()
    29  	ctx, cancel := context.WithCancel(context.Background())
    30  	defer cancel()
    31  	_, err, ok := cgoLookupIP(ctx, "localhost")
    32  	if !ok {
    33  		t.Errorf("cgoLookupIP must not be a placeholder")
    34  	}
    35  	if err != nil {
    36  		t.Error(err)
    37  	}
    38  }
    39  
    40  func TestCgoLookupPort(t *testing.T) {
    41  	defer dnsWaitGroup.Wait()
    42  	ctx := context.Background()
    43  	_, err, ok := cgoLookupPort(ctx, "tcp", "smtp")
    44  	if !ok {
    45  		t.Errorf("cgoLookupPort must not be a placeholder")
    46  	}
    47  	if err != nil {
    48  		t.Error(err)
    49  	}
    50  }
    51  
    52  func TestCgoLookupPortWithCancel(t *testing.T) {
    53  	defer dnsWaitGroup.Wait()
    54  	ctx, cancel := context.WithCancel(context.Background())
    55  	defer cancel()
    56  	_, err, ok := cgoLookupPort(ctx, "tcp", "smtp")
    57  	if !ok {
    58  		t.Errorf("cgoLookupPort must not be a placeholder")
    59  	}
    60  	if err != nil {
    61  		t.Error(err)
    62  	}
    63  }
    64  
    65  func TestCgoLookupPTR(t *testing.T) {
    66  	defer dnsWaitGroup.Wait()
    67  	ctx := context.Background()
    68  	_, err, ok := cgoLookupPTR(ctx, "127.0.0.1")
    69  	if !ok {
    70  		t.Errorf("cgoLookupPTR must not be a placeholder")
    71  	}
    72  	if err != nil {
    73  		t.Error(err)
    74  	}
    75  }
    76  
    77  func TestCgoLookupPTRWithCancel(t *testing.T) {
    78  	defer dnsWaitGroup.Wait()
    79  	ctx, cancel := context.WithCancel(context.Background())
    80  	defer cancel()
    81  	_, err, ok := cgoLookupPTR(ctx, "127.0.0.1")
    82  	if !ok {
    83  		t.Errorf("cgoLookupPTR must not be a placeholder")
    84  	}
    85  	if err != nil {
    86  		t.Error(err)
    87  	}
    88  }
    89  

View as plain text