Merge "Test guestfs without support for close_on_exit"

This commit is contained in:
Jenkins 2014-02-10 19:20:15 +00:00 committed by Gerrit Code Review
commit bd773a625c
2 changed files with 16 additions and 1 deletions

View File

@ -14,8 +14,12 @@
class GuestFS(object):
SUPPORT_CLOSE_ON_EXIT = True
def __init__(self, close_on_exit=True):
def __init__(self, **kwargs):
if not self.SUPPORT_CLOSE_ON_EXIT and 'close_on_exit' in kwargs:
raise TypeError('close_on_exit')
self.kwargs = kwargs
self.drives = []
self.running = False
self.closed = False

View File

@ -202,3 +202,14 @@ class VirtDiskVFSGuestFSTest(test.NoDBTestCase):
self.assertEqual(vfs.handle.files["/some/file"]["gid"], 600)
vfs.teardown()
def test_close_on_error(self):
vfs = vfsimpl.VFSGuestFS(imgfile="/dummy.qcow2", imgfmt="qcow2")
vfs.setup()
self.assertFalse(vfs.handle.kwargs['close_on_exit'])
vfs.teardown()
self.stubs.Set(fakeguestfs.GuestFS, 'SUPPORT_CLOSE_ON_EXIT', False)
vfs = vfsimpl.VFSGuestFS(imgfile="/dummy.qcow2", imgfmt="qcow2")
vfs.setup()
self.assertNotIn('close_on_exit', vfs.handle.kwargs)
vfs.teardown()