1
0

gosl_test.go 710 B

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