]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/errors: port test.bash to Go
authorBryan C. Mills <bcmills@google.com>
Tue, 12 Sep 2017 22:28:02 +0000 (18:28 -0400)
committerBryan Mills <bcmills@google.com>
Wed, 13 Sep 2017 17:45:52 +0000 (17:45 +0000)
This makes the test easier to run in isolation and easier to change,
and simplifies the code to run the tests in parallel.

updates #13467

Change-Id: I5622b5cc98276970347da18e95d071dbca3c5cc1
Reviewed-on: https://go-review.googlesource.com/63276
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
24 files changed:
misc/cgo/errors/errors_test.go [new file with mode: 0644]
misc/cgo/errors/issue13635.go [deleted file]
misc/cgo/errors/ptr_test.go [moved from misc/cgo/errors/ptr.go with 79% similarity]
misc/cgo/errors/src/err1.go [moved from misc/cgo/errors/err1.go with 100% similarity]
misc/cgo/errors/src/err2.go [moved from misc/cgo/errors/err2.go with 100% similarity]
misc/cgo/errors/src/err3.go [moved from misc/cgo/errors/err3.go with 100% similarity]
misc/cgo/errors/src/err4.go [moved from misc/cgo/errors/err4.go with 100% similarity]
misc/cgo/errors/src/issue11097a.go [moved from misc/cgo/errors/issue11097a.go with 100% similarity]
misc/cgo/errors/src/issue11097b.go [moved from misc/cgo/errors/issue11097b.go with 100% similarity]
misc/cgo/errors/src/issue13129.go [moved from misc/cgo/errors/issue13129.go with 88% similarity]
misc/cgo/errors/src/issue13423.go [moved from misc/cgo/errors/issue13423.go with 100% similarity]
misc/cgo/errors/src/issue13635.go [new file with mode: 0644]
misc/cgo/errors/src/issue13830.go [moved from misc/cgo/errors/issue13830.go with 100% similarity]
misc/cgo/errors/src/issue14669.go [moved from misc/cgo/errors/issue14669.go with 100% similarity]
misc/cgo/errors/src/issue16116.go [moved from misc/cgo/errors/issue16116.go with 100% similarity]
misc/cgo/errors/src/issue16591.go [moved from misc/cgo/errors/issue16591.go with 100% similarity]
misc/cgo/errors/src/issue18452.go [moved from misc/cgo/errors/issue18452.go with 75% similarity]
misc/cgo/errors/src/issue18889.go [moved from misc/cgo/errors/issue18889.go with 100% similarity]
misc/cgo/errors/src/issue7757.go [moved from misc/cgo/errors/issue7757.go with 100% similarity]
misc/cgo/errors/src/issue8442.go [moved from misc/cgo/errors/issue8442.go with 100% similarity]
misc/cgo/errors/src/long_double_size.go [new file with mode: 0644]
misc/cgo/errors/src/malloc.go [moved from misc/cgo/errors/malloc.go with 100% similarity]
misc/cgo/errors/test.bash [deleted file]
src/cmd/dist/test.go

