Source file src/crypto/internal/cryptotest/allocations.go

     1  // Copyright 2024 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package cryptotest
     6  
     7  import (
     8  	"crypto/internal/boring"
     9  	"internal/asan"
    10  	"internal/msan"
    11  	"internal/race"
    12  	"internal/testenv"
    13  	"runtime"
    14  	"testing"
    15  )
    16  
    17  // SkipTestAllocations skips the test if there are any factors that interfere
    18  // with allocation optimizations.
    19  func SkipTestAllocations(t *testing.T) {
    20  	// Go+BoringCrypto uses cgo.
    21  	if boring.Enabled {
    22  		t.Skip("skipping allocations test with BoringCrypto")
    23  	}
    24  
    25  	// The sanitizers sometimes cause allocations.
    26  	if race.Enabled || msan.Enabled || asan.Enabled {
    27  		t.Skip("skipping allocations test with sanitizers")
    28  	}
    29  
    30  	// The plan9 crypto/rand allocates.
    31  	if runtime.GOOS == "plan9" {
    32  		t.Skip("skipping allocations test on plan9")
    33  	}
    34  
    35  	// s390x deviates from other assembly implementations and is very hard to
    36  	// test due to the lack of LUCI builders. See #67307.
    37  	if runtime.GOARCH == "s390x" {
    38  		t.Skip("skipping allocations test on s390x")
    39  	}
    40  
    41  	// Some APIs rely on inliner and devirtualization to allocate on the stack.
    42  	testenv.SkipIfOptimizationOff(t)
    43  }
    44  

View as plain text