gosl_test.go 460 B

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