...
Run Format

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

Documentation: cmd/link/internal/ld

     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  package ld
     6  
     7  import (
     8  	"internal/testenv"
     9  	"io/ioutil"
    10  	"os"
    11  	"os/exec"
    12  	"path/filepath"
    13  	"runtime"
    14  	"testing"
    15  )
    16  
    17  func TestNooptCgoBuild(t *testing.T) {
    18  	testenv.MustHaveGoBuild(t)
    19  	testenv.MustHaveCGO(t)
    20  	dir, err := ioutil.TempDir("", "go-build")
    21  	if err != nil {
    22  		t.Fatal(err)
    23  	}
    24  	defer os.RemoveAll(dir)
    25  	cmd := exec.Command(testenv.GoToolPath(t), "build", "-gcflags=-N -l", "-o", filepath.Join(dir, "a.out"))
    26  	cmd.Dir = filepath.Join(runtime.GOROOT(), "src", "runtime", "testdata", "testprogcgo")
    27  	out, err := cmd.CombinedOutput()
    28  	if err != nil {
    29  		t.Logf("go build output: %s", out)
    30  		t.Fatal(err)
    31  	}
    32  }
    33  

View as plain text