diff options
author | Mohammed Junaid <junaid@redhat.com> | 2013-06-25 07:50:28 +0530 |
---|---|---|
committer | Peter Portante <pportant@redhat.com> | 2013-06-27 17:15:45 -0700 |
commit | c7ce3beec168cfc530da9e8d11fc1a0e8c80bcce (patch) | |
tree | 79100a6d0bc58a219f2c5784033fb7cff7276db6 /test | |
parent | 41b91061436210afd1d22cad3c2ee1e038c23e3c (diff) |
object-storage: Use fchown instead of chown.
This is a step towards making fd based system calls where ever possible to avoid
path lookups.
Signed-off-by: Mohammed Junaid <junaid@redhat.com>
Change-Id: I482ea29ebe0859d0a5307ff25ecb5945d54bc7ca
Reviewed-on: http://review.gluster.org/5251
Reviewed-by: Peter Portante <pportant@redhat.com>
Tested-by: Peter Portante <pportant@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/common/test_fs_utils.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/unit/common/test_fs_utils.py b/test/unit/common/test_fs_utils.py index 559c7db..175a362 100644 --- a/test/unit/common/test_fs_utils.py +++ b/test/unit/common/test_fs_utils.py @@ -363,6 +363,45 @@ class TestFsUtils(unittest.TestCase): else: self.fail("Expected OSError") + def test_fchown(self): + tmpdir = mkdtemp() + try: + fd, tmpfile = mkstemp(dir=tmpdir) + buf = os.stat(tmpfile) + if buf.st_uid == 0: + raise SkipTest + else: + try: + fs.do_fchown(fd, 20000, 20000) + except OSError as ex: + if ex.errno != errno.EPERM: + self.fail("Expected OSError") + else: + self.fail("Expected OSError") + finally: + os.close(fd) + shutil.rmtree(tmpdir) + + def test_fchown_err(self): + tmpdir = mkdtemp() + try: + fd, tmpfile = mkstemp(dir=tmpdir) + fd_rd = os.open(tmpfile, os.O_RDONLY) + buf = os.stat(tmpfile) + if buf.st_uid == 0: + raise SkipTest + else: + try: + fs.do_fchown(fd_rd, 20000, 20000) + except OSError as ex: + if ex.errno != errno.EPERM: + self.fail("Expected OSError") + else: + self.fail("Expected OSError") + finally: + os.close(fd_rd) + os.close(fd) + shutil.rmtree(tmpdir) def test_do_fsync(self): tmpdir = mkdtemp() |