@@ -53,7 +53,8 @@ var sysdir = func() *sysDir {
5353 },
5454 }
5555 case "darwin" :
56- if runtime .GOARCH == "arm" {
56+ switch runtime .GOARCH {
57+ case "arm" , "arm64" :
5758 wd , err := syscall .Getwd ()
5859 if err != nil {
5960 wd = err .Error ()
@@ -131,7 +132,8 @@ func localTmp() string {
131132 case "android" , "windows" :
132133 return TempDir ()
133134 case "darwin" :
134- if runtime .GOARCH == "arm" {
135+ switch runtime .GOARCH {
136+ case "arm" , "arm64" :
135137 return TempDir ()
136138 }
137139 }
@@ -323,7 +325,8 @@ func TestReaddirnamesOneAtATime(t *testing.T) {
323325 case "android" :
324326 dir = "/system/bin"
325327 case "darwin" :
326- if runtime .GOARCH == "arm" {
328+ switch runtime .GOARCH {
329+ case "arm" , "arm64" :
327330 wd , err := Getwd ()
328331 if err != nil {
329332 t .Fatal (err )
@@ -534,15 +537,10 @@ func TestReaddirOfFile(t *testing.T) {
534537}
535538
536539func TestHardLink (t * testing.T ) {
537- // Hardlinks are not supported under windows or Plan 9.
538- switch runtime .GOOS {
539- case "plan9" :
540- return
541- case "darwin" :
542- if runtime .GOARCH == "arm" {
543- defer chtmpdir (t )()
544- }
540+ if runtime .GOOS == "plan9" {
541+ t .Skip ("skipping on plan9, hardlinks not supported" )
545542 }
543+ defer chtmpdir (t )()
546544 from , to := "hardlinktestfrom" , "hardlinktestto"
547545 Remove (from ) // Just in case.
548546 file , err := Create (to )
@@ -582,6 +580,9 @@ func TestHardLink(t *testing.T) {
582580// chtmpdir changes the working directory to a new temporary directory and
583581// provides a cleanup function. Used when PWD is read-only.
584582func chtmpdir (t * testing.T ) func () {
583+ if runtime .GOOS != "darwin" || (runtime .GOARCH != "arm" && runtime .GOARCH != "arm64" ) {
584+ return func () {} // only needed on darwin/arm{,64}
585+ }
585586 oldwd , err := Getwd ()
586587 if err != nil {
587588 t .Fatalf ("chtmpdir: %v" , err )
@@ -609,11 +610,8 @@ func TestSymlink(t *testing.T) {
609610 if ! supportsSymlinks {
610611 t .Skipf ("skipping on %s" , runtime .GOOS )
611612 }
612- case "darwin" :
613- if runtime .GOARCH == "arm" {
614- defer chtmpdir (t )()
615- }
616613 }
614+ defer chtmpdir (t )()
617615 from , to := "symlinktestfrom" , "symlinktestto"
618616 Remove (from ) // Just in case.
619617 file , err := Create (to )
@@ -679,11 +677,8 @@ func TestLongSymlink(t *testing.T) {
679677 if ! supportsSymlinks {
680678 t .Skipf ("skipping on %s" , runtime .GOOS )
681679 }
682- case "darwin" :
683- if runtime .GOARCH == "arm" {
684- defer chtmpdir (t )()
685- }
686680 }
681+ defer chtmpdir (t )()
687682 s := "0123456789abcdef"
688683 // Long, but not too long: a common limit is 255.
689684 s = s + s + s + s + s + s + s + s + s + s + s + s + s + s + s
@@ -704,9 +699,7 @@ func TestLongSymlink(t *testing.T) {
704699}
705700
706701func TestRename (t * testing.T ) {
707- if runtime .GOOS == "darwin" && runtime .GOARCH == "arm" {
708- defer chtmpdir (t )()
709- }
702+ defer chtmpdir (t )()
710703 from , to := "renamefrom" , "renameto"
711704 // Ensure we are not testing the overwrite case here.
712705 Remove (from )
@@ -734,9 +727,7 @@ func TestRenameOverwriteDest(t *testing.T) {
734727 if runtime .GOOS == "plan9" {
735728 t .Skip ("skipping on plan9" )
736729 }
737- if runtime .GOOS == "darwin" && runtime .GOARCH == "arm" {
738- defer chtmpdir (t )()
739- }
730+ defer chtmpdir (t )()
740731 from , to := "renamefrom" , "renameto"
741732 // Just in case.
742733 Remove (from )
@@ -807,8 +798,9 @@ func TestStartProcess(t *testing.T) {
807798 case "android" , "nacl" :
808799 t .Skipf ("skipping on %s" , runtime .GOOS )
809800 case "darwin" :
810- if runtime .GOARCH == "arm" {
811- t .Skipf ("skipping on %s/%s" , runtime .GOOS , runtime .GOARCH )
801+ switch runtime .GOARCH {
802+ case "arm" , "arm64" :
803+ t .Skipf ("skipping on %s/%s, cannot fork" , runtime .GOOS , runtime .GOARCH )
812804 }
813805 }
814806
@@ -991,7 +983,8 @@ func TestChdirAndGetwd(t *testing.T) {
991983 case "plan9" :
992984 dirs = []string {"/" , "/usr" }
993985 case "darwin" :
994- if runtime .GOARCH == "arm" {
986+ switch runtime .GOARCH {
987+ case "arm" , "arm64" :
995988 d1 , err := ioutil .TempDir ("" , "d1" )
996989 if err != nil {
997990 t .Fatalf ("TempDir: %v" , err )
@@ -1211,8 +1204,9 @@ func TestHostname(t *testing.T) {
12111204 case "android" , "nacl" , "plan9" :
12121205 t .Skipf ("skipping on %s" , runtime .GOOS )
12131206 case "darwin" :
1214- if runtime .GOARCH == "arm" {
1215- t .Skipf ("skipping on %s/%s" , runtime .GOOS , runtime .GOARCH )
1207+ switch runtime .GOARCH {
1208+ case "arm" , "arm64" :
1209+ t .Skipf ("skipping on %s/%s, cannot fork" , runtime .GOOS , runtime .GOARCH )
12161210 }
12171211 case "windows" :
12181212 testWindowsHostname (t )
@@ -1293,9 +1287,7 @@ func writeFile(t *testing.T, fname string, flag int, text string) string {
12931287}
12941288
12951289func TestAppend (t * testing.T ) {
1296- if runtime .GOOS == "darwin" && runtime .GOARCH == "arm" {
1297- defer chtmpdir (t )()
1298- }
1290+ defer chtmpdir (t )()
12991291 const f = "append.txt"
13001292 defer Remove (f )
13011293 s := writeFile (t , f , O_CREATE | O_TRUNC | O_RDWR , "new" )
@@ -1359,9 +1351,7 @@ func TestNilProcessStateString(t *testing.T) {
13591351}
13601352
13611353func TestSameFile (t * testing.T ) {
1362- if runtime .GOOS == "darwin" && runtime .GOARCH == "arm" {
1363- defer chtmpdir (t )()
1364- }
1354+ defer chtmpdir (t )()
13651355 fa , err := Create ("a" )
13661356 if err != nil {
13671357 t .Fatalf ("Create(a): %v" , err )
@@ -1485,7 +1475,8 @@ func testKillProcess(t *testing.T, processKiller func(p *Process)) {
14851475 case "android" , "nacl" :
14861476 t .Skipf ("skipping on %s" , runtime .GOOS )
14871477 case "darwin" :
1488- if runtime .GOARCH == "arm" {
1478+ switch runtime .GOARCH {
1479+ case "arm" , "arm64" :
14891480 t .Skipf ("skipping on %s/%s" , runtime .GOOS , runtime .GOARCH )
14901481 }
14911482 }
@@ -1532,7 +1523,8 @@ func TestGetppid(t *testing.T) {
15321523 // TODO: golang.org/issue/8206
15331524 t .Skipf ("skipping test on plan9; see issue 8206" )
15341525 case "darwin" :
1535- if runtime .GOARCH == "arm" {
1526+ switch runtime .GOARCH {
1527+ case "arm" , "arm64" :
15361528 t .Skipf ("skipping test on %s/%s, no fork" , runtime .GOOS , runtime .GOARCH )
15371529 }
15381530 }
0 commit comments