aboutsummaryrefslogtreecommitdiff
path: root/src/os/readfrom_linux_test.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2025-01-27 14:05:22 -0800
committerGopher Robot <gobot@golang.org>2025-01-29 06:29:28 -0800
commit1f58ad5d6d2eebc1939a65a511ca84c9b997cd6a (patch)
tree4445aa22d65de5dd116f24b0f9a474b2ca6e676b /src/os/readfrom_linux_test.go
parent90ec9996cb6e7ea98ffeab1b6e28037d79e81026 (diff)
downloadgo-1f58ad5d6d2eebc1939a65a511ca84c9b997cd6a.tar.xz
Revert "os: employ sendfile(2) for file-to-file copying on Linux when needed"
This reverts CL 603295. Reason for revert: can cause child exit_group to hang. This is not a clean revert. CL 603098 did a major refactoring of the tests. That refactor is kept, just the sendfile-specific tests are dropped from the linux tests. Fixes #71375. Change-Id: Ic4d6535759667c69a44bd9281bbb33d5b559f591 Reviewed-on: https://go-review.googlesource.com/c/go/+/644895 Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Andy Pan <panjf2000@gmail.com>
Diffstat (limited to 'src/os/readfrom_linux_test.go')
-rw-r--r--src/os/readfrom_linux_test.go52
1 files changed, 2 insertions, 50 deletions
diff --git a/src/os/readfrom_linux_test.go b/src/os/readfrom_linux_test.go
index cc0322882b..d33f9cf9c9 100644
--- a/src/os/readfrom_linux_test.go
+++ b/src/os/readfrom_linux_test.go
@@ -242,13 +242,12 @@ func testSpliceToTTY(t *testing.T, proto string, size int64) {
}
var (
- copyFileTests = []copyFileTestFunc{newCopyFileRangeTest, newSendfileOverCopyFileRangeTest}
- copyFileHooks = []copyFileTestHook{hookCopyFileRange, hookSendFileOverCopyFileRange}
+ copyFileTests = []copyFileTestFunc{newCopyFileRangeTest}
+ copyFileHooks = []copyFileTestHook{hookCopyFileRange}
)
func testCopyFiles(t *testing.T, size, limit int64) {
testCopyFileRange(t, size, limit)
- testSendfileOverCopyFileRange(t, size, limit)
}
func testCopyFileRange(t *testing.T, size int64, limit int64) {
@@ -256,11 +255,6 @@ func testCopyFileRange(t *testing.T, size int64, limit int64) {
testCopyFile(t, dst, src, data, hook, limit, name)
}
-func testSendfileOverCopyFileRange(t *testing.T, size int64, limit int64) {
- dst, src, data, hook, name := newSendfileOverCopyFileRangeTest(t, size)
- testCopyFile(t, dst, src, data, hook, limit, name)
-}
-
// newCopyFileRangeTest initializes a new test for copy_file_range.
//
// It hooks package os' call to poll.CopyFileRange and returns the hook,
@@ -276,20 +270,6 @@ func newCopyFileRangeTest(t *testing.T, size int64) (dst, src *File, data []byte
return
}
-// newSendfileOverCopyFileRangeTest initializes a new test for sendfile over copy_file_range.
-// It hooks package os' call to poll.SendFile and returns the hook,
-// so it can be inspected.
-func newSendfileOverCopyFileRangeTest(t *testing.T, size int64) (dst, src *File, data []byte, hook *copyFileHook, name string) {
- t.Helper()
-
- name = "newSendfileOverCopyFileRangeTest"
-
- dst, src, data = newCopyFileTest(t, size)
- hook, _ = hookSendFileOverCopyFileRange(t)
-
- return
-}
-
// newSpliceFileTest initializes a new test for splice.
//
// It creates source sockets and destination file, and populates the source sockets
@@ -342,34 +322,6 @@ func hookCopyFileRange(t *testing.T) (hook *copyFileHook, name string) {
return
}
-func hookSendFileOverCopyFileRange(t *testing.T) (*copyFileHook, string) {
- return hookSendFileTB(t), "hookSendFileOverCopyFileRange"
-}
-
-func hookSendFileTB(tb testing.TB) *copyFileHook {
- // Disable poll.CopyFileRange to force the fallback to poll.SendFile.
- originalCopyFileRange := *PollCopyFileRangeP
- *PollCopyFileRangeP = func(dst, src *poll.FD, remain int64) (written int64, handled bool, err error) {
- return 0, false, nil
- }
-
- hook := new(copyFileHook)
- orig := poll.TestHookDidSendFile
- tb.Cleanup(func() {
- *PollCopyFileRangeP = originalCopyFileRange
- poll.TestHookDidSendFile = orig
- })
- poll.TestHookDidSendFile = func(dstFD *poll.FD, src int, written int64, err error, handled bool) {
- hook.called = true
- hook.dstfd = dstFD.Sysfd
- hook.srcfd = src
- hook.written = written
- hook.err = err
- hook.handled = handled
- }
- return hook
-}
-
func hookSpliceFile(t *testing.T) *spliceFileHook {
h := new(spliceFileHook)
h.install()