From 3d1edd2492a97e1d047028100c3fb5f328d51478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Colomb?= Date: Wed, 30 Dec 2020 09:56:10 +0100 Subject: [PATCH] lib/fs: Fix TestChmodDir depending on umask (fixes #6551) (#7241) The test would fail if the umask on UNIX is greater than 0022, because the OS transparently subtracts it from the mode passed to Mkdir(), as the Go documentation confirms. Our goal here is not to test os.Mkdir(), so just make sure the desired mode is actually set by forcing it afterwards. --- lib/fs/basicfs_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/fs/basicfs_test.go b/lib/fs/basicfs_test.go index c900a131d..0012a774c 100644 --- a/lib/fs/basicfs_test.go +++ b/lib/fs/basicfs_test.go @@ -121,6 +121,10 @@ func TestChmodDir(t *testing.T) { if err := os.Mkdir(path, mode); err != nil { t.Error(err) } + // On UNIX, Mkdir will subtract the umask, so force desired mode explicitly + if err := os.Chmod(path, mode); err != nil { + t.Error(err) + } if stat, err := os.Stat(path); err != nil || stat.Mode()&os.ModePerm != mode { t.Errorf("wrong perm: %t %#o", err == nil, stat.Mode()&os.ModePerm)