You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

read_unix.go 1.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //go:build linux || darwin || freebsd
  2. package vfstest
  3. import (
  4. "syscall"
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. // TestReadFileDoubleClose tests double close on read
  9. func TestReadFileDoubleClose(t *testing.T) {
  10. run.skipIfVFS(t)
  11. run.skipIfNoFUSE(t)
  12. run.createFile(t, "testdoubleclose", "hello")
  13. in, err := run.os.Open(run.path("testdoubleclose"))
  14. assert.NoError(t, err)
  15. fd := in.Fd()
  16. fd1, err := syscall.Dup(int(fd))
  17. assert.NoError(t, err)
  18. fd2, err := syscall.Dup(int(fd))
  19. assert.NoError(t, err)
  20. // close one of the dups - should produce no error
  21. err = syscall.Close(fd1)
  22. assert.NoError(t, err)
  23. // read from the file
  24. buf := make([]byte, 1)
  25. _, err = in.Read(buf)
  26. assert.NoError(t, err)
  27. // close it
  28. err = in.Close()
  29. assert.NoError(t, err)
  30. // read from the other dup - should produce no error as this
  31. // file is now buffered
  32. n, err := syscall.Read(fd2, buf)
  33. assert.NoError(t, err)
  34. assert.Equal(t, 1, n)
  35. // close the dup - should not produce an error
  36. err = syscall.Close(fd2)
  37. assert.NoError(t, err, "input/output error")
  38. run.rm(t, "testdoubleclose")
  39. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。