Added integration test validating umask is properly set on file creation by touch.

Summary: Added integration test validating umask is properly set on file creation by touch.

Reviewed By: wez

Differential Revision: D6749557

fbshipit-source-id: adb89ec996148ede95bdb23399745b39504ae8db
This commit is contained in:
Sergey Zhupanov 2018-01-18 20:44:30 -08:00 committed by Facebook Github Bot
parent 319b991379
commit c2eb5f3f3f

View File

@ -107,6 +107,21 @@ class SetAttrTest:
self.assertGreaterEqual(st.st_atime, now)
self.assertGreaterEqual(st.st_mtime, now)
def test_umask(self):
original_umask = os.umask(0o177)
try:
filename = os.path.join(self.mount, 'test1')
with open(filename, 'w') as f:
f.write('garbage')
self.assertEqual(os.stat(filename).st_mode & 0o777, 0o600)
filename = os.path.join(self.mount, 'test2')
os.umask(0o777)
with open(filename, 'w') as f:
f.write('garbage')
self.assertEqual(os.stat(filename).st_mode & 0o777, 0o000)
finally:
os.umask(original_umask)
def test_dir_addfile(self):
dirname = os.path.join(self.mount, 'test_dir')
self.mkdir('test_dir')