]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.14-security] cmd/go: add test case for cgo CC setting
authorRuss Cox <rsc@golang.org>
Mon, 11 Jan 2021 14:43:08 +0000 (09:43 -0500)
committerRoland Shoemaker <roland@golang.org>
Sat, 16 Jan 2021 01:43:57 +0000 (17:43 -0800)
Change-Id: Ied986053a64447c5eac6369f6c9b69ed3d3f94d9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/949415
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit e97d4ed8dcc1fed64fe44b56dfdfb0f929aabb65)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955298
Reviewed-by: Katie Hockman <katiehockman@google.com>
src/cmd/go/testdata/script/cgo_path.txt [new file with mode: 0644]

diff --git a/src/cmd/go/testdata/script/cgo_path.txt b/src/cmd/go/testdata/script/cgo_path.txt
new file mode 100644 (file)
index 0000000..e4d07de
--- /dev/null
@@ -0,0 +1,35 @@
+[!cgo] skip
+
+env GOCACHE=$WORK/gocache  # Looking for compile flags, so need a clean cache.
+[!windows] env PATH=.:$PATH
+[!windows] chmod 0777 p/gcc p/clang
+[!windows] exists p/gcc p/clang
+[windows] exists p/gcc.bat p/clang.bat
+! exists p/bug.txt
+go build -x
+! exists p/bug.txt
+
+-- go.mod --
+module m
+
+-- m.go --
+package m
+
+import _ "m/p"
+
+-- p/p.go --
+package p
+
+// #define X 1
+import "C"
+
+-- p/gcc --
+#!/bin/sh
+echo ran gcc >bug.txt
+-- p/clang --
+#!/bin/sh
+echo ran clang >bug.txt
+-- p/gcc.bat --
+echo ran gcc >bug.txt
+-- p/clang.bat --
+echo ran clang >bug.txt