fix(verify): fix flaky JIT tests with global buffers and KeepAlive
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package verify
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -44,6 +45,7 @@ func TestProfilePaths(t *testing.T) {
|
||||
|
||||
// Build a corpus of varied LZ4 blocks.
|
||||
var argSets [][]byte
|
||||
var liveDsts [][]byte // keep dst buffers alive across ProfilePaths
|
||||
blocks := []struct {
|
||||
src []byte
|
||||
dstSize int
|
||||
@@ -63,6 +65,7 @@ func TestProfilePaths(t *testing.T) {
|
||||
PutUint64(args, 8, uint64(len(b.src)))
|
||||
PutUint64(args, 16, uint64(cap(b.src)))
|
||||
dst := make([]byte, b.dstSize)
|
||||
liveDsts = append(liveDsts, dst)
|
||||
if len(dst) > 0 {
|
||||
PutPtr(args, 24, unsafe.Pointer(&dst[0]))
|
||||
}
|
||||
@@ -73,6 +76,8 @@ func TestProfilePaths(t *testing.T) {
|
||||
|
||||
// Result offsets: n+48 and code+56.
|
||||
paths, err := k.ProfilePaths("decodeBlockAVX2", argSets, []int{48, 56})
|
||||
runtime.KeepAlive(blocks)
|
||||
runtime.KeepAlive(liveDsts)
|
||||
if err != nil {
|
||||
t.Fatalf("ProfilePaths: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user