mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.boringcrypto] crypto/internal/boring: fix detection of tests to allow *.test and *_test
When using the go command, test binaries end in .test, but when using Bazel, test binaries conventionally end in _test. Change-Id: Ic4cac8722fd93ae316169f87b321f68e0b71f0c3 Reviewed-on: https://go-review.googlesource.com/63913 Reviewed-by: Adam Langley <agl@golang.org>
This commit is contained in:
parent
c9e2d9eb06
commit
aa4a4a80ff
1 changed files with 8 additions and 3 deletions
|
|
@ -30,12 +30,17 @@ func Unreachable() {
|
||||||
// provided by runtime to avoid os import
|
// provided by runtime to avoid os import
|
||||||
func runtime_arg0() string
|
func runtime_arg0() string
|
||||||
|
|
||||||
|
func hasSuffix(s, t string) bool {
|
||||||
|
return len(s) > len(t) && s[len(s)-len(t):] == t
|
||||||
|
}
|
||||||
|
|
||||||
// UnreachableExceptTests marks code that should be unreachable
|
// UnreachableExceptTests marks code that should be unreachable
|
||||||
// when BoringCrypto is in use. It panics.
|
// when BoringCrypto is in use. It panics.
|
||||||
func UnreachableExceptTests() {
|
func UnreachableExceptTests() {
|
||||||
arg0 := runtime_arg0()
|
name := runtime_arg0()
|
||||||
if len(arg0) < 5 || arg0[len(arg0)-5:] != ".test" {
|
// If BoringCrypto ran on Windows we'd need to allow _test.exe and .test.exe as well.
|
||||||
println("ARG0", arg0)
|
if !hasSuffix(name, "_test") && !hasSuffix(name, ".test") {
|
||||||
|
println("boringcrypto: unexpected code execution in", name)
|
||||||
panic("boringcrypto: invalid code execution")
|
panic("boringcrypto: invalid code execution")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue