]> Cypherpunks repositories - gostls13.git/commit
misc/reboot: don't use symlinks when copying GOROOT/src
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 8 Feb 2022 14:49:30 +0000 (14:49 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 8 Feb 2022 15:30:12 +0000 (15:30 +0000)
commitef06a5f44a46dfaf601ca79717ffb00b3591d297
treef5f92fdd7d45a93bf690076e66c175f6819aeb63
parentc856fbf36190cef65ac6639a048cd512e4b7fc0a
misc/reboot: don't use symlinks when copying GOROOT/src

go:embed disallows using symlinked files by design.
crypto/elliptic is the first std package to use it as of CL 380475,
and unfortunately that broke the TestRepeatBootstrap long test.

The reason it uses symlinks is for speed; it wants to copy GOROOT/src,
but regular files aren't going to be modified in any way,
so a symlink, if supported, means not needing to copy the contents.

Replace the symlink attempt with hard links,
which will mean regular files remain as such, fixing go:embed.
It's worth noting that on many systems hard links won't work,
as the temporary filesystem tends to be separate,
but it doesn't hurt to try.

In my system, where /tmp is tmpfs, the test now copies more bytes.
With the added Logf, I can see overlayDir goes from ~30ms to ~100ms.
This makes sense, as GOROOT/src currently weighs around 100MiB.
To alleviate that slow-down, stop copying testdata directories,
as they currently weigh around 20MiB and aren't needed for the test.
This gets overlayDir on my system down to an acceptable ~70ms.

I briefly considered teaching overlayDir what files can be symlinks,
but that seemed fairly complex long-term, as any file could be embedded.

While here, start using testing.T.TempDir and fs.WalkDir.

For #50995.

Change-Id: I17947e6bdee96237e1ca0606ad0b95e7c5987bc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/383995
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
misc/reboot/overlaydir_test.go
misc/reboot/reboot_test.go