]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: skip TestUnshareMountNameSpaceChroot on platforms that require external...
authorBryan C. Mills <bcmills@google.com>
Thu, 24 Aug 2023 14:45:11 +0000 (10:45 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 24 Aug 2023 17:32:08 +0000 (17:32 +0000)
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 <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/syscall/exec_linux_test.go

index f894bbaae92399bceaaefb43a9ea90868a3a61d2..873ae4f9151a34cc268ed66d84098f84e39bb0a4 100644 (file)
@@ -10,6 +10,7 @@ import (
        "bytes"
        "flag"
        "fmt"
+       "internal/platform"
        "internal/testenv"
        "io"
        "os"
@@ -285,6 +286,9 @@ func TestUnshareMountNameSpaceChroot(t *testing.T) {
        // Since we are doing a chroot, we need the binary there,
        // and it must be statically linked.
        testenv.MustHaveGoBuild(t)
+       if platform.MustLinkExternal(runtime.GOOS, runtime.GOARCH, false) {
+               t.Skipf("skipping: can't build static binary because %s/%s requires external linking", runtime.GOOS, runtime.GOARCH)
+       }
        x := filepath.Join(d, "syscall.test")
        t.Cleanup(func() {
                // If the subprocess fails to unshare the parent directory, force-unmount it
@@ -297,7 +301,7 @@ func TestUnshareMountNameSpaceChroot(t *testing.T) {
        cmd := testenv.Command(t, testenv.GoToolPath(t), "test", "-c", "-o", x, "syscall")
        cmd.Env = append(cmd.Environ(), "CGO_ENABLED=0")
        if o, err := cmd.CombinedOutput(); err != nil {
-               t.Fatalf("Build of syscall in chroot failed, output %v, err %v", o, err)
+               t.Fatalf("%v: %v\n%s", cmd, err, o)
        }
 
        cmd = testenv.Command(t, "/syscall.test", "-test.run=TestUnshareMountNameSpaceChroot", "/")