Source file src/cmd/nm/nm_cgo_test.go

     1  // Copyright 2017 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 cgo
     6  
     7  package main
     8  
     9  import (
    10  	"runtime"
    11  	"testing"
    12  )
    13  
    14  func canInternalLink() bool {
    15  	switch runtime.GOOS {
    16  	case "aix":
    17  		return false
    18  	case "dragonfly":
    19  		return false
    20  	case "freebsd":
    21  		switch runtime.GOARCH {
    22  		case "arm64":
    23  			return false
    24  		}
    25  	case "linux":
    26  		switch runtime.GOARCH {
    27  		case "arm64", "mips64", "mips64le", "mips", "mipsle", "ppc64", "ppc64le", "riscv64":
    28  			return false
    29  		}
    30  	case "openbsd":
    31  		switch runtime.GOARCH {
    32  		case "arm64", "mips64":
    33  			return false
    34  		}
    35  	case "windows":
    36  		switch runtime.GOARCH {
    37  		case "arm64":
    38  			return false
    39  		}
    40  	}
    41  	return true
    42  }
    43  
    44  func TestInternalLinkerCgoExec(t *testing.T) {
    45  	if !canInternalLink() {
    46  		t.Skip("skipping; internal linking is not supported")
    47  	}
    48  	testGoExec(t, true, false)
    49  }
    50  
    51  func TestExternalLinkerCgoExec(t *testing.T) {
    52  	testGoExec(t, true, true)
    53  }
    54  
    55  func TestCgoLib(t *testing.T) {
    56  	testGoLib(t, true)
    57  }
    58  

View as plain text