diff options
Diffstat (limited to 'test')
33 files changed, 609 insertions, 32 deletions
diff --git a/test/chan/select6.go b/test/chan/select6.go new file mode 100644 index 000000000..2ba6810ac --- /dev/null +++ b/test/chan/select6.go @@ -0,0 +1,34 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2011 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. + +// Issue 2075 +// A bug in select corrupts channel queues of failed cases +// if there are multiple waiters on those channels and the +// select is the last in the queue. If further waits are made +// on the channel without draining it first then those waiters +// will never wake up. In the code below c1 is such a channel. + +package main + +func main() { + c1 := make(chan bool) + c2 := make(chan bool) + c3 := make(chan bool) + go func() { <-c1 }() + go func() { + select { + case <-c1: + panic("dummy") + case <-c2: + c3 <- true + } + <-c1 + }() + go func() { c2 <- true }() + <-c3 + c1 <- true + c1 <- true +} diff --git a/test/chan/zerosize.go b/test/chan/zerosize.go new file mode 100644 index 000000000..617c9dab3 --- /dev/null +++ b/test/chan/zerosize.go @@ -0,0 +1,16 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2011 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. + +// Making channels of a zero-sized type should not panic. + +package main + +func main() { + _ = make(chan [0]byte) + _ = make(chan [0]byte, 1) + _ = make(chan struct{}) + _ = make(chan struct{}, 1) +} diff --git a/test/ddd1.go b/test/ddd1.go index 96a358e1c..83e32de7b 100644 --- a/test/ddd1.go +++ b/test/ddd1.go @@ -44,4 +44,6 @@ func bad(args ...int) { _ = unsafe.Pointer(&x...) // ERROR "[.][.][.]" _ = unsafe.Sizeof(x...) // ERROR "[.][.][.]" _ = [...]byte("foo") // ERROR "[.][.][.]" + _ = [...][...]int{{1,2,3},{4,5,6}} // ERROR "[.][.][.]" } + diff --git a/test/divide.go b/test/divide.go new file mode 100644 index 000000000..5c0f45059 --- /dev/null +++ b/test/divide.go @@ -0,0 +1,54 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2011 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. + +// divide corner cases + +package main + +import "fmt" + +func f8(x, y, q, r int8) { + if t := x / y; t != q { + fmt.Printf("%d/%d = %d, want %d\n", x, y, t, q) + } + if t := x % y; t != r { + fmt.Printf("%d%%%d = %d, want %d\n", x, y, t, r) + } +} + +func f16(x, y, q, r int16) { + if t := x / y; t != q { + fmt.Printf("%d/%d = %d, want %d\n", x, y, t, q) + } + if t := x % y; t != r { + fmt.Printf("%d%%%d = %d, want %d\n", x, y, t, r) + } +} + +func f32(x, y, q, r int32) { + if t := x / y; t != q { + fmt.Printf("%d/%d = %d, want %d\n", x, y, t, q) + } + if t := x % y; t != r { + fmt.Printf("%d%%%d = %d, want %d\n", x, y, t, r) + } +} + +func f64(x, y, q, r int64) { + if t := x / y; t != q { + fmt.Printf("%d/%d = %d, want %d\n", x, y, t, q) + } + if t := x % y; t != r { + fmt.Printf("%d%%%d = %d, want %d\n", x, y, t, r) + } +} + +func main() { + f8(-1<<7, -1, -1<<7, 0) + f16(-1<<15, -1, -1<<15, 0) + f32(-1<<31, -1, -1<<31, 0) + f64(-1<<63, -1, -1<<63, 0) +} diff --git a/test/fixedbugs/bug273.go b/test/fixedbugs/bug273.go index 816f69e8f..dd5aaa7b8 100644 --- a/test/fixedbugs/bug273.go +++ b/test/fixedbugs/bug273.go @@ -47,15 +47,6 @@ func bigcap() { g1 = make([]int, 10, big) } -const ( - addrBits = 8*uint(unsafe.Sizeof((*byte)(nil))) - sh = addrBits/2 - 2 -) -var g2 [][1<<sh][1<<sh]byte -func overflow() { - g2 = make([][1<<sh][1<<sh]byte, 64) -} - var g3 map[int]int func badmapcap() { g3 = make(map[int]int, minus1) @@ -74,6 +65,8 @@ func bigchancap() { g4 = make(chan int, big) } +const addrBits = unsafe.Sizeof((*byte)(nil)) + var g5 chan [1<<15]byte func overflowchan() { if addrBits == 32 { @@ -92,7 +85,6 @@ func main() { shouldfail(badcap, "badcap") shouldfail(badcap1, "badcap1") shouldfail(bigcap, "bigcap") - shouldfail(overflow, "overflow") shouldfail(badmapcap, "badmapcap") shouldfail(bigmapcap, "bigmapcap") shouldfail(badchancap, "badchancap") diff --git a/test/fixedbugs/bug274.go b/test/fixedbugs/bug274.go index 81ee9e5b8..198544c3f 100644 --- a/test/fixedbugs/bug274.go +++ b/test/fixedbugs/bug274.go @@ -25,6 +25,7 @@ func main() { L1: // ERROR "statement" default: // correct since no semicolon is required before a '}' - L2: // ERROR "not used" + goto L2 + L2: } } diff --git a/test/fixedbugs/bug298.go b/test/fixedbugs/bug298.go index fe4a99a78..c16c3f98a 100644 --- a/test/fixedbugs/bug298.go +++ b/test/fixedbugs/bug298.go @@ -7,5 +7,5 @@ package ddd func Sum() int - for i := range []int{} { return i } // ERROR "return outside function|expected" + for i := range []int{} { return i } // ERROR "statement outside function|expected" diff --git a/test/fixedbugs/bug346.go b/test/fixedbugs/bug346.go new file mode 100644 index 000000000..31284c31a --- /dev/null +++ b/test/fixedbugs/bug346.go @@ -0,0 +1,19 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: issue2056 + +// Copyright 2011 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 main + +import "os" + +func main() { + x := 4 + a, b, c, d := func(i int) (p int, q int, r int, s int) { return 1, i, 3, x }(2) + + if a != 1 || b != 2 || c != 3 || d != 4 { + println("abcd: expected 1 2 3 4 got", a, b, c, d) + os.Exit(1) + } +} diff --git a/test/fixedbugs/bug347.go b/test/fixedbugs/bug347.go new file mode 100644 index 000000000..5532cee83 --- /dev/null +++ b/test/fixedbugs/bug347.go @@ -0,0 +1,49 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2011 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 main + +import ( + "runtime" + "strings" +) + +var t *struct { + c chan int +} + +var c chan int + +func f() { + select { + case <-t.c: // THIS IS LINE 22 + break + case <-c: + break + } +} + +func main() { + defer func() { + recover() + for i := 0;; i++ { + pc, file, line, ok := runtime.Caller(i) + if !ok { + print("BUG: bug347: cannot find caller\n") + return + } + if !strings.Contains(file, "bug347.go") || runtime.FuncForPC(pc).Name() != "main.f" { + // walk past runtime frames + continue + } + if line != 22 { + print("BUG: bug347: panic at ", file, ":", line, " in ", runtime.FuncForPC(pc).Name(), "\n") + } + return + } + }() + f() +} diff --git a/test/fixedbugs/bug348.go b/test/fixedbugs/bug348.go new file mode 100644 index 000000000..1a539aa3e --- /dev/null +++ b/test/fixedbugs/bug348.go @@ -0,0 +1,46 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2011 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 main + +import ( + "runtime" + "strings" +) + +func f() { + var x *string + + for _, i := range *x { // THIS IS LINE 17 + println(i) + } +} + +func g() { +} + +func main() { + defer func() { + for i := 0;; i++ { + pc, file, line, ok := runtime.Caller(i) + if !ok { + print("BUG: bug348: cannot find caller\n") + return + } + if !strings.Contains(file, "bug348.go") || runtime.FuncForPC(pc).Name() != "main.f" { + // walk past runtime frames + continue + } + if line != 17 { + print("BUG: bug348: panic at ", file, ":", line, " in ", runtime.FuncForPC(pc).Name(), "\n") + return + } + recover() + return + } + }() + f() +} diff --git a/test/fixedbugs/bug349.go b/test/fixedbugs/bug349.go new file mode 100644 index 000000000..07005973e --- /dev/null +++ b/test/fixedbugs/bug349.go @@ -0,0 +1,13 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// issue 1192 - detail in error + +package main + +func foo() (a, b, c int) { + return 0, 1 2.01 // ERROR "unexpected literal 2.01" +} diff --git a/test/fixedbugs/bug350.go b/test/fixedbugs/bug350.go new file mode 100644 index 000000000..aac294901 --- /dev/null +++ b/test/fixedbugs/bug350.go @@ -0,0 +1,15 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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 main + +type T int + +func (T) m() {} +func (T) m() {} // ERROR "T[.]m redeclared" + +func (*T) p() {} +func (*T) p() {} // ERROR "[(][*]T[)][.]p redeclared" diff --git a/test/fixedbugs/bug351.go b/test/fixedbugs/bug351.go new file mode 100644 index 000000000..c33e28271 --- /dev/null +++ b/test/fixedbugs/bug351.go @@ -0,0 +1,11 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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 main + +func main() { + (x) := 0 // ERROR "non-name [(]x[)]" +} diff --git a/test/fixedbugs/bug352.go b/test/fixedbugs/bug352.go new file mode 100644 index 000000000..62fd006c4 --- /dev/null +++ b/test/fixedbugs/bug352.go @@ -0,0 +1,19 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug352 + +// Copyright 2011 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 main + +var x [10][0]byte +var y = make([]struct{}, 10) + +func main() { + if &x[1] != &x[2] { + println("BUG: bug352 [0]byte") + } + if &y[1] != &y[2] { + println("BUG: bug352 struct{}") + } +} diff --git a/test/fixedbugs/bug353.go b/test/fixedbugs/bug353.go new file mode 100644 index 000000000..46f5c36cb --- /dev/null +++ b/test/fixedbugs/bug353.go @@ -0,0 +1,30 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// issue 2089 - internal compiler error + +package main + +import ( + "io" + "os" +) + +func echo(fd io.ReadWriterCloser) { // ERROR "undefined: io.ReadWriterCloser" + var buf [1024]byte + for { + n, err := fd.Read(buf) + if err != nil { + break + } + fd.Write(buf[0:n]) + } +} + +func main() { + fd, _ := os.Open("a.txt") + echo(fd) +} diff --git a/test/fixedbugs/bug354.go b/test/fixedbugs/bug354.go new file mode 100644 index 000000000..1f6a6dc9f --- /dev/null +++ b/test/fixedbugs/bug354.go @@ -0,0 +1,26 @@ +// $G $D/$F.go || echo BUG: bug354 + +// Copyright 2011 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. + +// issue 2086 +// was calling makeclosure twice on the closure + +package main + +import ( + "os" +) + +type Inner struct { + F func() os.Error +} + +type Outer struct { + Inners []Inner +} + +// calls makeclosure twice on same closure + +var Foo = Outer{[]Inner{Inner{func() os.Error{ return nil }}}} diff --git a/test/fixedbugs/bug355.go b/test/fixedbugs/bug355.go new file mode 100644 index 000000000..a9cf0161b --- /dev/null +++ b/test/fixedbugs/bug355.go @@ -0,0 +1,18 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2011 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 main + +var f = func() int { + type S int + return 42 +} + +func main() { + if f() != 42 { + panic("BUG: bug355") + } +} diff --git a/test/fixedbugs/bug356.go b/test/fixedbugs/bug356.go new file mode 100644 index 000000000..d21f0cfac --- /dev/null +++ b/test/fixedbugs/bug356.go @@ -0,0 +1,41 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug344 + +// Copyright 2011 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. + +// issue 1808 + +package main + +func main() { + var i uint64 + var x int = 12345 + + if y := x << (i&5); y != 12345<<0 { + println("BUG bug344", y) + return + } + + i++ + if y := x << (i&5); y != 12345<<1 { + println("BUG bug344a", y) + } + + i = 70 + if y := x << i; y != 0 { + println("BUG bug344b", y) + } + + i = 1<<32 + if y := x << i; y != 0 { + println("BUG bug344c", y) + } +} + + +/* +typecheck [1008592b0] +. INDREG a(1) l(15) x(24) tc(2) runtime.ret G0 string +bug343.go:15: internal compiler error: typecheck INDREG +*/ diff --git a/test/fixedbugs/bug357.go b/test/fixedbugs/bug357.go new file mode 100644 index 000000000..2220398d0 --- /dev/null +++ b/test/fixedbugs/bug357.go @@ -0,0 +1,25 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// issue 1993. +// error used to have last line number in file + +package main + +func bla1() bool { + return false +} + +func bla5() bool { + _ = 1 + false // ERROR "false not used" + _ = 2 +} + +func main() { + x := bla1() + _ = x +} diff --git a/test/fixedbugs/bug358.go b/test/fixedbugs/bug358.go new file mode 100644 index 000000000..cc622c047 --- /dev/null +++ b/test/fixedbugs/bug358.go @@ -0,0 +1,26 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// issue 1979 +// used to get internal compiler error too + +package main + +import ( + "http" + "io/ioutil" + "os" +) + +func makeHandler(fn func(http.ResponseWriter, *http.Request, string)) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) // ERROR "syntax error" +} + +type Page struct { + Title string + Body []byte +} + diff --git a/test/fixedbugs/bug359.go b/test/fixedbugs/bug359.go new file mode 100644 index 000000000..6ced608bc --- /dev/null +++ b/test/fixedbugs/bug359.go @@ -0,0 +1,26 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// issue 1910 +// error on wrong line + +package main + +import "container/list" + +type Painting struct { + fragments list.List // private +} + +func (p Painting) Foo() { + for e := p.fragments; e.Front() != nil; e = e.Next() { // ERROR "unexported field" + } +} + +// from comment 4 of issue 1910 +type Foo interface { + Run(a int) (a int) // ERROR "a redeclared" +} diff --git a/test/fixedbugs/bug361.go b/test/fixedbugs/bug361.go new file mode 100644 index 000000000..d2a64bcef --- /dev/null +++ b/test/fixedbugs/bug361.go @@ -0,0 +1,15 @@ +// $G $D/$F.go || echo BUG: bug360 + +// Copyright 2011 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. + +// issue 1908 +// unreasonable width used to be internal fatal error + +package test + +func main() { + buf := [1<<30]byte{} + _ = buf[:] +} diff --git a/test/fixedbugs/bug362.go b/test/fixedbugs/bug362.go new file mode 100644 index 000000000..791209103 --- /dev/null +++ b/test/fixedbugs/bug362.go @@ -0,0 +1,16 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// issue 1662 +// iota inside var + +package main + +var ( + a = iota // ERROR "undefined: iota" + b = iota // ERROR "undefined: iota" + c = iota // ERROR "undefined: iota" +) diff --git a/test/fixedbugs/bug363.go b/test/fixedbugs/bug363.go new file mode 100644 index 000000000..7e89749a0 --- /dev/null +++ b/test/fixedbugs/bug363.go @@ -0,0 +1,21 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// issue 1664 + +package main + +func main() { + var i uint = 33 + var a = (1<<i) + 4.5 // ERROR "shift of type float64" + println(a) + + var b = (1<<i) + 4.0 // ERROR "shift of type float64" + println(b) + + var c int64 = (1<<i) + 4.0 // ok - it's all int64 + println(b) +} diff --git a/test/fixedbugs/bug364.go b/test/fixedbugs/bug364.go new file mode 100644 index 000000000..a17453419 --- /dev/null +++ b/test/fixedbugs/bug364.go @@ -0,0 +1,25 @@ +package main + +import "fmt" + +var s string + +func accum(args ...interface{}) { + s += fmt.Sprintln(args...) +} + +func f(){ + v := 0.0 + for i := 0; i < 3; i++ { + v += 0.1 + defer accum(v) + } +} + +func main() { + f() + if s != "0.30000000000000004\n0.2\n0.1\n" { + println("BUG: defer") + print(s) + } +} diff --git a/test/fixedbugs/bug365.go b/test/fixedbugs/bug365.go new file mode 100644 index 000000000..7ec19b0c8 --- /dev/null +++ b/test/fixedbugs/bug365.go @@ -0,0 +1,22 @@ +// errchk $G $D/$F.go + +// Copyright 2011 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. + +// check that compiler doesn't stop reading struct def +// after first unknown type. + +// Fixes issue 2110. + +package main + +type S struct { + err os.Error // ERROR "undefined" + Num int +} + +func main() { + s := S{} + _ = s.Num // no error here please +} diff --git a/test/gc2.go b/test/gc2.go index c5c6cbe4b..c54d807df 100644 --- a/test/gc2.go +++ b/test/gc2.go @@ -32,7 +32,8 @@ func main() { } } } - + + runtime.UpdateMemStats() obj := runtime.MemStats.HeapObjects - st.HeapObjects if obj > N/5 { fmt.Println("too many objects left:", obj) diff --git a/test/if.go b/test/if.go index c1bb69d27..18a6715d7 100644 --- a/test/if.go +++ b/test/if.go @@ -53,25 +53,28 @@ func main() { count = 0 if true { count = count + 1 - } else + } else { count = count - 1 + } assertequal(count, 1, "if else true") count = 0 if false { count = count + 1 - } else + } else { count = count - 1 + } assertequal(count, -1, "if else false") count = 0 - if t:=1; false { + if t := 1; false { count = count + 1 _ = t t := 7 _ = t - } else + } else { count = count - t + } assertequal(count, -1, "if else false var") count = 0 @@ -80,8 +83,9 @@ func main() { count = count + 1 t := 7 _ = t - } else + } else { count = count - t + } _ = t assertequal(count, -1, "if else false var outside") } diff --git a/test/malloc1.go b/test/malloc1.go index 146976467..61f1797c7 100644 --- a/test/malloc1.go +++ b/test/malloc1.go @@ -18,6 +18,7 @@ var chatty = flag.Bool("v", false, "chatty") func main() { runtime.Free(runtime.Alloc(1)) + runtime.UpdateMemStats() if *chatty { fmt.Printf("%+v %v\n", runtime.MemStats, uint64(0)) } diff --git a/test/mallocrand.go b/test/mallocrand.go index e6b422e22..f014b441b 100644 --- a/test/mallocrand.go +++ b/test/mallocrand.go @@ -21,6 +21,7 @@ var footprint uint64 var allocated uint64 func bigger() { + runtime.UpdateMemStats() if f := runtime.MemStats.Sys; footprint < f { footprint = f if *chatty { diff --git a/test/mallocrep.go b/test/mallocrep.go index 762f3754f..9f47e52e2 100644 --- a/test/mallocrep.go +++ b/test/mallocrep.go @@ -18,6 +18,7 @@ var chatty = flag.Bool("v", false, "chatty") var oldsys uint64 func bigger() { + runtime.UpdateMemStats() if st := runtime.MemStats; oldsys < st.Sys { oldsys = st.Sys if *chatty { @@ -31,7 +32,7 @@ func bigger() { } func main() { - runtime.GC() // clean up garbage from init + runtime.GC() // clean up garbage from init runtime.MemProfileRate = 0 // disable profiler runtime.MemStats.Alloc = 0 // ignore stacks flag.Parse() @@ -45,8 +46,10 @@ func main() { panic("fail") } b := runtime.Alloc(uintptr(j)) + runtime.UpdateMemStats() during := runtime.MemStats.Alloc runtime.Free(b) + runtime.UpdateMemStats() if a := runtime.MemStats.Alloc; a != 0 { println("allocated ", j, ": wrong stats: during=", during, " after=", a, " (want 0)") panic("fail") diff --git a/test/mallocrep1.go b/test/mallocrep1.go index eb67bed86..0b1479900 100644 --- a/test/mallocrep1.go +++ b/test/mallocrep1.go @@ -42,6 +42,7 @@ func AllocAndFree(size, count int) { if *chatty { fmt.Printf("size=%d count=%d ...\n", size, count) } + runtime.UpdateMemStats() n1 := stats.Alloc for i := 0; i < count; i++ { b[i] = runtime.Alloc(uintptr(size)) @@ -50,11 +51,13 @@ func AllocAndFree(size, count int) { println("lookup failed: got", base, n, "for", b[i]) panic("fail") } - if runtime.MemStats.Sys > 1e9 { + runtime.UpdateMemStats() + if stats.Sys > 1e9 { println("too much memory allocated") panic("fail") } } + runtime.UpdateMemStats() n2 := stats.Alloc if *chatty { fmt.Printf("size=%d count=%d stats=%+v\n", size, count, *stats) @@ -72,6 +75,7 @@ func AllocAndFree(size, count int) { panic("fail") } runtime.Free(b[i]) + runtime.UpdateMemStats() if stats.Alloc != uint64(alloc-n) { println("free alloc got", stats.Alloc, "expected", alloc-n, "after free of", n) panic("fail") @@ -81,6 +85,7 @@ func AllocAndFree(size, count int) { panic("fail") } } + runtime.UpdateMemStats() n4 := stats.Alloc if *chatty { @@ -33,9 +33,9 @@ failed=0 PATH=/bin:/usr/bin:/usr/local/bin:${GOBIN:-$GOROOT/bin}:`pwd` -RUNFILE=/tmp/gorun-$$-$USER -TMP1FILE=/tmp/gotest1-$$-$USER -TMP2FILE=/tmp/gotest2-$$-$USER +RUNFILE="/tmp/gorun-$$-$USER" +TMP1FILE="/tmp/gotest1-$$-$USER" +TMP2FILE="/tmp/gotest2-$$-$USER" # don't run the machine out of memory: limit individual processes to 4GB. # on thresher, 3GB suffices to run the tests; with 2GB, peano fails. @@ -64,20 +64,20 @@ do fi export F=$(basename $i .go) export D=$dir - sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|g' >$RUNFILE - if ! { time -p bash -c "bash $RUNFILE >$TMP1FILE 2>&1" ; } 2>$TMP2FILE + sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|g' >"$RUNFILE" + if ! { time -p bash -c "bash '$RUNFILE' >'$TMP1FILE' 2>&1" ; } 2>"$TMP2FILE" then echo echo "===========" $i - cat $TMP1FILE + cat "$TMP1FILE" echo >&2 fail: $i echo "# $i # fail" >>pass.out - elif test -s $TMP1FILE + elif test -s "$TMP1FILE" then echo echo "===========" $i - cat $TMP1FILE - if grep -q '^BUG' $TMP1FILE + cat "$TMP1FILE" + if grep -q '^BUG' "$TMP1FILE" then if [ $dir != bugs ] then @@ -93,13 +93,13 @@ do else echo $i >>pass.out fi - echo $(awk 'NR==1{print $2}' $TMP2FILE) $D/$F >>times.out + echo $(awk 'NR==1{print $2}' "$TMP2FILE") $D/$F >>times.out rm -f $F.$A $A.out ) done done | # clean up some stack noise egrep -v '^(r[0-9a-z]+|[cfg]s) +0x' | sed '/tmp.*Bus error/s/.*Bus/Bus/; /tmp.*Trace.BPT/s/.*Trace/Trace/ - s!'$RUNFILE'!$RUNFILE!g + s!'"$RUNFILE"'!$RUNFILE!g s/^PC=0x[0-9a-f]*/pc: xxx/ s/^pc: 0x[0-9a-f]*/pc: xxx/ s/PC=0x[0-9a-f]*/PC=xxx/ @@ -110,7 +110,7 @@ done | # clean up some stack noise /Segmentation fault/d /^qemu: uncaught target signal 11 (Segmentation fault) - exiting/d' > run.out -rm -f $RUNFILE $TMP1FILE $TMP2FILE *.$A *.a $A.out +rm -f "$RUNFILE" "$TMP1FILE" "$TMP2FILE" *.$A *.a $A.out diffmsg="" if ! diff $golden run.out then |
