diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2018-11-01 13:24:51 +0000 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2018-11-01 13:24:51 +0000 |
| commit | 8ebf8ea90ecbbb2ef743dccfbfb73e2904cad1f5 (patch) | |
| tree | 56a5de883941fd7bacf6c485225bedcbad5450f9 /tests/qemu-iotests/nbd-fault-injector.py | |
| parent | 8002fa2bf6d3eddc0b73f8a0b64ac6b3ad1defab (diff) | |
| parent | e301e65c97142c4d2a2adf35f5a4fa73d65d8a4f (diff) | |
| download | focaccia-qemu-8ebf8ea90ecbbb2ef743dccfbfb73e2904cad1f5.tar.gz focaccia-qemu-8ebf8ea90ecbbb2ef743dccfbfb73e2904cad1f5.zip | |
Merge remote-tracking branch 'remotes/ehabkost/tags/python-next-pull-request' into staging
Python queue, 2018-10-30 * Makefile rule for running acceptance tests (make check-acceptance) (Cleber Rosa) * Make iotests compatible with Python 3 (Max Reitz) * device-crash-test whitelist update (Thomas Huth) * Misc cleanups (Cleber Rosa) # gpg: Signature made Wed 31 Oct 2018 00:28:39 GMT # gpg: using RSA key 2807936F984DC5A6 # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/python-next-pull-request: scripts/qemu.py: use a more consistent docstring style scripts/decodetree.py: fix reference to attributes Travis support for the acceptance tests Acceptance tests: add make rule for running them Bootstrap Python venv for tests iotests: Unify log outputs between Python 2 and 3 iotests: Modify imports for Python 3 iotests: 'new' module replacement in 169 iotests: Explicitly bequeath FDs in Python iotests: Different iterator behavior in Python 3 iotests: Use // for Python integer division iotests: Use Python byte strings where appropriate iotests: Flush in iotests.py's QemuIoInteractive iotests: Make nbd-fault-injector flush scripts/device-crash-test: Remove devices that are not user_creatable anymore Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/qemu-iotests/nbd-fault-injector.py')
| -rwxr-xr-x | tests/qemu-iotests/nbd-fault-injector.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/nbd-fault-injector.py index f9193c0fae..6b2d659dee 100755 --- a/tests/qemu-iotests/nbd-fault-injector.py +++ b/tests/qemu-iotests/nbd-fault-injector.py @@ -48,7 +48,10 @@ import sys import socket import struct import collections -import ConfigParser +if sys.version_info.major >= 3: + import configparser +else: + import ConfigParser as configparser FAKE_DISK_SIZE = 8 * 1024 * 1024 * 1024 # 8 GB @@ -86,7 +89,7 @@ def recvall(sock, bufsize): raise Exception('unexpected disconnect') chunks.append(chunk) received += len(chunk) - return ''.join(chunks) + return b''.join(chunks) class Rule(object): def __init__(self, name, event, io, when): @@ -112,6 +115,7 @@ class FaultInjectionSocket(object): if rule.match(event, io): if rule.when == 0 or bufsize is None: print('Closing connection on rule match %s' % rule.name) + self.sock.flush() sys.exit(0) if rule.when != -1: return rule.when @@ -176,7 +180,7 @@ def handle_connection(conn, use_export): req = read_request(conn) if req.type == NBD_CMD_READ: write_reply(conn, 0, req.handle) - conn.send('\0' * req.len, event='data') + conn.send(b'\0' * req.len, event='data') elif req.type == NBD_CMD_WRITE: _ = conn.recv(req.len, event='data') write_reply(conn, 0, req.handle) @@ -224,7 +228,7 @@ def parse_config(config): return rules def load_rules(filename): - config = ConfigParser.RawConfigParser() + config = configparser.RawConfigParser() with open(filename, 'rt') as f: config.readfp(f, filename) return parse_config(config) |