aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/os
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-01-25 20:56:26 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-01-25 20:56:26 +0000
commitdf1304ee03f41aed179545d1e8b4684cfd22bbdf (patch)
treec68d6b2a9f5b82a23171b0a488a4b7e5c63ad860 /libgo/go/os
parent3be18e47c33b61365786831e0f967f42b09922c9 (diff)
downloadgcc-df1304ee03f41aed179545d1e8b4684cfd22bbdf.zip
gcc-df1304ee03f41aed179545d1e8b4684cfd22bbdf.tar.gz
gcc-df1304ee03f41aed179545d1e8b4684cfd22bbdf.tar.bz2
libgo: Update to weekly.2012-01-15.
From-SVN: r183539
Diffstat (limited to 'libgo/go/os')
-rw-r--r--libgo/go/os/env_test.go11
-rw-r--r--libgo/go/os/os_test.go30
-rw-r--r--libgo/go/os/os_unix_test.go3
-rw-r--r--libgo/go/os/path_test.go5
-rw-r--r--libgo/go/os/stat_openbsd.go4
-rw-r--r--libgo/go/os/types.go26
6 files changed, 48 insertions, 31 deletions
diff --git a/libgo/go/os/env_test.go b/libgo/go/os/env_test.go
index 04ff390..991fa4d 100644
--- a/libgo/go/os/env_test.go
+++ b/libgo/go/os/env_test.go
@@ -6,6 +6,7 @@ package os_test
import (
. "os"
+ "reflect"
"testing"
)
@@ -57,3 +58,13 @@ func TestExpand(t *testing.T) {
}
}
}
+
+func TestConsistentEnviron(t *testing.T) {
+ e0 := Environ()
+ for i := 0; i < 10; i++ {
+ e1 := Environ()
+ if !reflect.DeepEqual(e0, e1) {
+ t.Fatalf("environment changed")
+ }
+ }
+}
diff --git a/libgo/go/os/os_test.go b/libgo/go/os/os_test.go
index 9a60990..59f2bb0 100644
--- a/libgo/go/os/os_test.go
+++ b/libgo/go/os/os_test.go
@@ -11,8 +11,8 @@ import (
"io/ioutil"
. "os"
"path/filepath"
+ "runtime"
"strings"
- "syscall"
"testing"
"time"
)
@@ -33,7 +33,7 @@ type sysDir struct {
}
var sysdir = func() (sd *sysDir) {
- switch syscall.OS {
+ switch runtime.GOOS {
case "windows":
sd = &sysDir{
Getenv("SystemRoot") + "\\system32\\drivers\\etc",
@@ -87,7 +87,7 @@ func size(name string, t *testing.T) int64 {
}
func equal(name1, name2 string) (r bool) {
- switch syscall.OS {
+ switch runtime.GOOS {
case "windows":
r = strings.ToLower(name1) == strings.ToLower(name2)
default:
@@ -101,7 +101,7 @@ func newFile(testName string, t *testing.T) (f *File) {
// On Unix, override $TMPDIR in case the user
// has it set to an NFS-mounted directory.
dir := ""
- if syscall.OS != "windows" {
+ if runtime.GOOS != "windows" {
dir = "/tmp"
}
f, err := ioutil.TempFile(dir, "_Go_"+testName)
@@ -276,7 +276,7 @@ func smallReaddirnames(file *File, length int, t *testing.T) []string {
func TestReaddirnamesOneAtATime(t *testing.T) {
// big directory that doesn't change often.
dir := "/usr/bin"
- switch syscall.OS {
+ switch runtime.GOOS {
case "windows":
dir = Getenv("SystemRoot") + "\\system32"
case "plan9":
@@ -380,7 +380,7 @@ func TestReaddirNValues(t *testing.T) {
func TestHardLink(t *testing.T) {
// Hardlinks are not supported under windows or Plan 9.
- if syscall.OS == "windows" || syscall.OS == "plan9" {
+ if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
return
}
from, to := "hardlinktestfrom", "hardlinktestto"
@@ -413,7 +413,7 @@ func TestHardLink(t *testing.T) {
func TestSymLink(t *testing.T) {
// Symlinks are not supported under windows or Plan 9.
- if syscall.OS == "windows" || syscall.OS == "plan9" {
+ if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
return
}
from, to := "symlinktestfrom", "symlinktestto"
@@ -475,7 +475,7 @@ func TestSymLink(t *testing.T) {
func TestLongSymlink(t *testing.T) {
// Symlinks are not supported under windows or Plan 9.
- if syscall.OS == "windows" || syscall.OS == "plan9" {
+ if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
return
}
s := "0123456789abcdef"
@@ -545,7 +545,7 @@ func exec(t *testing.T, dir, cmd string, args []string, expect string) {
func TestStartProcess(t *testing.T) {
var dir, cmd, le string
var args []string
- if syscall.OS == "windows" {
+ if runtime.GOOS == "windows" {
le = "\r\n"
cmd = Getenv("COMSPEC")
dir = Getenv("SystemRoot")
@@ -576,7 +576,7 @@ func checkMode(t *testing.T, path string, mode FileMode) {
func TestChmod(t *testing.T) {
// Chmod is not supported under windows.
- if syscall.OS == "windows" {
+ if runtime.GOOS == "windows" {
return
}
f := newFile("TestChmod", t)
@@ -678,7 +678,7 @@ func TestChtimes(t *testing.T) {
*/
pat := Atime(postStat)
pmt := postStat.ModTime()
- if !pat.Before(at) && syscall.OS != "plan9" {
+ if !pat.Before(at) && runtime.GOOS != "plan9" {
t.Errorf("AccessTime didn't go backwards; was=%d, after=%d", at, pat)
}
@@ -689,7 +689,7 @@ func TestChtimes(t *testing.T) {
func TestChdirAndGetwd(t *testing.T) {
// TODO(brainman): file.Chdir() is not implemented on windows.
- if syscall.OS == "windows" {
+ if runtime.GOOS == "windows" {
return
}
fd, err := Open(".")
@@ -700,7 +700,7 @@ func TestChdirAndGetwd(t *testing.T) {
// (unlike, say, /var, /etc, and /tmp).
dirs := []string{"/", "/usr/bin"}
// /usr/bin does not usually exist on Plan 9.
- if syscall.OS == "plan9" {
+ if runtime.GOOS == "plan9" {
dirs = []string{"/", "/usr"}
}
for mode := 0; mode < 2; mode++ {
@@ -828,7 +828,7 @@ func TestOpenError(t *testing.T) {
t.Errorf("Open(%q, %d) returns error of %T type; want *PathError", tt.path, tt.mode, err)
}
if perr.Err != tt.error {
- if syscall.OS == "plan9" {
+ if runtime.GOOS == "plan9" {
syscallErrStr := perr.Err.Error()
expectedErrStr := strings.Replace(tt.error.Error(), "file ", "", 1)
if !strings.HasSuffix(syscallErrStr, expectedErrStr) {
@@ -886,7 +886,7 @@ func run(t *testing.T, cmd []string) string {
func TestHostname(t *testing.T) {
// There is no other way to fetch hostname on windows, but via winapi.
// On Plan 9 it is can be taken from #c/sysname as Hostname() does.
- if syscall.OS == "windows" || syscall.OS == "plan9" {
+ if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
return
}
diff --git a/libgo/go/os/os_unix_test.go b/libgo/go/os/os_unix_test.go
index 1f800d7..1bdcd74 100644
--- a/libgo/go/os/os_unix_test.go
+++ b/libgo/go/os/os_unix_test.go
@@ -8,6 +8,7 @@ package os_test
import (
. "os"
+ "runtime"
"syscall"
"testing"
)
@@ -29,7 +30,7 @@ func checkUidGid(t *testing.T, path string, uid, gid int) {
func TestChown(t *testing.T) {
// Chown is not supported under windows or Plan 9.
// Plan9 provides a native ChownPlan9 version instead.
- if syscall.OS == "windows" || syscall.OS == "plan9" {
+ if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
return
}
// Use TempDir() to make sure we're on a local file system,
diff --git a/libgo/go/os/path_test.go b/libgo/go/os/path_test.go
index 89d66c2..18634ba 100644
--- a/libgo/go/os/path_test.go
+++ b/libgo/go/os/path_test.go
@@ -8,7 +8,6 @@ import (
. "os"
"path/filepath"
"runtime"
- "syscall"
"testing"
)
@@ -63,7 +62,7 @@ func TestMkdirAll(t *testing.T) {
t.Fatalf("MkdirAll %q returned wrong error path: %q not %q", ffpath, filepath.Clean(perr.Path), filepath.Clean(fpath))
}
- if syscall.OS == "windows" {
+ if runtime.GOOS == "windows" {
path := `_test\_TestMkdirAll_\dir\.\dir2\`
err := MkdirAll(path, 0777)
if err != nil {
@@ -117,7 +116,7 @@ func TestRemoveAll(t *testing.T) {
// Determine if we should run the following test.
testit := true
- if syscall.OS == "windows" {
+ if runtime.GOOS == "windows" {
// Chmod is not supported under windows.
testit = false
} else {
diff --git a/libgo/go/os/stat_openbsd.go b/libgo/go/os/stat_openbsd.go
index 66189a6..b0a569e 100644
--- a/libgo/go/os/stat_openbsd.go
+++ b/libgo/go/os/stat_openbsd.go
@@ -24,8 +24,10 @@ func fileInfoFromStat(st *syscall.Stat_t, name string) FileInfo {
}
fs.mode = FileMode(st.Mode & 0777)
switch st.Mode & syscall.S_IFMT {
- case syscall.S_IFBLK, syscall.S_IFCHR:
+ case syscall.S_IFBLK:
fs.mode |= ModeDevice
+ case syscall.S_IFCHR:
+ fs.mode |= ModeDevice | ModeCharDevice
case syscall.S_IFDIR:
fs.mode |= ModeDir
case syscall.S_IFIFO:
diff --git a/libgo/go/os/types.go b/libgo/go/os/types.go
index 2638153..bf00980 100644
--- a/libgo/go/os/types.go
+++ b/libgo/go/os/types.go
@@ -30,19 +30,23 @@ type FileMode uint32
// The defined file mode bits are the most significant bits of the FileMode.
// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
+// The values of these bits should be considered part of the public API and
+// may be used in wire protocols or disk representations: they must not be
+// changed, although new bits might be added.
const (
// The single letters are the abbreviations
// used by the String method's formatting.
- ModeDir FileMode = 1 << (32 - 1 - iota) // d: is a directory
- ModeAppend // a: append-only
- ModeExclusive // l: exclusive use
- ModeTemporary // t: temporary file (not backed up)
- ModeSymlink // L: symbolic link
- ModeDevice // D: device file
- ModeNamedPipe // p: named pipe (FIFO)
- ModeSocket // S: Unix domain socket
- ModeSetuid // u: setuid
- ModeSetgid // g: setgid
+ ModeDir FileMode = 1 << (32 - 1 - iota) // d: is a directory
+ ModeAppend // a: append-only
+ ModeExclusive // l: exclusive use
+ ModeTemporary // t: temporary file (not backed up)
+ ModeSymlink // L: symbolic link
+ ModeDevice // D: device file
+ ModeNamedPipe // p: named pipe (FIFO)
+ ModeSocket // S: Unix domain socket
+ ModeSetuid // u: setuid
+ ModeSetgid // g: setgid
+ ModeCharDevice // c: Unix character device, when ModeDevice is set
// Mask for the type bits. For regular files, none will be set.
ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice
@@ -51,7 +55,7 @@ const (
)
func (m FileMode) String() string {
- const str = "daltLDpSug"
+ const str = "daltLDpSugc"
var buf [20]byte
w := 0
for i, c := range str {