diff --git a/misc/cgo/errors/errors_test.go b/misc/cgo/errors/errors_test.go
new file mode 100644 (file)
index 0000000..2924993
--- /dev/null
@@ -0,0 +1,151 @@
+// Copyright 2017 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 errorstest
+
+import (
+       "bytes"
+       "fmt"
+       "io/ioutil"
+       "os"
+       "os/exec"
+       "path/filepath"
+       "regexp"
+       "strconv"
+       "strings"
+       "testing"
+)
+
+func path(file string) string {
+       return filepath.Join("src", file)
+}
+
+func check(t *testing.T, file string) {
+       t.Run(file, func(t *testing.T) {
+               t.Parallel()
+
+               contents, err := ioutil.ReadFile(path(file))
+               if err != nil {
+                       t.Fatal(err)
+               }
+               var errors []*regexp.Regexp
+               for i, line := range bytes.Split(contents, []byte("\n")) {
+                       if !bytes.Contains(line, []byte("ERROR HERE")) {
+                               continue
+                       }
+                       var re *regexp.Regexp
+                       frags := bytes.SplitAfterN(line, []byte("ERROR HERE: "), 1)
+                       if len(frags) == 1 {
+                               re = regexp.MustCompile(regexp.QuoteMeta(fmt.Sprintf("%s:%d:", file, i+1)))
+                       } else {
+                               re, err = regexp.Compile(string(frags[1]))
+                               if err != nil {
+                                       t.Errorf("Invalid regexp after `ERROR HERE: `: %q", frags[1])
+                                       continue
+                               }
+                       }
+                       errors = append(errors, re)
+               }
+               if len(errors) == 0 {
+                       t.Fatalf("cannot find ERROR HERE")
+               }
+               expect(t, file, errors)
+       })
+}
+
+func expect(t *testing.T, file string, errors []*regexp.Regexp) {
+       cmd := exec.Command("go", "build", "-gcflags=-C", path(file))
+       out, err := cmd.CombinedOutput()
+       if err == nil {
+               t.Errorf("expected cgo to fail but it succeeded")
+       }
+
+       lines := bytes.Split(out, []byte("\n"))
+       for _, re := range errors {
+               found := false
+               for _, line := range lines {
+                       if re.Match(line) {
+                               found = true
+                               break
+                       }
+               }
+               if !found {
+                       t.Errorf("expected error output to contain %q", re)
+               }
+       }
+
+       if t.Failed() {
+               t.Logf("actual output:\n%s", out)
+       }
+}
+
+func sizeofLongDouble(t *testing.T) int {
+       cmd := exec.Command("go", "run", path("long_double_size.go"))
+       out, err := cmd.CombinedOutput()
+       if err != nil {
+               t.Fatalf("%#q: %v:\n%s", strings.Join(cmd.Args, " "), err, out)
+       }
+
+       i, err := strconv.Atoi(strings.TrimSpace(string(out)))
+       if err != nil {
+               t.Fatalf("long_double_size.go printed invalid size: %s", out)
+       }
+       return i
+}
+
+func TestReportsTypeErrors(t *testing.T) {
+       for _, file := range []string{
+               "err1.go",
+               "err2.go",
+               "err3.go",
+               "issue7757.go",
+               "issue8442.go",
+               "issue11097a.go",
+               "issue11097b.go",
+               "issue13129.go",
+               "issue13423.go",
+               "issue13635.go",
+               "issue13830.go",
+               "issue16116.go",
+               "issue16591.go",
+               "issue18452.go",
+               "issue18889.go",
+       } {
+               check(t, file)
+       }
+
+       if sizeofLongDouble(t) > 8 {
+               check(t, "err4.go")
+       }
+}
+
+func TestToleratesOptimizationFlag(t *testing.T) {
+       for _, cflags := range []string{
+               "",
+               "-O",
+       } {
+               cflags := cflags
+               t.Run(cflags, func(t *testing.T) {
+                       t.Parallel()
+
+                       cmd := exec.Command("go", "build", path("issue14669.go"))
+                       cmd.Env = append(os.Environ(), "CGO_CFLAGS="+cflags)
+                       out, err := cmd.CombinedOutput()
+                       if err != nil {
+                               t.Errorf("%#q: %v:\n%s", strings.Join(cmd.Args, " "), err, out)
+                       }
+               })
+       }
+}
+
+func TestMallocCrashesOnNil(t *testing.T) {
+       t.Parallel()
+
+       cmd := exec.Command("go", "run", path("malloc.go"))
+       out, err := cmd.CombinedOutput()
+       if err == nil {
+               t.Logf("%#q:\n%s", strings.Join(cmd.Args, " "), out)
+               t.Fatalf("succeeded unexpectedly")
+       }
+}
diff --git a/misc/cgo/errors/issue13635.go b/misc/cgo/errors/issue13635.go
deleted file mode 100644 (file)
index 0ce2b1e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2015 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 13635: used to output error about C.unsignedchar.
-// This test tests all such types.
-
-package pkg
-
-import "C"
-
-func main() {
-       var (
-               _ C.uchar         = "uc"  // ERROR HERE
-               _ C.schar         = "sc"  // ERROR HERE
-               _ C.ushort        = "us"  // ERROR HERE
-               _ C.uint          = "ui"  // ERROR HERE
-               _ C.ulong         = "ul"  // ERROR HERE
-               _ C.longlong      = "ll"  // ERROR HERE
-               _ C.ulonglong     = "ull" // ERROR HERE
-               _ C.complexfloat  = "cf"  // ERROR HERE
-               _ C.complexdouble = "cd"  // ERROR HERE
-       )
-}
similarity index 79%
rename from misc/cgo/errors/ptr.go
rename to misc/cgo/errors/ptr_test.go
index e5f62f8b562fd49093af21d1a1adb3b06ec4b929..d295a5849dbfcd94a4b14f597b86e8391670f754 100644 (file)
@@ -4,20 +4,18 @@
 
 // Tests that cgo detects invalid pointer passing at runtime.
 
