summaryrefslogtreecommitdiff
path: root/src/pkg/os/os_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/os/os_test.go')
-rw-r--r--src/pkg/os/os_test.go58
1 files changed, 22 insertions, 36 deletions
diff --git a/src/pkg/os/os_test.go b/src/pkg/os/os_test.go
index ec8c50986..21e2f374c 100644
--- a/src/pkg/os/os_test.go
+++ b/src/pkg/os/os_test.go
@@ -13,6 +13,7 @@ import (
"path/filepath"
"runtime"
"strings"
+ "syscall"
"testing"
"time"
)
@@ -23,7 +24,6 @@ var dot = []string{
"error.go",
"file.go",
"os_test.go",
- "time.go",
"types.go",
"stat_darwin.go",
"stat_linux.go",
@@ -408,7 +408,7 @@ func TestHardLink(t *testing.T) {
if err != nil {
t.Fatalf("stat %q failed: %v", from, err)
}
- if !tostat.(*FileStat).SameFile(fromstat.(*FileStat)) {
+ if !SameFile(tostat, fromstat) {
t.Errorf("link %q, %q did not create hard link", to, from)
}
}
@@ -444,7 +444,7 @@ func TestSymLink(t *testing.T) {
if err != nil {
t.Fatalf("stat %q failed: %v", from, err)
}
- if !tostat.(*FileStat).SameFile(fromstat.(*FileStat)) {
+ if !SameFile(tostat, fromstat) {
t.Errorf("symlink %q, %q did not create symlink", to, from)
}
fromstat, err = Lstat(from)
@@ -541,7 +541,7 @@ func exec(t *testing.T, dir, cmd string, args []string, expect string) {
t.Errorf("exec %q returned %q wanted %q",
strings.Join(append([]string{cmd}, args...), " "), output, expect)
}
- p.Wait(0)
+ p.Wait()
}
func TestStartProcess(t *testing.T) {
@@ -658,7 +658,7 @@ func TestChtimes(t *testing.T) {
if err != nil {
t.Fatalf("Stat %s: %s", f.Name(), err)
}
- preStat := st.(*FileStat)
+ preStat := st
// Move access and modification time back a second
at := Atime(preStat)
@@ -672,7 +672,7 @@ func TestChtimes(t *testing.T) {
if err != nil {
t.Fatalf("second Stat %s: %s", f.Name(), err)
}
- postStat := st.(*FileStat)
+ postStat := st
/* Plan 9:
Mtime is the time of the last change of content. Similarly, atime is set whenever the
@@ -744,19 +744,6 @@ func TestChdirAndGetwd(t *testing.T) {
fd.Close()
}
-func TestTime(t *testing.T) {
- // Just want to check that Time() is getting something.
- // A common failure mode on Darwin is to get 0, 0,
- // because it returns the time in registers instead of
- // filling in the structure passed to the system call.
- // Too bad the compiler doesn't know that
- // 365.24*86400 is an integer.
- sec, nsec, err := Time()
- if sec < (2009-1970)*36524*864 {
- t.Errorf("Time() = %d, %d, %s; not plausible", sec, nsec, err)
- }
-}
-
func TestSeek(t *testing.T) {
f := newFile("TestSeek", t)
defer Remove(f.Name())
@@ -783,7 +770,7 @@ func TestSeek(t *testing.T) {
for i, tt := range tests {
off, err := f.Seek(tt.in, tt.whence)
if off != tt.out || err != nil {
- if e, ok := err.(*PathError); ok && e.Err == EINVAL && tt.out > 1<<32 {
+ if e, ok := err.(*PathError); ok && e.Err == syscall.EINVAL && tt.out > 1<<32 {
// Reiserfs rejects the big seeks.
// http://code.google.com/p/go/issues/detail?id=91
break
@@ -803,17 +790,17 @@ var openErrorTests = []openErrorTest{
{
sfdir + "/no-such-file",
O_RDONLY,
- ENOENT,
+ syscall.ENOENT,
},
{
sfdir,
O_WRONLY,
- EISDIR,
+ syscall.EISDIR,
},
{
sfdir + "/" + sfname + "/no-such-file",
O_WRONLY,
- ENOTDIR,
+ syscall.ENOTDIR,
},
}
@@ -866,7 +853,7 @@ func run(t *testing.T, cmd []string) string {
var b bytes.Buffer
io.Copy(&b, r)
- _, err = p.Wait(0)
+ _, err = p.Wait()
if err != nil {
t.Fatalf("run hostname Wait: %v", err)
}
@@ -999,32 +986,31 @@ func TestAppend(t *testing.T) {
}
func TestStatDirWithTrailingSlash(t *testing.T) {
- // Create new dir, in _test so it will get
- // cleaned up by make if not by us.
- path := "_test/_TestStatDirWithSlash_"
- err := MkdirAll(path, 0777)
+ // Create new temporary directory and arrange to clean it up.
+ path, err := ioutil.TempDir("", "/_TestStatDirWithSlash_")
if err != nil {
- t.Fatalf("MkdirAll %q: %s", path, err)
+ t.Fatalf("TempDir: %s", err)
}
defer RemoveAll(path)
// Stat of path should succeed.
_, err = Stat(path)
if err != nil {
- t.Fatal("stat failed:", err)
+ t.Fatalf("stat %s failed: %s", path, err)
}
// Stat of path+"/" should succeed too.
- _, err = Stat(path + "/")
+ path += "/"
+ _, err = Stat(path)
if err != nil {
- t.Fatal("stat failed:", err)
+ t.Fatalf("stat %s failed: %s", path, err)
}
}
-func TestNilWaitmsgString(t *testing.T) {
- var w *Waitmsg
- s := w.String()
+func TestNilProcessStateString(t *testing.T) {
+ var ps *ProcessState
+ s := ps.String()
if s != "<nil>" {
- t.Errorf("(*Waitmsg)(nil).String() = %q, want %q", s, "<nil>")
+ t.Errorf("(*ProcessState)(nil).String() = %q, want %q", s, "<nil>")
}
}