summaryrefslogtreecommitdiff
path: root/libgo/go/os/os_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/os/os_test.go')
-rw-r--r--libgo/go/os/os_test.go59
1 files changed, 52 insertions, 7 deletions
diff --git a/libgo/go/os/os_test.go b/libgo/go/os/os_test.go
index 78201f2c27e..5497704e167 100644
--- a/libgo/go/os/os_test.go
+++ b/libgo/go/os/os_test.go
@@ -45,10 +45,10 @@ var sysdir = func() *sysDir {
switch runtime.GOOS {
case "android":
return &sysDir{
- "/system/etc",
+ "/system/framework",
[]string{
- "audio_policy.conf",
- "system_fonts.xml",
+ "ext.jar",
+ "framework.jar",
},
}
case "darwin":
@@ -294,6 +294,48 @@ func TestReaddir(t *testing.T) {
testReaddir(sysdir.name, sysdir.files, t)
}
+func benchmarkReaddirname(path string, b *testing.B) {
+ var nentries int
+ for i := 0; i < b.N; i++ {
+ f, err := Open(path)
+ if err != nil {
+ b.Fatalf("open %q failed: %v", path, err)
+ }
+ ns, err := f.Readdirnames(-1)
+ f.Close()
+ if err != nil {
+ b.Fatalf("readdirnames %q failed: %v", path, err)
+ }
+ nentries = len(ns)
+ }
+ b.Logf("benchmarkReaddirname %q: %d entries", path, nentries)
+}
+
+func benchmarkReaddir(path string, b *testing.B) {
+ var nentries int
+ for i := 0; i < b.N; i++ {
+ f, err := Open(path)
+ if err != nil {
+ b.Fatalf("open %q failed: %v", path, err)
+ }
+ fs, err := f.Readdir(-1)
+ f.Close()
+ if err != nil {
+ b.Fatalf("readdir %q failed: %v", path, err)
+ }
+ nentries = len(fs)
+ }
+ b.Logf("benchmarkReaddir %q: %d entries", path, nentries)
+}
+
+func BenchmarkReaddirname(b *testing.B) {
+ benchmarkReaddirname(".", b)
+}
+
+func BenchmarkReaddir(b *testing.B) {
+ benchmarkReaddir(".", b)
+}
+
// Read the directory one entry at a time.
func smallReaddirnames(file *File, length int, t *testing.T) []string {
names := make([]string, length)
@@ -539,6 +581,12 @@ func TestHardLink(t *testing.T) {
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9, hardlinks not supported")
}
+ // From Android release M (Marshmallow), hard linking files is blocked
+ // and an attempt to call link() on a file will return EACCES.
+ // - https://code.google.com/p/android-developer-preview/issues/detail?id=3150
+ if runtime.GOOS == "android" {
+ t.Skip("skipping on android, hardlinks not supported")
+ }
defer chtmpdir(t)()
from, to := "hardlinktestfrom", "hardlinktestto"
Remove(from) // Just in case.
@@ -670,7 +718,7 @@ func TestSymlink(t *testing.T) {
func TestLongSymlink(t *testing.T) {
switch runtime.GOOS {
- case "plan9", "nacl":
+ case "android", "plan9", "nacl":
t.Skipf("skipping on %s", runtime.GOOS)
case "windows":
if !supportsSymlinks {
@@ -723,9 +771,6 @@ func TestRename(t *testing.T) {
}
func TestRenameOverwriteDest(t *testing.T) {
- if runtime.GOOS == "plan9" {
- t.Skip("skipping on plan9")
- }
defer chtmpdir(t)()
from, to := "renamefrom", "renameto"
// Just in case.