]> Cypherpunks.ru repositories - gostls13.git/blobdiff - misc/cgo/testso/so_test.go
[dev.cmdgo] all: merge master (912f075) into dev.cmdgo
[gostls13.git] / misc / cgo / testso / so_test.go
index 57f0fd34f78aca081045e20a22c9f3c68e10cbbd..6d14e32dc6caa474d9ca85082407c50db8b5e56c 100644 (file)
@@ -2,12 +2,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build cgo
 // +build cgo
 
 package so_test
 
 import (
-       "io/ioutil"
        "log"
        "os"
        "os/exec"
@@ -37,7 +37,7 @@ func requireTestSOSupported(t *testing.T) {
 func TestSO(t *testing.T) {
        requireTestSOSupported(t)
 
-       GOPATH, err := ioutil.TempDir("", "cgosotest")
+       GOPATH, err := os.MkdirTemp("", "cgosotest")
        if err != nil {
                log.Fatal(err)
        }
@@ -47,7 +47,7 @@ func TestSO(t *testing.T) {
        if err := overlayDir(modRoot, "testdata"); err != nil {
                log.Panic(err)
        }
-       if err := ioutil.WriteFile(filepath.Join(modRoot, "go.mod"), []byte("module cgosotest\n"), 0666); err != nil {
+       if err := os.WriteFile(filepath.Join(modRoot, "go.mod"), []byte("module cgosotest\n"), 0666); err != nil {
                log.Panic(err)
        }
 
@@ -80,6 +80,10 @@ func TestSO(t *testing.T) {
        case "windows":
                ext = "dll"
                args = append(args, "-DEXPORT_DLL")
+               // At least in mingw-clang it is not permitted to just name a .dll
+               // on the command line. You must name the corresponding import
+               // library instead, even though the dll is used when the executable is run.
+               args = append(args, "-Wl,-out-implib,libcgosotest.a")
        case "aix":
                ext = "so.1"
        }