Fix test failures on Solaris

Add exceptions for symlinks, sticky bits, and device nodes in the same places where the BSDSs and/or Darwin have them.
This commit is contained in:
Greg 2022-01-25 18:05:56 -08:00
parent df89aa0087
commit 2e9180638e
3 changed files with 6 additions and 4 deletions

View file

@ -67,7 +67,7 @@ func isSymlink(fi os.FileInfo) bool {
func sameModTime(fi1, fi2 os.FileInfo) bool { func sameModTime(fi1, fi2 os.FileInfo) bool {
switch runtime.GOOS { switch runtime.GOOS {
case "darwin", "freebsd", "openbsd", "netbsd": case "darwin", "freebsd", "openbsd", "netbsd", "solaris":
if isSymlink(fi1) && isSymlink(fi2) { if isSymlink(fi1) && isSymlink(fi2) {
return true return true
} }

View file

@ -210,7 +210,7 @@ func TestNodeRestoreAt(t *testing.T) {
"%v: GID doesn't match (%v != %v)", test.Type, test.GID, n2.GID) "%v: GID doesn't match (%v != %v)", test.Type, test.GID, n2.GID)
if test.Type != "symlink" { if test.Type != "symlink" {
// On OpenBSD only root can set sticky bit (see sticky(8)). // On OpenBSD only root can set sticky bit (see sticky(8)).
if runtime.GOOS != "openbsd" && runtime.GOOS != "netbsd" && test.Name == "testSticky" { if runtime.GOOS != "openbsd" && runtime.GOOS != "netbsd" && runtime.GOOS != "solaris" && test.Name == "testSticky" {
rtest.Assert(t, test.Mode == n2.Mode, rtest.Assert(t, test.Mode == n2.Mode,
"%v: mode doesn't match (0%o != 0%o)", test.Type, test.Mode, n2.Mode) "%v: mode doesn't match (0%o != 0%o)", test.Type, test.Mode, n2.Mode)
} }
@ -228,7 +228,7 @@ func AssertFsTimeEqual(t *testing.T, label string, nodeType string, t1 time.Time
// Go currently doesn't support setting timestamps of symbolic links on darwin and bsd // Go currently doesn't support setting timestamps of symbolic links on darwin and bsd
if nodeType == "symlink" { if nodeType == "symlink" {
switch runtime.GOOS { switch runtime.GOOS {
case "darwin", "freebsd", "openbsd", "netbsd": case "darwin", "freebsd", "openbsd", "netbsd", "solaris":
return return
} }
} }

View file

@ -93,7 +93,9 @@ func TestNodeFromFileInfo(t *testing.T) {
// on darwin, users are not permitted to list the extended attributes of // on darwin, users are not permitted to list the extended attributes of
// /dev/null, therefore skip it. // /dev/null, therefore skip it.
if runtime.GOOS != "darwin" { // on solaris, /dev/null is a symlink to a device node in /devices
// which does not support extended attributes, therefore skip it.
if runtime.GOOS != "darwin" && runtime.GOOS != "solaris" {
tests = append(tests, Test{"/dev/null", true}) tests = append(tests, Test{"/dev/null", true})
} }