Commit cb2355bb authored by David Crawshaw's avatar David Crawshaw

os: adjust tests for android file system

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/108460043
parent 8543ed3d
...@@ -42,6 +42,14 @@ type sysDir struct { ...@@ -42,6 +42,14 @@ type sysDir struct {
var sysdir = func() (sd *sysDir) { var sysdir = func() (sd *sysDir) {
switch runtime.GOOS { switch runtime.GOOS {
case "android":
sd = &sysDir{
"/system/etc",
[]string{
"audio_policy.conf",
"system_fonts.xml",
},
}
case "windows": case "windows":
sd = &sysDir{ sd = &sysDir{
Getenv("SystemRoot") + "\\system32\\drivers\\etc", Getenv("SystemRoot") + "\\system32\\drivers\\etc",
...@@ -108,7 +116,7 @@ func newFile(testName string, t *testing.T) (f *File) { ...@@ -108,7 +116,7 @@ func newFile(testName string, t *testing.T) (f *File) {
// On Unix, override $TMPDIR in case the user // On Unix, override $TMPDIR in case the user
// has it set to an NFS-mounted directory. // has it set to an NFS-mounted directory.
dir := "" dir := ""
if runtime.GOOS != "windows" { if runtime.GOOS != "android" && runtime.GOOS != "windows" {
dir = "/tmp" dir = "/tmp"
} }
f, err := ioutil.TempFile(dir, "_Go_"+testName) f, err := ioutil.TempFile(dir, "_Go_"+testName)
...@@ -284,10 +292,12 @@ func TestReaddirnamesOneAtATime(t *testing.T) { ...@@ -284,10 +292,12 @@ func TestReaddirnamesOneAtATime(t *testing.T) {
// big directory that doesn't change often. // big directory that doesn't change often.
dir := "/usr/bin" dir := "/usr/bin"
switch runtime.GOOS { switch runtime.GOOS {
case "windows": case "android":
dir = Getenv("SystemRoot") + "\\system32" dir = "/system/bin"
case "plan9": case "plan9":
dir = "/bin" dir = "/bin"
case "windows":
dir = Getenv("SystemRoot") + "\\system32"
} }
file, err := Open(dir) file, err := Open(dir)
if err != nil { if err != nil {
...@@ -498,7 +508,7 @@ func TestHardLink(t *testing.T) { ...@@ -498,7 +508,7 @@ func TestHardLink(t *testing.T) {
func TestSymlink(t *testing.T) { func TestSymlink(t *testing.T) {
switch runtime.GOOS { switch runtime.GOOS {
case "windows", "plan9", "nacl": case "android", "nacl", "plan9", "windows":
t.Skipf("skipping on %s", runtime.GOOS) t.Skipf("skipping on %s", runtime.GOOS)
} }
from, to := "symlinktestfrom", "symlinktestto" from, to := "symlinktestfrom", "symlinktestto"
...@@ -630,8 +640,9 @@ func exec(t *testing.T, dir, cmd string, args []string, expect string) { ...@@ -630,8 +640,9 @@ func exec(t *testing.T, dir, cmd string, args []string, expect string) {
} }
func TestStartProcess(t *testing.T) { func TestStartProcess(t *testing.T) {
if runtime.GOOS == "nacl" { switch runtime.GOOS {
t.Skip("skipping on nacl") case "android", "nacl":
t.Skipf("skipping on %s", runtime.GOOS)
} }
var dir, cmd string var dir, cmd string
...@@ -792,8 +803,11 @@ func TestChdirAndGetwd(t *testing.T) { ...@@ -792,8 +803,11 @@ func TestChdirAndGetwd(t *testing.T) {
// These are chosen carefully not to be symlinks on a Mac // These are chosen carefully not to be symlinks on a Mac
// (unlike, say, /var, /etc, and /tmp). // (unlike, say, /var, /etc, and /tmp).
dirs := []string{"/", "/usr/bin"} dirs := []string{"/", "/usr/bin"}
// /usr/bin does not usually exist on Plan 9. // /usr/bin does not usually exist on Plan 9 or Android.
if runtime.GOOS == "plan9" { switch runtime.GOOS {
case "android":
dirs = []string{"/", "/system/bin"}
case "plan9":
dirs = []string{"/", "/usr"} dirs = []string{"/", "/usr"}
} }
for mode := 0; mode < 2; mode++ { for mode := 0; mode < 2; mode++ {
...@@ -972,9 +986,9 @@ func run(t *testing.T, cmd []string) string { ...@@ -972,9 +986,9 @@ func run(t *testing.T, cmd []string) string {
func TestHostname(t *testing.T) { func TestHostname(t *testing.T) {
// There is no other way to fetch hostname on windows, but via winapi. // 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. // On Plan 9 it can be taken from #c/sysname as Hostname() does.
switch runtime.GOOS { switch runtime.GOOS {
case "windows", "plan9", "nacl": case "android", "nacl", "plan9", "windows":
t.Skipf("skipping on %s", runtime.GOOS) t.Skipf("skipping on %s", runtime.GOOS)
} }
...@@ -1234,8 +1248,9 @@ func TestReadAtEOF(t *testing.T) { ...@@ -1234,8 +1248,9 @@ func TestReadAtEOF(t *testing.T) {
} }
func testKillProcess(t *testing.T, processKiller func(p *Process)) { func testKillProcess(t *testing.T, processKiller func(p *Process)) {
if runtime.GOOS == "nacl" { switch runtime.GOOS {
t.Skip("skipping on nacl") case "android", "nacl":
t.Skipf("skipping on %s", runtime.GOOS)
} }
dir, err := ioutil.TempDir("", "go-build") dir, err := ioutil.TempDir("", "go-build")
......
...@@ -198,8 +198,9 @@ func TestMkdirAllWithSymlink(t *testing.T) { ...@@ -198,8 +198,9 @@ func TestMkdirAllWithSymlink(t *testing.T) {
} }
func TestMkdirAllAtSlash(t *testing.T) { func TestMkdirAllAtSlash(t *testing.T) {
if runtime.GOOS == "windows" || runtime.GOOS == "plan9" { switch runtime.GOOS {
return case "android", "plan9", "windows":
t.Skipf("skipping on %s", runtime.GOOS)
} }
RemoveAll("/_go_os_test") RemoveAll("/_go_os_test")
err := MkdirAll("/_go_os_test/dir", 0777) err := MkdirAll("/_go_os_test/dir", 0777)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment