tests: reduce noise on MacOS
This should get rid of Openat: O_NOFOLLOW missing: flags = 0x0 Fchmodat: adding missing AT_SYMLINK_NOFOLLOW flag sys_common_test.go:203: chmod on symlink should have failed, but did not. New mode=0333 UnmountErr: "[...]/057376762.mnt" was not found in MountInfo, cannot check for FD leak and add some context to --- FAIL: TestUtimesNano (0.00s) matrix_test.go:628: no such file or directory See https://github.com/rfjakob/gocryptfs/pull/343#issuecomment-453888006 for full test output
This commit is contained in:
parent
6542ddd2f9
commit
20140e24ed
@ -38,7 +38,9 @@ func TestReadlinkat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOpenat(t *testing.T) {
|
||||
_, err := Openat(tmpDirFd, "testOpenAt", 0, 0)
|
||||
// Always pass O_NOFOLLOW to avoid this warning:
|
||||
// Openat: O_NOFOLLOW missing: flags = 0x0"
|
||||
_, err := Openat(tmpDirFd, "testOpenAt", syscall.O_NOFOLLOW, 0)
|
||||
if err == nil {
|
||||
t.Errorf("should have failed")
|
||||
}
|
||||
@ -47,7 +49,7 @@ func TestOpenat(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fd.Close()
|
||||
rawFd, err := Openat(tmpDirFd, "testOpenAt", 0, 0)
|
||||
rawFd, err := Openat(tmpDirFd, "testOpenAt", syscall.O_NOFOLLOW, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -56,7 +58,7 @@ func TestOpenat(t *testing.T) {
|
||||
t.Fatalf("rawFd=%d", rawFd)
|
||||
}
|
||||
// Test with absolute path
|
||||
rawFd, err = Openat(-1, tmpDir+"/testOpenAt", 0, 0)
|
||||
rawFd, err = Openat(-1, tmpDir+"/testOpenAt", syscall.O_NOFOLLOW, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -156,7 +158,7 @@ func TestUnlinkat(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFchmodat(t *testing.T) {
|
||||
func TestFchmodatNofollow(t *testing.T) {
|
||||
regular := "TestFchmodat_Regular"
|
||||
f, err := os.OpenFile(tmpDir+"/"+regular, os.O_CREATE|os.O_WRONLY, 0000)
|
||||
if err != nil {
|
||||
@ -197,7 +199,10 @@ func TestFchmodat(t *testing.T) {
|
||||
|
||||
// Check what happens on a symlink
|
||||
err = FchmodatNofollow(dirfd, symlink, 0333)
|
||||
if err == nil {
|
||||
// On Darwin, permissions on symlinks are significant and can be changed. On
|
||||
// Linux they are ignored, and FchmodatNofollow rejects attempts to change
|
||||
// them.
|
||||
if err == nil && runtime.GOOS == "linux" {
|
||||
syscall.Lstat(tmpDir+"/"+symlink, &st)
|
||||
st.Mode &= 0777
|
||||
t.Errorf("chmod on symlink should have failed, but did not. New mode=%#0o", st.Mode)
|
||||
|
@ -625,7 +625,7 @@ func doTestUtimesNano(t *testing.T, path string) {
|
||||
for i, tc := range utimeTestcases {
|
||||
err := syscall.UtimesNano(path, tc.in[:])
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatalf("%q: %v", path, err)
|
||||
}
|
||||
var st syscall.Stat_t
|
||||
err = syscall.Stat(path, &st)
|
||||
|
@ -133,7 +133,8 @@ func UnmountErr(dir string) (err error) {
|
||||
var fdsNow []string
|
||||
pid := MountInfo[dir].Pid
|
||||
fds := MountInfo[dir].Fds
|
||||
if pid <= 0 {
|
||||
if pid <= 0 && runtime.GOOS == "linux" {
|
||||
// The FD leak check only works on Linux.
|
||||
fmt.Printf("UnmountErr: %q was not found in MountInfo, cannot check for FD leaks\n", dir)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user