| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package testutil // import "go.opentelemetry.io/collector/internal/testutil" |
| 5 |
|
| 6 |
import ( |
| 7 |
"os" |
| 8 |
"strings" |
| 9 |
"testing" |
| 10 |
) |
| 11 |
|
| 12 |
// SkipIfFIPSOnly will mark the passed test as skipped if GODEBUG=fips140=only is detected. |
| 13 |
// If GODEBUG=fips140=on, go may call non-compliant algorithms and the test does not need to be skipped. |
| 14 |
func SkipIfFIPSOnly(t *testing.T, msg string) { |
| 15 |
// NOTE: This only checks env var; at the time of writing fips140 can only be set via env |
| 16 |
// other GODEBUG settings can be set via embedded comments or in go.mod, we may need to account for this in the future. |
| 17 |
s := os.Getenv("GODEBUG") |
| 18 |
if strings.Contains(s, "fips140=only") { |
| 19 |
t.Skip("GODEBUG=fips140=only detected, skipping test:", msg) |
| 20 |
} |
| 21 |
} |