1
0

gosl_test.go 615 B

12345678910111213141516171819202122232425262728
  1. package main
  2. import "os"
  3. import "testing"
  4. import "github.com/dgraph-io/badger/y"
  5. var Size int64 = 128 * 1024 * 1024
  6. func TestMmap(t *testing.T) {
  7. t.Log("Trying mmap")
  8. var i int64
  9. for i = 1; i < 8; i++ {
  10. flags := os.O_RDWR | os.O_CREATE | os.O_EXCL
  11. f, err := os.OpenFile("test.md", flags, 0666)
  12. defer f.Close()
  13. y.Check(err)
  14. // size := int64(256 * 1024 * 1024)
  15. t.Logf("Size is : %v", i*Size)
  16. _, err = y.Mmap(f,false,i*Size)
  17. if err != nil {
  18. t.Errorf("mmap failed with error: %v", err)
  19. }
  20. err = os.Remove("test.md")
  21. if err != nil {
  22. t.Errorf("could not remove test.md: %v", err)
  23. }
  24. }
  25. }