Commit 9b544442 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder Committed by Russ Cox

test: move linkx and sinit to run.go

The remaining run-only tests will be migrated to run.go in another CL.

This CL will break the build due to issues 8746 and 8806.

Update #4139
Update #8746
Update #8806

LGTM=rsc
R=rsc, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/144630044
parent 5b110c7b
// $G $D/$F.go && $L -X main.tbd hello -X main.overwrite trumped -X main.nosuchsymbol neverseen $F.$A && ./$A.out // skip
// NOTE: This test is not run by 'run.go' and so not run by all.bash.
// To run this test you must use the ./run shell script.
// Copyright 2012 The Go Authors. All rights reserved. // Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Test the -X facility of the gc linker (6l etc.). // Test the -X facility of the gc linker (6l etc.).
// This test is run by linkx_run.go.
package main package main
...@@ -15,10 +13,6 @@ var tbd string ...@@ -15,10 +13,6 @@ var tbd string
var overwrite string = "dibs" var overwrite string = "dibs"
func main() { func main() {
if tbd != "hello" { println(tbd)
println("BUG: test/linkx tbd", len(tbd), tbd) println(overwrite)
}
if overwrite != "trumped" {
println("BUG: test/linkx overwrite", len(overwrite), overwrite)
}
} }
// run
// Copyright 2014 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.
// Run the linkx test.
package main
import (
"fmt"
"os"
"os/exec"
)
func main() {
cmd := exec.Command("go", "run", "-ldflags=-X main.tbd hello -X main.overwrite trumped", "linkx.go")
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(string(out))
fmt.Println(err)
os.Exit(1)
}
want := "hello\ntrumped\n"
got := string(out)
if got != want {
fmt.Printf("got %q want %q\n", got, want)
os.Exit(1)
}
}
...@@ -907,8 +907,6 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) { ...@@ -907,8 +907,6 @@ func (t *test) wantedErrors(file, short string) (errs []wantedError) {
} }
var skipOkay = map[string]bool{ var skipOkay = map[string]bool{
"linkx.go": true, // like "run" but wants linker flags
"sinit.go": true,
"fixedbugs/bug248.go": true, // combines errorcheckdir and rundir in the same dir. "fixedbugs/bug248.go": true, // combines errorcheckdir and rundir in the same dir.
"fixedbugs/bug302.go": true, // tests both .$O and .a imports. "fixedbugs/bug302.go": true, // tests both .$O and .a imports.
"fixedbugs/bug345.go": true, // needs the appropriate flags in gc invocation. "fixedbugs/bug345.go": true, // needs the appropriate flags in gc invocation.
......
// $G -S $D/$F.go | egrep initdone >/dev/null && echo BUG sinit || true // skip
// NOTE: This test is not run by 'run.go' and so not run by all.bash.
// To run this test you must use the ./run shell script.
// Copyright 2010 The Go Authors. All rights reserved. // Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
...@@ -9,6 +6,7 @@ ...@@ -9,6 +6,7 @@
// Test that many initializations can be done at link time and // Test that many initializations can be done at link time and
// generate no executable init functions. // generate no executable init functions.
// This test is run by sinit_run.go.
package p package p
...@@ -179,7 +177,7 @@ var sx []int ...@@ -179,7 +177,7 @@ var sx []int
var s0 = []int{0, 0, 0} var s0 = []int{0, 0, 0}
var s1 = []int{1, 2, 3} var s1 = []int{1, 2, 3}
func fi() int func fi() int { return 1 }
var ax [10]int var ax [10]int
var a0 = [10]int{0, 0, 0} var a0 = [10]int{0, 0, 0}
...@@ -281,6 +279,8 @@ type T1 int ...@@ -281,6 +279,8 @@ type T1 int
func (t *T1) M() {} func (t *T1) M() {}
type Mer interface { M() } type Mer interface {
M()
}
var _ Mer = (*T1)(nil) var _ Mer = (*T1)(nil)
// run
// Copyright 2014 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.
// Run the sinit test.
package main
import (
"bytes"
"fmt"
"go/build"
"os"
"os/exec"
)
func main() {
letter, err := build.ArchChar(build.Default.GOARCH)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
cmd := exec.Command("go", "tool", letter+"g", "-S", "sinit.go")
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(string(out))
fmt.Println(err)
os.Exit(1)
}
os.Remove("sinit." + letter)
if bytes.Contains(out, []byte("initdone")) {
fmt.Println("sinit generated an init function")
os.Exit(1)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment