PR target/117048 aarch64: Use more canonical and optimization-friendly representation...
[official-gcc.git] / libgo / go / net / cgo_unix_test.go
blob5264fcd0ff3d1515905680cb78df5df0b2929e2a
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.
5 //go:build cgo && !netgo && (aix || darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris)
7 package net
9 import (
10 "context"
11 "testing"
14 func TestCgoLookupIP(t *testing.T) {
15 defer dnsWaitGroup.Wait()
16 ctx := context.Background()
17 _, err, ok := cgoLookupIP(ctx, "ip", "localhost")
18 if !ok {
19 t.Errorf("cgoLookupIP must not be a placeholder")
21 if err != nil {
22 t.Error(err)
26 func TestCgoLookupIPWithCancel(t *testing.T) {
27 defer dnsWaitGroup.Wait()
28 ctx, cancel := context.WithCancel(context.Background())
29 defer cancel()
30 _, err, ok := cgoLookupIP(ctx, "ip", "localhost")
31 if !ok {
32 t.Errorf("cgoLookupIP must not be a placeholder")
34 if err != nil {
35 t.Error(err)
39 func TestCgoLookupPort(t *testing.T) {
40 defer dnsWaitGroup.Wait()
41 ctx := context.Background()
42 _, err, ok := cgoLookupPort(ctx, "tcp", "smtp")
43 if !ok {
44 t.Errorf("cgoLookupPort must not be a placeholder")
46 if err != nil {
47 t.Error(err)
51 func TestCgoLookupPortWithCancel(t *testing.T) {
52 defer dnsWaitGroup.Wait()
53 ctx, cancel := context.WithCancel(context.Background())
54 defer cancel()
55 _, err, ok := cgoLookupPort(ctx, "tcp", "smtp")
56 if !ok {
57 t.Errorf("cgoLookupPort must not be a placeholder")
59 if err != nil {
60 t.Error(err)
64 func TestCgoLookupPTR(t *testing.T) {
65 defer dnsWaitGroup.Wait()
66 ctx := context.Background()
67 _, err, ok := cgoLookupPTR(ctx, "127.0.0.1")
68 if !ok {
69 t.Errorf("cgoLookupPTR must not be a placeholder")
71 if err != nil {
72 t.Error(err)
76 func TestCgoLookupPTRWithCancel(t *testing.T) {
77 defer dnsWaitGroup.Wait()
78 ctx, cancel := context.WithCancel(context.Background())
79 defer cancel()
80 _, err, ok := cgoLookupPTR(ctx, "127.0.0.1")
81 if !ok {
82 t.Errorf("cgoLookupPTR must not be a placeholder")
84 if err != nil {
85 t.Error(err)