Skip to content

Commit

Permalink
fix mmap
Browse files Browse the repository at this point in the history
  • Loading branch information
roseduan committed Jun 8, 2022
1 parent 2a86066 commit 14c35fa
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions mmap/mmap_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mmap

import (
"github.com/flower-corp/rosedb/logger"
"github.com/stretchr/testify/assert"
"io/ioutil"
"os"
Expand All @@ -18,8 +19,7 @@ func TestMmap(t *testing.T) {
defer func() {
if fd != nil {
_ = fd.Close()
err := os.Remove(fd.Name())
assert.Nil(t, err)
destroyDir(path)
}
}()
type args struct {
Expand Down Expand Up @@ -63,8 +63,7 @@ func TestMunmap(t *testing.T) {
defer func() {
if fd != nil {
_ = fd.Close()
err := os.Remove(fd.Name())
assert.Nil(t, err)
destroyDir(path)
}
}()

Expand All @@ -84,8 +83,7 @@ func TestMsync(t *testing.T) {
defer func() {
if fd != nil {
_ = fd.Close()
err := os.Remove(fd.Name())
assert.Nil(t, err)
destroyDir(path)
}
}()

Expand All @@ -105,8 +103,7 @@ func TestMadvise(t *testing.T) {
defer func() {
if fd != nil {
_ = fd.Close()
err := os.RemoveAll(path)
assert.Nil(t, err)
destroyDir(path)
}
}()

Expand All @@ -115,3 +112,9 @@ func TestMadvise(t *testing.T) {
err = Madvise(buf, false)
assert.Nil(t, err)
}

func destroyDir(dir string) {
if err := os.RemoveAll(dir); err != nil {
logger.Warnf("remove dir err: %v", err)
}
}

0 comments on commit 14c35fa

Please sign in to comment.