From 93f95a30a3c20774bca22e77ebbb5c1f3a8ce008 Mon Sep 17 00:00:00 2001 From: Alberto Donizetti Date: Fri, 13 Apr 2018 12:19:20 +0200 Subject: [PATCH] cmd/compile: move Issue 16214 test, delete asm_test file Move the Issue16214 test in the fixedbugs_test.go file, and delete the now empty asm_test.go file. Change-Id: I2a0c72bd36f0359b7baf75b5d1ba647cc84feb46 Reviewed-on: https://go-review.googlesource.com/106836 Run-TryBot: Alberto Donizetti TryBot-Result: Gobot Gobot Reviewed-by: Giovanni Bajo --- src/cmd/compile/internal/gc/asm_test.go | 50 ------------------- src/cmd/compile/internal/gc/fixedbugs_test.go | 44 +++++++++++++++- 2 files changed, 43 insertions(+), 51 deletions(-) delete mode 100644 src/cmd/compile/internal/gc/asm_test.go diff --git a/src/cmd/compile/internal/gc/asm_test.go b/src/cmd/compile/internal/gc/asm_test.go deleted file mode 100644 index 92d0d83555..0000000000 --- a/src/cmd/compile/internal/gc/asm_test.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gc - -import ( - "internal/testenv" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "strings" - "testing" -) - -// TestLineNumber checks to make sure the generated assembly has line numbers -// see issue #16214 -func TestLineNumber(t *testing.T) { - testenv.MustHaveGoBuild(t) - dir, err := ioutil.TempDir("", "TestLineNumber") - if err != nil { - t.Fatalf("could not create directory: %v", err) - } - defer os.RemoveAll(dir) - - src := filepath.Join(dir, "x.go") - err = ioutil.WriteFile(src, []byte(issue16214src), 0644) - if err != nil { - t.Fatalf("could not write file: %v", err) - } - - cmd := exec.Command(testenv.GoToolPath(t), "tool", "compile", "-S", "-o", filepath.Join(dir, "out.o"), src) - out, err := cmd.CombinedOutput() - if err != nil { - t.Fatalf("fail to run go tool compile: %v", err) - } - - if strings.Contains(string(out), "unknown line number") { - t.Errorf("line number missing in assembly:\n%s", out) - } -} - -var issue16214src = ` -package main - -func Mod32(x uint32) uint32 { - return x % 3 // frontend rewrites it as HMUL with 2863311531, the LITERAL node has unknown Pos -} -` diff --git a/src/cmd/compile/internal/gc/fixedbugs_test.go b/src/cmd/compile/internal/gc/fixedbugs_test.go index 095b816a53..8ac4436947 100644 --- a/src/cmd/compile/internal/gc/fixedbugs_test.go +++ b/src/cmd/compile/internal/gc/fixedbugs_test.go @@ -4,7 +4,15 @@ package gc -import "testing" +import ( + "internal/testenv" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "strings" + "testing" +) type T struct { x [2]int64 // field that will be clobbered. Also makes type not SSAable. @@ -48,3 +56,37 @@ func TestIssue15854b(t *testing.T) { } } } + +// Test that the generated assembly has line numbers (Issue #16214). +func TestIssue16214(t *testing.T) { + testenv.MustHaveGoBuild(t) + dir, err := ioutil.TempDir("", "TestLineNumber") + if err != nil { + t.Fatalf("could not create directory: %v", err) + } + defer os.RemoveAll(dir) + + src := filepath.Join(dir, "x.go") + err = ioutil.WriteFile(src, []byte(issue16214src), 0644) + if err != nil { + t.Fatalf("could not write file: %v", err) + } + + cmd := exec.Command(testenv.GoToolPath(t), "tool", "compile", "-S", "-o", filepath.Join(dir, "out.o"), src) + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("fail to run go tool compile: %v", err) + } + + if strings.Contains(string(out), "unknown line number") { + t.Errorf("line number missing in assembly:\n%s", out) + } +} + +var issue16214src = ` +package main + +func Mod32(x uint32) uint32 { + return x % 3 // frontend rewrites it as HMUL with 2863311531, the LITERAL node has unknown Pos +} +` -- 2.48.1