github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/link/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  	"path/filepath"
     9  	"testing"
    10  
    11  	"github.com/go-asm/go/testenv"
    12  )
    13  
    14  func TestNooptCgoBuild(t *testing.T) {
    15  	if testing.Short() {
    16  		t.Skip("skipping test in short mode.")
    17  	}
    18  	t.Parallel()
    19  
    20  	testenv.MustHaveGoBuild(t)
    21  	testenv.MustHaveCGO(t)
    22  	dir := t.TempDir()
    23  	cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-gcflags=-N -l", "-o", filepath.Join(dir, "a.out"))
    24  	cmd.Dir = filepath.Join(testenv.GOROOT(t), "src", "runtime", "testdata", "testprogcgo")
    25  	out, err := cmd.CombinedOutput()
    26  	if err != nil {
    27  		t.Logf("go build output: %s", out)
    28  		t.Fatal(err)
    29  	}
    30  }