Source file src/net/cgo_unix_test.go

     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  //go:build !netgo && ((cgo && unix) || darwin)
     6  
     7  package net
     8  
     9  import (
    10  	"context"
    11  	"testing"
    12  )
    13  
    14  func TestCgoLookupIP(t *testing.T) {
    15  	defer dnsWaitGroup.Wait()
    16  	ctx := context.Background()
    17  	_, err := cgoLookupIP(ctx, "ip", "localhost")
    18  	if err != nil {
    19  		t.Error(err)
    20  	}
    21  }
    22  
    23  func TestCgoLookupIPWithCancel(t *testing.T) {
    24  	defer dnsWaitGroup.Wait()
    25  	ctx, cancel := context.WithCancel(context.Background())
    26  	defer cancel()
    27  	_, err := cgoLookupIP(ctx, "ip", "localhost")
    28  	if err != nil {
    29  		t.Error(err)
    30  	}
    31  }
    32  
    33  func TestCgoLookupPort(t *testing.T) {
    34  	defer dnsWaitGroup.Wait()
    35  	ctx := context.Background()
    36  	_, err := cgoLookupPort(ctx, "tcp", "smtp")
    37  	if err != nil {
    38  		t.Error(err)
    39  	}
    40  }
    41  
    42  func TestCgoLookupPortWithCancel(t *testing.T) {
    43  	defer dnsWaitGroup.Wait()
    44  	ctx, cancel := context.WithCancel(context.Background())
    45  	defer cancel()
    46  	_, err := cgoLookupPort(ctx, "tcp", "smtp")
    47  	if err != nil {
    48  		t.Error(err)
    49  	}
    50  }
    51  
    52  func TestCgoLookupPTR(t *testing.T) {
    53  	defer dnsWaitGroup.Wait()
    54  	ctx := context.Background()
    55  	_, err := cgoLookupPTR(ctx, "127.0.0.1")
    56  	if err != nil {
    57  		t.Error(err)
    58  	}
    59  }
    60  
    61  func TestCgoLookupPTRWithCancel(t *testing.T) {
    62  	defer dnsWaitGroup.Wait()
    63  	ctx, cancel := context.WithCancel(context.Background())
    64  	defer cancel()
    65  	_, err := cgoLookupPTR(ctx, "127.0.0.1")
    66  	if err != nil {
    67  		t.Error(err)
    68  	}
    69  }
    70  

View as plain text