...

Source file src/cmd/link/internal/ld/issue33808_test.go

Documentation: cmd/link/internal/ld

     1  // Copyright 2019 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  package ld
     6  
     7  import (
     8  	"internal/testenv"
     9  	"runtime"
    10  	"strings"
    11  	"testing"
    12  )
    13  
    14  const prog = `
    15  package main
    16  
    17  import "log"
    18  
    19  func main() {
    20  	log.Fatalf("HERE")
    21  }
    22  `
    23  
    24  func TestIssue33808(t *testing.T) {
    25  	if runtime.GOOS != "darwin" {
    26  		return
    27  	}
    28  	testenv.MustHaveGoBuild(t)
    29  	testenv.MustHaveCGO(t)
    30  	t.Parallel()
    31  
    32  	dir := t.TempDir()
    33  
    34  	f := gobuild(t, dir, prog, "-ldflags=-linkmode=external")
    35  	f.Close()
    36  
    37  	syms, err := f.Symbols()
    38  	if err != nil {
    39  		t.Fatalf("Error reading symbols: %v", err)
    40  	}
    41  
    42  	name := "log.Fatalf"
    43  	for _, sym := range syms {
    44  		if strings.Contains(sym.Name, name) {
    45  			return
    46  		}
    47  	}
    48  	t.Fatalf("Didn't find %v", name)
    49  }
    50  

View as plain text