fix(verify): fix flaky JIT tests with global buffers and KeepAlive
Test / vet (push) Successful in 49s
Test / test (push) Failing after 2m9s
Test / build (push) Skipped

This commit is contained in:
2026-08-05 23:09:54 +02:00
parent 23b3d3e152
commit 19b37569c0
10 changed files with 323 additions and 38 deletions
+5
View File
@@ -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)
}