Пример #1
0
func TestShmMemoryRegion(t *testing.T) {
	if !SetupOptional() {
		t.Skip("skipping TestShmMemoryRegion")
		return
	}
	buf, err := shm.NewBufferTmpfs(64<<20, shm.PROT_RDWR)
	if err != nil {
		panic(err)
	}
	mr, err := RegisterMemory(buf.Bytes())
	if err != nil {
		panic(err)
	}
	checkClose(mr)
	checkClose(buf)

	buf, err = shm.NewBufferHugepages(64<<20, shm.PROT_RDWR)
	if err != nil {
		panic(err)
	}
	mr, err = RegisterMemory(buf.Bytes())
	if err != nil {
		panic(err)
	}
	checkClose(mr)
	checkClose(buf)
}
Пример #2
0
func init() {
	if !SetupOptional() {
		return
	}
	var err error
	tmpfsBuf, err = shm.NewBufferTmpfs(2<<20, shm.PROT_RDWR)
	if err != nil {
		panic(err)
	}
	hugeBuf, err = shm.NewBufferHugepages(64<<20, shm.PROT_RDWR)
	if err != nil {
		panic(err)
	}
}