-package main
+package errorstest
 
 import (
        "bufio"
        "bytes"
        "fmt"
-       "io"
        "io/ioutil"
        "os"
        "os/exec"
        "path/filepath"
-       "runtime"
        "strings"
-       "sync"
+       "testing"
 )
 
 // ptrTest is the tests without the boilerplate.
@@ -353,219 +351,145 @@ var ptrTests = []ptrTest{
        },
 }
 
-func main() {
-       os.Exit(doTests())
+func TestPointerChecks(t *testing.T) {
+       for _, pt := range ptrTests {
+               pt := pt
+               t.Run(pt.name, func(t *testing.T) {
+                       testOne(t, pt)
+               })
+       }
 }
 
-func doTests() int {
-       gopath, err := ioutil.TempDir("", "cgoerrors")
+func testOne(t *testing.T, pt ptrTest) {
+       t.Parallel()
+
+       gopath, err := ioutil.TempDir("", filepath.Base(t.Name()))
        if err != nil {
-               fmt.Fprintln(os.Stderr, err)
-               return 2
+               t.Fatal(err)
        }
        defer os.RemoveAll(gopath)
 
-       if err := os.MkdirAll(filepath.Join(gopath, "src"), 0777); err != nil {
-               fmt.Fprintln(os.Stderr, err)
-               return 2
-       }
-
-       workers := runtime.NumCPU() + 1
-
-       var wg sync.WaitGroup
-       c := make(chan int)
-       errs := make(chan int)
-       for i := 0; i < workers; i++ {
-               wg.Add(1)
-               go func() {
-                       worker(gopath, c, errs)
-                       wg.Done()
-               }()
-       }
-
-       for i := range ptrTests {
-               c <- i
-       }
-       close(c)
-
-       go func() {
-               wg.Wait()
-               close(errs)
-       }()
-
-       tot := 0
-       for e := range errs {
-               tot += e
-       }
-       return tot
-}
-
-func worker(gopath string, c, errs chan int) {
-       e := 0
-       for i := range c {
-               if !doOne(gopath, i) {
-                       e++
-               }
-       }
-       if e > 0 {
-               errs <- e
-       }
-}
-
-func doOne(gopath string, i int) bool {
-       t := &ptrTests[i]
-
-       dir := filepath.Join(gopath, "src", fmt.Sprintf("dir%d", i))
-       if err := os.Mkdir(dir, 0777); err != nil {
-               fmt.Fprintln(os.Stderr, err)
-               return false
+       src := filepath.Join(gopath, "src")
+       if err := os.Mkdir(src, 0777); err != nil {
+               t.Fatal(err)
        }
 
-       name := filepath.Join(dir, fmt.Sprintf("t%d.go", i))
+       name := filepath.Join(src, fmt.Sprintf("%s.go", filepath.Base(t.Name())))
        f, err := os.Create(name)
        if err != nil {
-               fmt.Fprintln(os.Stderr, err)
-               return false
+               t.Fatal(err)
        }
 
        b := bufio.NewWriter(f)
        fmt.Fprintln(b, `package main`)
        fmt.Fprintln(b)
        fmt.Fprintln(b, `/*`)
-       fmt.Fprintln(b, t.c)
+       fmt.Fprintln(b, pt.c)
        fmt.Fprintln(b, `*/`)
        fmt.Fprintln(b, `import "C"`)
        fmt.Fprintln(b)
-       for _, imp := range t.imports {
+       for _, imp := range pt.imports {
                fmt.Fprintln(b, `import "`+imp+`"`)
        }
-       if len(t.imports) > 0 {
+       if len(pt.imports) > 0 {
                fmt.Fprintln(b)
        }
-       if len(t.support) > 0 {
-               fmt.Fprintln(b, t.support)
+       if len(pt.support) > 0 {
+               fmt.Fprintln(b, pt.support)
                fmt.Fprintln(b)
        }
        fmt.Fprintln(b, `func main() {`)
-       fmt.Fprintln(b, t.body)
+       fmt.Fprintln(b, pt.body)
        fmt.Fprintln(b, `}`)
 
        if err := b.Flush(); err != nil {
-               fmt.Fprintf(os.Stderr, "flushing %s: %v\n", name, err)
-               return false
+               t.Fatalf("flushing %s: %v", name, err)
        }
        if err := f.Close(); err != nil {
-               fmt.Fprintf(os.Stderr, "closing %s: %v\n", name, err)
-               return false
+               t.Fatalf("closing %s: %v", name, err)
        }
 
-       for _, e := range t.extra {
-               if err := ioutil.WriteFile(filepath.Join(dir, e.name), []byte(e.contents), 0644); err != nil {
-                       fmt.Fprintf(os.Stderr, "writing %s: %v\n", e.name, err)
-                       return false
+       for _, e := range pt.extra {
+               if err := ioutil.WriteFile(filepath.Join(src, e.name), []byte(e.contents), 0644); err != nil {
+                       t.Fatalf("writing %s: %v", e.name, err)
                }
        }
 
-       ok := true
+       args := func(cmd *exec.Cmd) string {
+               return strings.Join(cmd.Args, " ")
+       }
 
        cmd := exec.Command("go", "build")
-       cmd.Dir = dir
+       cmd.Dir = src
        cmd.Env = addEnv("GOPATH", gopath)
        buf, err := cmd.CombinedOutput()
        if err != nil {
-               fmt.Fprintf(os.Stderr, "test %s failed to build: %v\n%s", t.name, err, buf)
-               return false
+               t.Logf("%#q:\n%s", args(cmd), buf)
+               t.Fatalf("failed to build: %v", err)
        }
 
-       exe := filepath.Join(dir, filepath.Base(dir))
+       exe := filepath.Join(src, filepath.Base(src))
        cmd = exec.Command(exe)
-       cmd.Dir = dir
+       cmd.Dir = src
 
-       if t.expensive {
+       if pt.expensive {
                cmd.Env = cgocheckEnv("1")
                buf, err := cmd.CombinedOutput()
                if err != nil {
-                       var errbuf bytes.Buffer
-                       if t.fail {
-                               fmt.Fprintf(&errbuf, "test %s marked expensive but failed when not expensive: %v\n", t.name, err)
+                       t.Logf("%#q:\n%s", args(cmd), buf)
+                       if pt.fail {
+                               t.Fatalf("test marked expensive, but failed when not expensive: %v", err)
                        } else {
-                               fmt.Fprintf(&errbuf, "test %s failed unexpectedly with GODEBUG=cgocheck=1: %v\n", t.name, err)
+                               t.Errorf("failed unexpectedly with GODEBUG=cgocheck=1: %v", err)
                        }
-                       reportTestOutput(&errbuf, t.name, buf)
-                       os.Stderr.Write(errbuf.Bytes())
-                       ok = false
                }
 
                cmd = exec.Command(exe)
-               cmd.Dir = dir
+               cmd.Dir = src
        }
 
-       if t.expensive {
+       if pt.expensive {
                cmd.Env = cgocheckEnv("2")
        }
 
        buf, err = cmd.CombinedOutput()
-
-       if t.fail {
+       if pt.fail {
                if err == nil {
-                       var errbuf bytes.Buffer
-                       fmt.Fprintf(&errbuf, "test %s did not fail as expected\n", t.name)
-                       reportTestOutput(&errbuf, t.name, buf)
-                       os.Stderr.Write(errbuf.Bytes())
-                       ok = false
+                       t.Logf("%#q:\n%s", args(cmd), buf)
+                       t.Fatalf("did not fail as expected")
                } else if !bytes.Contains(buf, []byte("Go pointer")) {
-                       var errbuf bytes.Buffer
-                       fmt.Fprintf(&errbuf, "test %s output does not contain expected error (failed with %v)\n", t.name, err)
-                       reportTestOutput(&errbuf, t.name, buf)
-                       os.Stderr.Write(errbuf.Bytes())
-                       ok = false
+                       t.Logf("%#q:\n%s", args(cmd), buf)
+                       t.Fatalf("did not print expected error (failed with %v)", err)
                }
        } else {
                if err != nil {
-                       var errbuf bytes.Buffer
-                       fmt.Fprintf(&errbuf, "test %s failed unexpectedly: %v\n", t.name, err)
-                       reportTestOutput(&errbuf, t.name, buf)
-                       os.Stderr.Write(errbuf.Bytes())
-                       ok = false
+                       t.Logf("%#q:\n%s", args(cmd), buf)
+                       t.Fatalf("failed unexpectedly: %v", err)
                }
 
-               if !t.expensive && ok {
+               if !pt.expensive {
                        // Make sure it passes with the expensive checks.
                        cmd := exec.Command(exe)
-                       cmd.Dir = dir
+                       cmd.Dir = src
                        cmd.Env = cgocheckEnv("2")
                        buf, err := cmd.CombinedOutput()
                        if err != nil {
-                               var errbuf bytes.Buffer
-                               fmt.Fprintf(&errbuf, "test %s failed unexpectedly with expensive checks: %v\n", t.name, err)
-                               reportTestOutput(&errbuf, t.name, buf)
-                               os.Stderr.Write(errbuf.Bytes())
-                               ok = false
+                               t.Logf("%#q:\n%s", args(cmd), buf)
+                               t.Fatalf("failed unexpectedly with expensive checks: %v", err)
                        }
                }
        }
 
-       if t.fail && ok {
+       if pt.fail {
                cmd = exec.Command(exe)
-               cmd.Dir = dir
+               cmd.Dir = src
                cmd.Env = cgocheckEnv("0")
                buf, err := cmd.CombinedOutput()
                if err != nil {
-                       var errbuf bytes.Buffer
-                       fmt.Fprintf(&errbuf, "test %s failed unexpectedly with GODEBUG=cgocheck=0: %v\n", t.name, err)
-                       reportTestOutput(&errbuf, t.name, buf)
-                       os.Stderr.Write(errbuf.Bytes())
-                       ok = false
+                       t.Logf("%#q:\n%s", args(cmd), buf)
+                       t.Fatalf("failed unexpectedly with GODEBUG=cgocheck=0: %v", err)
                }
        }
-
-       return ok
-}
-
-func reportTestOutput(w io.Writer, name string, buf []byte) {
-       fmt.Fprintf(w, "=== test %s output ===\n", name)
-       fmt.Fprintf(w, "%s", buf)
-       fmt.Fprintf(w, "=== end of test %s output ===\n", name)
 }
 
 func cgocheckEnv(val string) []string {
similarity index 88%
rename from misc/cgo/errors/issue13129.go
rename to misc/cgo/errors/src/issue13129.go
index f7ad7a7e1499f393514188d7e7226d751d34232c..057bce4b829873e34b3e896560f9eabaee1f3460 100644 (file)
@@ -10,5 +10,5 @@ import "C"
 
 func main() {
        var x C.ushort
-       x = int(0) // ERROR HERE
+       x = int(0) // ERROR HERE: C\.ushort
 }
diff --git a/misc/cgo/errors/src/issue13635.go b/misc/cgo/errors/src/issue13635.go
new file mode 100644 (file)
index 0000000..3f38f5d
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2015 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 13635: used to output error about C.unsignedchar.
+// This test tests all such types.
+
+package pkg
+
+import "C"
+
+func main() {
+       var (
+               _ C.uchar         = "uc"  // ERROR HERE: C\.uchar
+               _ C.schar         = "sc"  // ERROR HERE: C\.schar
+               _ C.ushort        = "us"  // ERROR HERE: C\.ushort
+               _ C.uint          = "ui"  // ERROR HERE: C\.uint
+               _ C.ulong         = "ul"  // ERROR HERE: C\.ulong
+               _ C.longlong      = "ll"  // ERROR HERE: C\.longlong
+               _ C.ulonglong     = "ull" // ERROR HERE: C\.ulonglong
+               _ C.complexfloat  = "cf"  // ERROR HERE: C\.complexfloat
+               _ C.complexdouble = "cd"  // ERROR HERE: C\.complexdouble
+       )
+}
similarity index 75%
rename from misc/cgo/errors/issue18452.go
rename to misc/cgo/errors/src/issue18452.go
index 36ef7f54e12dbc904138270593d3f2219097ee74..0386d768927a1c6d027ffb3a288facd90787944b 100644 (file)
@@ -13,6 +13,6 @@ import (
 
 func a() {
        fmt.Println("Hello, world!")
-       C.function_that_does_not_exist() // line 16
-       C.pi                             // line 17
+       C.function_that_does_not_exist() // ERROR HERE
+       C.pi                             // ERROR HERE
 }
diff --git a/misc/cgo/errors/src/long_double_size.go b/misc/cgo/errors/src/long_double_size.go
new file mode 100644 (file)
index 0000000..8b797f8
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2017 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
+
+/*
+const int sizeofLongDouble = sizeof(long double);
+*/
+import "C"
+
+import "fmt"
+
+func main() {
+       fmt.Println(C.sizeofLongDouble)
+}
diff --git a/misc/cgo/errors/test.bash b/misc/cgo/errors/test.bash
deleted file mode 100755 (executable)
index 04747a6..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright 2013 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() {
-       file=$1
-       line=$(grep -n 'ERROR HERE' $file | sed 's/:.*//')
-       if [ "$line" = "" ]; then
-               echo 1>&2 misc/cgo/errors/test.bash: BUG: cannot find ERROR HERE in $file
-               exit 1
-       fi
-       expect $file $file:$line:
-}
-
-expect() {
-       file=$1
-       shift
-       if go build -gcflags=-C $file >errs 2>&1; then
-               echo 1>&2 misc/cgo/errors/test.bash: BUG: expected cgo to fail on $file but it succeeded
-               exit 1
-       fi
-       if ! test -s errs; then
-               echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error output for $file but saw none
-               exit 1
-       fi
-       for error; do
-               if ! fgrep $error errs >/dev/null 2>&1; then
-                       echo 1>&2 misc/cgo/errors/test.bash: BUG: expected error output for $file to contain \"$error\" but saw:
-                       cat 1>&2 errs
-                       exit 1
-               fi
-       done
-}
-
-check err1.go
-check err2.go
-check err3.go
-if [ $(go env GOARCH) == "amd64" ]; then # If we find a portable test case, we can remove this.
-       check err4.go
-fi
-check issue7757.go
-check issue8442.go
-check issue11097a.go
-check issue11097b.go
-expect issue13129.go C.ushort
-check issue13423.go
-expect issue13635.go C.uchar C.schar C.ushort C.uint C.ulong C.longlong C.ulonglong C.complexfloat C.complexdouble
-check issue13830.go
-check issue16116.go
-check issue16591.go
-check issue18889.go
-expect issue18452.go issue18452.go:16 issue18452.go:17
-
-if ! go build issue14669.go; then
-       exit 1
-fi
-if ! CGO_CFLAGS="-O" go build issue14669.go; then
-       exit 1
-fi
-
-if ! go run ptr.go; then
-       exit 1
-fi
-
-# The malloc.go test should crash.
-rm -f malloc.out
-if go run malloc.go >malloc.out 2>&1; then
-       echo '`go run malloc.go` succeeded unexpectedly'
-       cat malloc.out
-       rm -f malloc.out
-       exit 1
-fi
-rm -f malloc.out
-
-rm -rf errs _obj
-exit 0
index 89cec9ae5454f61cc234c95394d847a75e9dac69..b91d0964f8ac1c99c4fc49805df5b9d39dc5eb05 100644 (file)
@@ -623,7 +623,7 @@ func (t *tester) registerTests() {
                        t.registerHostTest("testsanitizers/msan", "../misc/cgo/testsanitizers", "misc/cgo/testsanitizers", ".")
                }
                if t.hasBash() && t.goos != "android" && !t.iOS() && t.gohostos != "windows" {
-                       t.registerTest("cgo_errors", "../misc/cgo/errors", "./test.bash")
+                       t.registerHostTest("cgo_errors", "../misc/cgo/errors", "misc/cgo/errors", ".")
                }
                if t.gohostos == "linux" && t.extLink() {
                        t.registerTest("testsigfwd", "../misc/cgo/testsigfwd", "go", "run", "main.go")