1 // Copyright 2023 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.
5 // This file and importx_test.go make it possible to write tests in the runtime
6 // package, which is generally more convenient for testing runtime internals.
7 // For tests that mostly touch public APIs, it's generally easier to write them
8 // in the runtime_test package and export any runtime internals via
11 // There are a few limitations on runtime package tests that this bridges:
13 // 1. Tests use the signature "XTest<name>(t TestingT)". Since runtime can't import
14 // testing, test functions can't use testing.T, so instead we have the T
15 // interface, which *testing.T satisfies. And we start names with "XTest"
16 // because otherwise go test will complain about Test functions with the wrong
17 // signature. To actually expose these as test functions, this file contains
20 // 2. Runtime package tests can't directly import other std packages, so we
21 // inject any necessary functions from std.
23 // TODO: Generate this
35 runtime.FmtSprintf = fmt.Sprintf
36 runtime.TestenvOptimizationOff = testenv.OptimizationOff
39 func TestInlineUnwinder(t *testing.T) {
40 runtime.XTestInlineUnwinder(t)
43 func TestSPWrite(t *testing.T) {
44 runtime.XTestSPWrite(t)