go/src/net/cgo_unix_test.go
database64128 ba1109feb5 net: remove redundant cgoLookupCNAME return parameter
`completed bool` just means `err == nil` after CL 446179.

While here, add a test for cgoLookupCNAME.

Co-authored-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Change-Id: I6081a089fde3cb27af4fbde6f04301fc3755272c
Reviewed-on: https://go-review.googlesource.com/c/go/+/698615
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-08-28 16:10:24 -07:00

79 lines
1.7 KiB
Go

// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !netgo && ((cgo && unix) || darwin)
package net
import (
"context"
"internal/testenv"
"testing"
)
func TestCgoLookupIP(t *testing.T) {
defer dnsWaitGroup.Wait()
ctx := context.Background()
_, err := cgoLookupIP(ctx, "ip", "localhost")
if err != nil {
t.Error(err)
}
}
func TestCgoLookupIPWithCancel(t *testing.T) {
defer dnsWaitGroup.Wait()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_, err := cgoLookupIP(ctx, "ip", "localhost")
if err != nil {
t.Error(err)
}
}
func TestCgoLookupPort(t *testing.T) {
defer dnsWaitGroup.Wait()
ctx := context.Background()
_, err := cgoLookupPort(ctx, "tcp", "smtp")
if err != nil {
t.Error(err)
}
}
func TestCgoLookupPortWithCancel(t *testing.T) {
defer dnsWaitGroup.Wait()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_, err := cgoLookupPort(ctx, "tcp", "smtp")
if err != nil {
t.Error(err)
}
}
func TestCgoLookupPTR(t *testing.T) {
defer dnsWaitGroup.Wait()
ctx := context.Background()
_, err := cgoLookupPTR(ctx, "127.0.0.1")
if err != nil {
t.Error(err)
}
}
func TestCgoLookupPTRWithCancel(t *testing.T) {
defer dnsWaitGroup.Wait()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_, err := cgoLookupPTR(ctx, "127.0.0.1")
if err != nil {
t.Error(err)
}
}
func TestCgoLookupCNAME(t *testing.T) {
mustHaveExternalNetwork(t)
testenv.SkipFlakyNet(t)
defer dnsWaitGroup.Wait()
if _, err := cgoLookupCNAME(t.Context(), "www.iana.org."); err != nil {
t.Error(err)
}
}