Skip to content

Commit db24f63

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommittedAug 24, 2023
syscall: skip TestUnshareMountNameSpaceChroot on platforms that require external linking
TestUnshareMountNameSpaceChroot attempts to build a statically-linked binary to run in a chroot, and sets CGO_ENABLED=0 in order to do so. Rather than trying to figure out some other way to coax the linker into building a static binary, let's just skip the test on Linux platforms that require external linking (namely android/arm). This should fix the build failure reported in https://build.golang.org/log/1ea245a9c2e916c81043db177be76778bab00058. While we're here, let's also fix the failure logging to make the text readable! Updates #46330. Change-Id: I4fa07640ce012ac141bf4698bc3215a7f146062c Reviewed-on: https://go-review.googlesource.com/c/go/+/522182 Auto-Submit: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent fe2c686 commit db24f63

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/syscall/exec_linux_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"bytes"
1111
"flag"
1212
"fmt"
13+
"internal/platform"
1314
"internal/testenv"
1415
"io"
1516
"os"
@@ -285,6 +286,9 @@ func TestUnshareMountNameSpaceChroot(t *testing.T) {
285286
// Since we are doing a chroot, we need the binary there,
286287
// and it must be statically linked.
287288
testenv.MustHaveGoBuild(t)
289+
if platform.MustLinkExternal(runtime.GOOS, runtime.GOARCH, false) {
290+
t.Skipf("skipping: can't build static binary because %s/%s requires external linking", runtime.GOOS, runtime.GOARCH)
291+
}
288292
x := filepath.Join(d, "syscall.test")
289293
t.Cleanup(func() {
290294
// If the subprocess fails to unshare the parent directory, force-unmount it
@@ -297,7 +301,7 @@ func TestUnshareMountNameSpaceChroot(t *testing.T) {
297301
cmd := testenv.Command(t, testenv.GoToolPath(t), "test", "-c", "-o", x, "syscall")
298302
cmd.Env = append(cmd.Environ(), "CGO_ENABLED=0")
299303
if o, err := cmd.CombinedOutput(); err != nil {
300-
t.Fatalf("Build of syscall in chroot failed, output %v, err %v", o, err)
304+
t.Fatalf("%v: %v\n%s", cmd, err, o)
301305
}
302306

303307
cmd = testenv.Command(t, "/syscall.test", "-test.run=TestUnshareMountNameSpaceChroot", "/")

0 commit comments

Comments
 (0)
Please sign in to comment.