diff options
author | Sascha Silbe <silbe@linux.vnet.ibm.com> | 2016-04-05 11:21:45 +0200 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2016-04-12 18:07:39 +0200 |
commit | c1c71e49bcf8a0e6f5ba2a41845678d4954c8106 (patch) | |
tree | ffc2ed6eb4f2d7114410d9ffa58092cb0c7ae342 /tests/qemu-iotests | |
parent | 1759386b7cfdd36f11cb4228d2237468814b0989 (diff) | |
download | qemu-c1c71e49bcf8a0e6f5ba2a41845678d4954c8106.tar.gz qemu-c1c71e49bcf8a0e6f5ba2a41845678d4954c8106.tar.bz2 qemu-c1c71e49bcf8a0e6f5ba2a41845678d4954c8106.zip |
qemu-iotests: iotests.VM: remove qtest socket on error
On error, VM.launch() cleaned up the monitor unix socket, but left the
qtest unix socket behind. This caused the remaining sub-tests to fail
with EADDRINUSE:
+======================================================================
+ERROR: testQuorum (__main__.TestFifoQuorumEvents)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+ File "148", line 63, in setUp
+ self.vm.launch()
+ File "/home6/silbe/qemu/tests/qemu-iotests/iotests.py", line 247, in launch
+ self._qmp.accept()
+ File "/home6/silbe/qemu/tests/qemu-iotests/../../scripts/qmp/qmp.py", line 141, in accept
+ return self.__negotiate_capabilities()
+ File "/home6/silbe/qemu/tests/qemu-iotests/../../scripts/qmp/qmp.py", line 57, in __negotiate_capabilities
+ raise QMPConnectError
+QMPConnectError
+
+======================================================================
+ERROR: testQuorum (__main__.TestQuorumEvents)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+ File "148", line 63, in setUp
+ self.vm.launch()
+ File "/home6/silbe/qemu/tests/qemu-iotests/iotests.py", line 244, in launch
+ self._qtest = qtest.QEMUQtestProtocol(self._qtest_path, server=True)
+ File "/home6/silbe/qemu/tests/qemu-iotests/../../scripts/qtest.py", line 33, in __init__
+ self._sock.bind(self._address)
+ File "/usr/lib64/python2.7/socket.py", line 224, in meth
+ return getattr(self._sock,name)(*args)
+error: [Errno 98] Address already in use
Fix this by cleaning up both the monitor socket and the qtest socket iff
they exist.
Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Bo Tu <tubo@linux.vnet.ibm.com>
Message-id: 1459848109-29756-4-git-send-email-silbe@linux.vnet.ibm.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests/qemu-iotests')
-rw-r--r-- | tests/qemu-iotests/iotests.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 8499e1b611..fb5c4824f3 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -16,6 +16,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +import errno import os import re import subprocess @@ -247,7 +248,8 @@ class VM(object): self._qmp.accept() self._qtest.accept() except: - os.remove(self._monitor_path) + _remove_if_exists(self._monitor_path) + _remove_if_exists(self._qtest_path) raise def shutdown(self): @@ -409,6 +411,15 @@ class QMPTestCase(unittest.TestCase): event = self.wait_until_completed(drive=drive) self.assert_qmp(event, 'data/type', 'mirror') +def _remove_if_exists(path): + '''Remove file object at path if it exists''' + try: + os.remove(path) + except OSError as exception: + if exception.errno == errno.ENOENT: + return + raise + def notrun(reason): '''Skip this test suite''' # Each test in qemu-iotests has a number ("seq") |