1
0
mirror of https://github.com/golang/go synced 2024-11-17 13:14:56 -07:00

cmd/link: write to temp directory in test

In TestMMap, write to temporary directory, instead of the current
directory (which may not be writeable).

Fix linux-mips64le-mengzhuo builder.

Change-Id: I06dc3266f125523568c543634079c447d91903bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/227077
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2020-04-02 20:57:44 -04:00
parent a9a78b7005
commit 6117275788

View File

@ -5,7 +5,9 @@
package ld
import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"testing"
)
@ -17,12 +19,16 @@ func TestMMap(t *testing.T) {
t.Skip("unsupported OS")
case "darwin", "dragonfly", "freebsd", "linux", "openbsd", "windows":
}
filename := "foo.out"
dir, err := ioutil.TempDir("", "TestMMap")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
filename := filepath.Join(dir, "foo.out")
ob := NewOutBuf(nil)
if err := ob.Open(filename); err != nil {
t.Errorf("error opening file: %v", err)
t.Fatalf("error opening file: %v", err)
}
defer os.RemoveAll(filename)
defer ob.Close()
if err := ob.Mmap(1 << 20); err != nil {
t.Errorf("error mmapping file %v", err)