Message ID | 1378113493-18915-4-git-send-email-xiawenc@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
On Mon, Sep 02, 2013 at 05:18:13PM +0800, Wenchao Xia wrote: > @@ -125,5 +125,39 @@ class TestFdSets(iotests.QMPTestCase): > 'No file descriptor supplied via SCM_RIGHTS') > self.vm.shutdown() > > +#Add fd at runtime, there are two ways: monitor related or fdset related > +class TestSCMFd(iotests.QMPTestCase): > + def setUp(self): > + self.vm = iotests.VM() > + qemu_img('create', '-f', iotests.imgfmt, image0, '128K') > + #Add a unused monitor, to verify it works fine when two minitor present > + self.vm.add_monitor_telnet("0",4445) Sorry to be picky: please use the same whitespace style as the existing code in these patches. # Comments have a space after the hash function(args, have, space) > + self.vm.launch() > + > + def tearDown(self): > + self.vm.shutdown() > + os.remove(image0) > + > + def _send_fd_by_SCM(self): > + ret = self.vm.send_fd_scm(image0) > + self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM') > + > + def test_add_fd(self): > + self._send_fd_by_SCM() > + result = self.vm.qmp('add-fd', fdset_id=2, opaque='image0:r') > + self.assert_qmp(result, 'return/fdset-id', 2) > + > + def test_getfd(self): > + self._send_fd_by_SCM() > + result = self.vm.qmp('getfd', fdname='image0:r') > + self.assert_qmp(result, 'return', {}) > + > + def test_closefd(self): > + self._send_fd_by_SCM() > + result = self.vm.qmp('getfd', fdname='image0:r') > + self.assert_qmp(result, 'return', {}) > + result = self.vm.qmp('closefd', fdname='image0:r') > + self.assert_qmp(result, 'return', {}) It would be good to also check the error cases like the existing tests do (e.g. getfd fdname=asdf -> error).
δΊ 2013-9-2 22:51, Stefan Hajnoczi ει: > On Mon, Sep 02, 2013 at 05:18:13PM +0800, Wenchao Xia wrote: >> @@ -125,5 +125,39 @@ class TestFdSets(iotests.QMPTestCase): >> 'No file descriptor supplied via SCM_RIGHTS') >> self.vm.shutdown() >> >> +#Add fd at runtime, there are two ways: monitor related or fdset related >> +class TestSCMFd(iotests.QMPTestCase): >> + def setUp(self): >> + self.vm = iotests.VM() >> + qemu_img('create', '-f', iotests.imgfmt, image0, '128K') >> + #Add a unused monitor, to verify it works fine when two minitor present >> + self.vm.add_monitor_telnet("0",4445) > > Sorry to be picky: please use the same whitespace style as the existing > code in these patches. > > # Comments have a space after the hash > function(args, have, space) > OK, will check all the comments and fix. >> + self.vm.launch() >> + >> + def tearDown(self): >> + self.vm.shutdown() >> + os.remove(image0) >> + >> + def _send_fd_by_SCM(self): >> + ret = self.vm.send_fd_scm(image0) >> + self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM') >> + >> + def test_add_fd(self): >> + self._send_fd_by_SCM() >> + result = self.vm.qmp('add-fd', fdset_id=2, opaque='image0:r') >> + self.assert_qmp(result, 'return/fdset-id', 2) >> + >> + def test_getfd(self): >> + self._send_fd_by_SCM() >> + result = self.vm.qmp('getfd', fdname='image0:r') >> + self.assert_qmp(result, 'return', {}) >> + >> + def test_closefd(self): >> + self._send_fd_by_SCM() >> + result = self.vm.qmp('getfd', fdname='image0:r') >> + self.assert_qmp(result, 'return', {}) >> + result = self.vm.qmp('closefd', fdname='image0:r') >> + self.assert_qmp(result, 'return', {}) > > It would be good to also check the error cases like the existing tests > do (e.g. getfd fdname=asdf -> error). > OK. I'll wait a few days and respin with fix.
diff --git a/tests/qemu-iotests/045 b/tests/qemu-iotests/045 index 2b6f1af..4381d8a 100755 --- a/tests/qemu-iotests/045 +++ b/tests/qemu-iotests/045 @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Tests for fdsets. +# Tests for fdsets and getfd. # # Copyright (C) 2012 IBM Corp. # @@ -125,5 +125,39 @@ class TestFdSets(iotests.QMPTestCase): 'No file descriptor supplied via SCM_RIGHTS') self.vm.shutdown() +#Add fd at runtime, there are two ways: monitor related or fdset related +class TestSCMFd(iotests.QMPTestCase): + def setUp(self): + self.vm = iotests.VM() + qemu_img('create', '-f', iotests.imgfmt, image0, '128K') + #Add a unused monitor, to verify it works fine when two minitor present + self.vm.add_monitor_telnet("0",4445) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(image0) + + def _send_fd_by_SCM(self): + ret = self.vm.send_fd_scm(image0) + self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM') + + def test_add_fd(self): + self._send_fd_by_SCM() + result = self.vm.qmp('add-fd', fdset_id=2, opaque='image0:r') + self.assert_qmp(result, 'return/fdset-id', 2) + + def test_getfd(self): + self._send_fd_by_SCM() + result = self.vm.qmp('getfd', fdname='image0:r') + self.assert_qmp(result, 'return', {}) + + def test_closefd(self): + self._send_fd_by_SCM() + result = self.vm.qmp('getfd', fdname='image0:r') + self.assert_qmp(result, 'return', {}) + result = self.vm.qmp('closefd', fdname='image0:r') + self.assert_qmp(result, 'return', {}) + if __name__ == '__main__': iotests.main(supported_fmts=['raw']) diff --git a/tests/qemu-iotests/045.out b/tests/qemu-iotests/045.out index 3f8a935..dae404e 100644 --- a/tests/qemu-iotests/045.out +++ b/tests/qemu-iotests/045.out @@ -1,5 +1,5 @@ -...... +......... ---------------------------------------------------------------------- -Ran 6 tests +Ran 9 tests OK
This case will test whether the monitor can receive fd at runtime. To verify better, additional monitor is created to see if qemu can handler two monitor instances correctly. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> --- tests/qemu-iotests/045 | 36 +++++++++++++++++++++++++++++++++++- tests/qemu-iotests/045.out | 4 ++-- 2 files changed, 37 insertions(+), 3 deletions(-)