From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VE9PN-0008PZ-9U for qemu-devel@nongnu.org; Mon, 26 Aug 2013 22:53:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VE9PD-00079W-PJ for qemu-devel@nongnu.org; Mon, 26 Aug 2013 22:53:29 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:52453) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VE9PB-0006v3-Sk for qemu-devel@nongnu.org; Mon, 26 Aug 2013 22:53:19 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Aug 2013 23:47:14 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id D681C2CE8052 for ; Tue, 27 Aug 2013 12:53:02 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7R2awKB4522392 for ; Tue, 27 Aug 2013 12:36:58 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r7R2r2L0026326 for ; Tue, 27 Aug 2013 12:53:02 +1000 From: Wenchao Xia Date: Tue, 27 Aug 2013 10:52:11 +0800 Message-Id: <1377571931-9144-4-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1377571931-9144-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1377571931-9144-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V2 3/3] qemu-iotests: add tests for runtime fd passing via SCM rights List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, Wenchao Xia , armbru@redhat.com, anthony@codemonkey.ws, lcapitulino@redhat.com 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 instance correctly. Signed-off-by: Wenchao Xia --- tests/qemu-iotests/045 | 37 ++++++++++++++++++++++++++++++++++++- tests/qemu-iotests/045.out | 4 ++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/045 b/tests/qemu-iotests/045 index 2b6f1af..f95e5fa 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,40 @@ 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') + self.file0 = open(image0, 'r') + self.vm.add_monitor_telnet("0",4445) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + self.file0.close() + os.remove(image0) + + def _send_fd_by_SCM(self): + ret = self.vm.send_fd_scm(self.file0.fileno()) + 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 -- 1.7.1