github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/link/internal/ld/nooptcgolink_test.go (about) 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 "github.com/gagliardetto/golang-go/not-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 if testing.Short() { 19 t.Skip("skipping test in short mode.") 20 } 21 t.Parallel() 22 23 testenv.MustHaveGoBuild(t) 24 testenv.MustHaveCGO(t) 25 dir, err := ioutil.TempDir("", "go-build") 26 if err != nil { 27 t.Fatal(err) 28 } 29 defer os.RemoveAll(dir) 30 cmd := exec.Command(testenv.GoToolPath(t), "build", "-gcflags=-N -l", "-o", filepath.Join(dir, "a.out")) 31 cmd.Dir = filepath.Join(runtime.GOROOT(), "src", "runtime", "testdata", "testprogcgo") 32 out, err := cmd.CombinedOutput() 33 if err != nil { 34 t.Logf("go build output: %s", out) 35 t.Fatal(err) 36 } 37 }