func Test1435(t *testing.T) { test1435(t) }
func Test6997(t *testing.T) { test6997(t) }
+func Test9400(t *testing.T) { test9400(t) }
func TestBuildID(t *testing.T) { testBuildID(t) }
func Test8092(t *testing.T) { test8092(t) }
func Test8517(t *testing.T) { test8517(t) }
func Test8694(t *testing.T) { test8694(t) }
+func Test8756(t *testing.T) { test8756(t) }
func Test8811(t *testing.T) { test8811(t) }
+func Test9026(t *testing.T) { test9026(t) }
+func Test9510(t *testing.T) { test9510(t) }
func Test9557(t *testing.T) { test9557(t) }
func Test10303(t *testing.T) { test10303(t, 10) }
func Test11925(t *testing.T) { test11925(t) }
func Test18126(t *testing.T) { test18126(t) }
func Test18720(t *testing.T) { test18720(t) }
func Test20129(t *testing.T) { test20129(t) }
+func Test20266(t *testing.T) { test20266(t) }
func Test20369(t *testing.T) { test20369(t) }
func Test20910(t *testing.T) { test20910(t) }
func Test21708(t *testing.T) { test21708(t) }
func Test24206(t *testing.T) { test24206(t) }
func Test25143(t *testing.T) { test25143(t) }
func Test26066(t *testing.T) { test26066(t) }
+func Test26213(t *testing.T) { test26213(t) }
func Test27660(t *testing.T) { test27660(t) }
func Test28896(t *testing.T) { test28896(t) }
func Test30065(t *testing.T) { test30065(t) }
func TestCastToEnum(t *testing.T) { testCastToEnum(t) }
func TestErrno(t *testing.T) { testErrno(t) }
func TestFpVar(t *testing.T) { testFpVar(t) }
+func TestGCC68255(t *testing.T) { testGCC68255(t) }
func TestHandle(t *testing.T) { testHandle(t) }
func TestHelpers(t *testing.T) { testHelpers(t) }
func TestLibgcc(t *testing.T) { testLibgcc(t) }
import (
"testing"
- "cgotest/gcc68255"
+ "misc/cgo/test/gcc68255"
)
func testGCC68255(t *testing.T) {
package cgotest
-import _ "cgotest/issue23555a"
-import _ "cgotest/issue23555b"
+import (
+ _ "misc/cgo/test/issue23555a"
+ _ "misc/cgo/test/issue23555b"
+)
import (
"testing"
- "cgotest/issue24161arg"
- "cgotest/issue24161e0"
- "cgotest/issue24161e1"
- "cgotest/issue24161e2"
- "cgotest/issue24161res"
+ "misc/cgo/test/issue24161arg"
+ "misc/cgo/test/issue24161e0"
+ "misc/cgo/test/issue24161e1"
+ "misc/cgo/test/issue24161e2"
+ "misc/cgo/test/issue24161res"
)
func Test24161Arg(t *testing.T) {
package cgotest
-import _ "cgotest/issue26430"
+import _ "misc/cgo/test/issue26430"
package cgotest
-import _ "cgotest/issue26743"
+import _ "misc/cgo/test/issue26743"
package cgotest
-import "cgotest/issue27340"
+import "misc/cgo/test/issue27340"
var issue27340Var = issue27340.Issue27340GoFunc
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !windows
// +build !windows
// Issue 29563: internal linker fails on duplicate weak symbols.
package cgotest
-import _ "cgotest/issue29563"
+import _ "misc/cgo/test/issue29563"
package cgotest
-import "cgotest/issue30527"
+import "misc/cgo/test/issue30527"
func issue30527G() {
issue30527.G(nil)
package cgotest
/*
- typedef struct S S;
+ typedef struct S41761 S41761;
*/
import "C"
import (
- "cgotest/issue41761a"
+ "misc/cgo/test/issue41761a"
"testing"
)
func test41761(t *testing.T) {
var x issue41761a.T
- _ = (*C.struct_S)(x.X)
+ _ = (*C.struct_S41761)(x.X)
}
package issue41761a
/*
- typedef struct S S;
+ typedef struct S41761 S41761;
*/
import "C"
type T struct {
- X *C.S
+ X *C.S41761
}
package cgotest
-// Issue 43639: No runtime test needed, make sure package cgotest/issue43639 compiles well.
+// Issue 43639: No runtime test needed, make sure package misc/cgo/test/issue43639 compiles well.
-import _ "cgotest/issue43639"
+import _ "misc/cgo/test/issue43639"
package cgotest
import (
- _ "cgotest/issue52611a"
- _ "cgotest/issue52611b"
+ _ "misc/cgo/test/issue52611a"
+ _ "misc/cgo/test/issue52611b"
)
import (
"testing"
- "cgotest/issue8756"
+ "misc/cgo/test/issue8756"
)
func test8756(t *testing.T) {
package cgotest
-import "cgotest/issue8828"
+import "misc/cgo/test/issue8828"
func p() {
issue8828.Bar()
import (
"testing"
- "cgotest/issue9026"
+ "misc/cgo/test/issue9026"
)
func test9026(t *testing.T) { issue9026.Test(t) }
"sync/atomic"
"testing"
- "cgotest/issue9400"
+ "misc/cgo/test/issue9400"
)
func test9400(t *testing.T) {
"runtime"
"testing"
- "cgotest/issue9510a"
- "cgotest/issue9510b"
+ "misc/cgo/test/issue9510a"
+ "misc/cgo/test/issue9510b"
)
func test9510(t *testing.T) {
+++ /dev/null
-// Copyright 2019 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 cgotest
-
-import (
- "io"
- "os"
- "path/filepath"
- "strings"
-)
-
-// overlayDir makes a minimal-overhead copy of srcRoot in which new files may be added.
-//
-// TODO: Once we no longer need to support the misc module in GOPATH mode,
-// factor this function out into a package to reduce duplication.
-func overlayDir(dstRoot, srcRoot string) error {
- dstRoot = filepath.Clean(dstRoot)
- if err := os.MkdirAll(dstRoot, 0777); err != nil {
- return err
- }
-
- srcRoot, err := filepath.Abs(srcRoot)
- if err != nil {
- return err
- }
-
- return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error {
- if err != nil || srcPath == srcRoot {
- return err
- }
-
- suffix := strings.TrimPrefix(srcPath, srcRoot)
- for len(suffix) > 0 && suffix[0] == filepath.Separator {
- suffix = suffix[1:]
- }
- dstPath := filepath.Join(dstRoot, suffix)
-
- perm := info.Mode() & os.ModePerm
- if info.Mode()&os.ModeSymlink != 0 {
- info, err = os.Stat(srcPath)
- if err != nil {
- return err
- }
- perm = info.Mode() & os.ModePerm
- }
-
- // Always copy directories (don't symlink them).
- // If we add a file in the overlay, we don't want to add it in the original.
- if info.IsDir() {
- return os.MkdirAll(dstPath, perm|0200)
- }
-
- // If the OS supports symlinks, use them instead of copying bytes.
- if err := os.Symlink(srcPath, dstPath); err == nil {
- return nil
- }
-
- // Otherwise, copy the bytes.
- src, err := os.Open(srcPath)
- if err != nil {
- return err
- }
- defer src.Close()
-
- dst, err := os.OpenFile(dstPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm)
- if err != nil {
- return err
- }
-
- _, err = io.Copy(dst, src)
- if closeErr := dst.Close(); err == nil {
- err = closeErr
- }
- return err
- })
-}
+++ /dev/null
-// Copyright 2019 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 cgotest
-
-import (
- "os"
- "os/exec"
- "path/filepath"
- "runtime"
- "strings"
- "testing"
-)
-
-// TestCrossPackageTests compiles and runs tests that depend on imports of other
-// local packages, using source code stored in the testdata directory.
-//
-// The tests in the misc directory tree do not have a valid import path in
-// GOPATH mode, so they previously used relative imports. However, relative
-// imports do not work in module mode. In order to make the test work in both
-// modes, we synthesize a GOPATH in which the module paths are equivalent, and
-// run the tests as a subprocess.
-//
-// If and when we no longer support these tests in GOPATH mode, we can remove
-// this shim and move the tests currently located in testdata back into the
-// parent directory.
-func TestCrossPackageTests(t *testing.T) {
- switch runtime.GOOS {
- case "android":
- t.Skip("Can't exec cmd/go subprocess on Android.")
- case "ios":
- switch runtime.GOARCH {
- case "arm64":
- t.Skip("Can't exec cmd/go subprocess on iOS.")
- }
- case "linux":
- if _, err := os.Stat("/etc/alpine-release"); err == nil {
- t.Skip("skipping failing test on alpine - go.dev/issue/39857")
- }
- }
-
- GOPATH, err := os.MkdirTemp("", "cgotest")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(GOPATH)
-
- modRoot := filepath.Join(GOPATH, "src", "cgotest")
- if err := overlayDir(modRoot, "testdata"); err != nil {
- t.Fatal(err)
- }
- if err := os.WriteFile(filepath.Join(modRoot, "go.mod"), []byte("module cgotest\n"), 0666); err != nil {
- t.Fatal(err)
- }
-
- cmd := exec.Command("go", "test")
- if testing.Verbose() {
- cmd.Args = append(cmd.Args, "-v")
- }
- if testing.Short() {
- cmd.Args = append(cmd.Args, "-short")
- }
- cmd.Dir = modRoot
- cmd.Env = append(os.Environ(), "GOPATH="+GOPATH, "PWD="+cmd.Dir)
- out, err := cmd.CombinedOutput()
- if err == nil {
- t.Logf("%s:\n%s", strings.Join(cmd.Args, " "), out)
- } else {
- t.Fatalf("%s: %s\n%s", strings.Join(cmd.Args, " "), err, out)
- }
-}
import (
"testing"
- "cgotest/issue26213"
+ "misc/cgo/test/issue26213"
)
func test26213(t *testing.T) {
+++ /dev/null
-// Copyright 2012 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 cgotest
-
-import "testing"
-
-func Test9400(t *testing.T) { test9400(t) }
+++ /dev/null
-// 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 cgotest
-
-import "testing"
-
-// The actual test functions are in non-_test.go files
-// so that they can use cgo (import "C").
-// These wrappers are here for gotest to find.
-
-func Test8756(t *testing.T) { test8756(t) }
-func Test9026(t *testing.T) { test9026(t) }
-func Test9510(t *testing.T) { test9510(t) }
-func Test20266(t *testing.T) { test20266(t) }
-func Test26213(t *testing.T) { test26213(t) }
-func TestGCC68255(t *testing.T) { testGCC68255(t) }
testenv.MustHaveGoBuild(t)
testenv.MustHaveCGO(t)
- importer := New(&build.Default, token.NewFileSet(), make(map[string]*types.Package))
- _, err := importer.ImportFrom("./misc/cgo/test", testenv.GOROOT(t), 0)
+ buildCtx := build.Default
+ buildCtx.Dir = filepath.Join(testenv.GOROOT(t), "misc")
+ importer := New(&buildCtx, token.NewFileSet(), make(map[string]*types.Package))
+ _, err := importer.ImportFrom("./cgo/test", buildCtx.Dir, 0)
if err != nil {
t.Fatalf("Import failed: %v", err)
}