From d1c7b1cc4b19a7a0c2c6a594dd47cf40f98223f9 Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Fri, 27 Dec 2013 14:36:06 +0530 Subject: Handle ENOSPC on os.close() operation It is quite possible that errors on a previous write() operation are first reported at the final close(). For fruther info, refer to: http://review.gluster.org/#/c/6269/ Change-Id: If0fbe2f5109d28c82cb493f2526fd5057f86b556 Signed-off-by: Prashanth Pai Reviewed-on: http://review.gluster.org/6608 Reviewed-by: Luis Pabon Tested-by: Luis Pabon --- test/unit/common/test_fs_utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/unit/common/test_fs_utils.py b/test/unit/common/test_fs_utils.py index 0f5f6f6..dbf052f 100644 --- a/test/unit/common/test_fs_utils.py +++ b/test/unit/common/test_fs_utils.py @@ -517,6 +517,15 @@ class TestFsUtils(unittest.TestCase): finally: os.remove(tmpfile) + def test_do_close_err_ENOSPC(self): + + def _mock_os_close_enospc(fd): + raise OSError(errno.ENOSPC, os.strerror(errno.ENOSPC)) + + fd, tmpfile = mkstemp() + with patch('os.close', _mock_os_close_enospc): + self.assertRaises(DiskFileNoSpace, fs.do_close, fd) + def test_do_unlink(self): fd, tmpfile = mkstemp() try: -- cgit