diff options
author | Daniel Martí <mvdan@mvdan.cc> | 2017-09-13 15:04:16 +0200 |
---|---|---|
committer | Daniel Martí <mvdan@mvdan.cc> | 2017-09-13 18:10:31 +0000 |
commit | 0d8a3b208c7356c08c29df79319149985b0a46b8 (patch) | |
tree | 43d774dc22da557b3b860806c4eb253aeebe63ed /src/runtime/runtime_test.go | |
parent | d02477e994b443ef45851e266381800ea5031859 (diff) | |
download | go-0d8a3b208c7356c08c29df79319149985b0a46b8.tar.gz go-0d8a3b208c7356c08c29df79319149985b0a46b8.zip |
cmd/compile: add TestIntendedInlining from runtime
Move it from the runtime package, as we will soon add more packages and
functions for it to check.
The test used the testEnv func, which cleaned certain environment
variables from a command, so it was moved to internal/testenv under a
more descriptive (and less ambiguous) name. Add a simple godoc to it
too.
For #21851.
Change-Id: I6f39c1f23b45377718355fafe66ffd87047d8ab6
Reviewed-on: https://go-review.googlesource.com/63550
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Diffstat (limited to 'src/runtime/runtime_test.go')
-rw-r--r-- | src/runtime/runtime_test.go | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/runtime/runtime_test.go b/src/runtime/runtime_test.go index 752cd21c92..922cd830bc 100644 --- a/src/runtime/runtime_test.go +++ b/src/runtime/runtime_test.go @@ -5,10 +5,7 @@ package runtime_test import ( - "bytes" - "internal/testenv" "io" - "os/exec" . "runtime" "runtime/debug" "strings" @@ -357,42 +354,3 @@ func TestVersion(t *testing.T) { t.Fatalf("cr/nl in version: %q", vers) } } - -// TestIntendedInlining tests that specific runtime functions are inlined. -// This allows refactoring for code clarity and re-use without fear that -// changes to the compiler will cause silent performance regressions. -func TestIntendedInlining(t *testing.T) { - if testing.Short() && testenv.Builder() == "" { - t.Skip("skipping in short mode") - } - testenv.MustHaveGoRun(t) - t.Parallel() - - // want is the list of function names that should be inlined. - want := []string{"tophash", "add", "(*bmap).keys", "bucketShift", "bucketMask"} - - m := make(map[string]bool, len(want)) - for _, s := range want { - m[s] = true - } - - cmd := testEnv(exec.Command(testenv.GoToolPath(t), "build", "-a", "-gcflags=-m", "runtime")) - out, err := cmd.CombinedOutput() - if err != nil { - t.Logf("%s", out) - t.Fatal(err) - } - lines := bytes.Split(out, []byte{'\n'}) - for _, x := range lines { - f := bytes.Split(x, []byte(": can inline ")) - if len(f) < 2 { - continue - } - fn := bytes.TrimSpace(f[1]) - delete(m, string(fn)) - } - - for s := range m { - t.Errorf("function %s not inlined", s) - } -} |