diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/libgfapi-python-tests.py | 12 | ||||
-rw-r--r-- | test/unit/gluster/test_gfapi.py | 10 |
2 files changed, 17 insertions, 5 deletions
diff --git a/test/functional/libgfapi-python-tests.py b/test/functional/libgfapi-python-tests.py index 13ae54d..87dbfe0 100644 --- a/test/functional/libgfapi-python-tests.py +++ b/test/functional/libgfapi-python-tests.py @@ -13,6 +13,7 @@ import unittest import os import types import errno +import threading from gluster.gfapi import File, Volume from gluster.exceptions import LibgfapiException @@ -197,6 +198,17 @@ class FileOpsTest(unittest.TestCase): f.lseek(0, os.SEEK_SET) self.assertEqual(f.read(), data + "hello world") + def test_fopen_in_thread(self): + def gluster_fopen(): + name = uuid4().hex + with self.vol.fopen(name, 'w') as f: + f.write('hello world') + + # the following caused segfault before the fix + thread = threading.Thread(target=gluster_fopen) + thread.start() + thread.join() + def test_create_file_already_exists(self): try: f = File(self.vol.open("newfile", os.O_CREAT)) diff --git a/test/unit/gluster/test_gfapi.py b/test/unit/gluster/test_gfapi.py index 7206aa1..d07ec67 100644 --- a/test/unit/gluster/test_gfapi.py +++ b/test/unit/gluster/test_gfapi.py @@ -440,7 +440,7 @@ class TestVolume(unittest.TestCase): mock_glfs_creat = Mock() mock_glfs_creat.return_value = 2 - with patch("gluster.api.client.glfs_creat", mock_glfs_creat): + with patch("gluster.api.glfs_creat", mock_glfs_creat): with File(self.vol.open("file.txt", os.O_CREAT, 0644)) as f: self.assertTrue(isinstance(f, File)) self.assertEqual(mock_glfs_creat.call_count, 1) @@ -716,7 +716,7 @@ class TestVolume(unittest.TestCase): mock_glfs_open = Mock() mock_glfs_open.return_value = 2 - with patch("gluster.api.client.glfs_open", mock_glfs_open): + with patch("gluster.api.glfs_open", mock_glfs_open): with File(self.vol.open("file.txt", os.O_WRONLY)) as f: self.assertTrue(isinstance(f, File)) self.assertEqual(mock_glfs_open.call_count, 1) @@ -731,14 +731,14 @@ class TestVolume(unittest.TestCase): with self.vol.open("file.txt", os.O_WRONLY) as fd: self.assertEqual(fd, None) - with patch("gluster.api.client.glfs_open", mock_glfs_open): + with patch("gluster.api.glfs_open", mock_glfs_open): self.assertRaises(OSError, assert_open) def test_open_direct_success(self): mock_glfs_open = Mock() mock_glfs_open.return_value = 2 - with patch("gluster.api.client.glfs_open", mock_glfs_open): + with patch("gluster.api.glfs_open", mock_glfs_open): f = File(self.vol.open("file.txt", os.O_WRONLY)) self.assertTrue(isinstance(f, File)) self.assertEqual(mock_glfs_open.call_count, 1) @@ -749,7 +749,7 @@ class TestVolume(unittest.TestCase): mock_glfs_open = Mock() mock_glfs_open.return_value = None - with patch("gluster.api.client.glfs_open", mock_glfs_open): + with patch("gluster.api.glfs_open", mock_glfs_open): self.assertRaises(OSError, self.vol.open, "file.txt", os.O_RDONLY) def test_opendir_success(self): |