aboutsummaryrefslogtreecommitdiff
path: root/test/py/test_device_get_region_info.py
diff options
context:
space:
mode:
authorJohn Levon <levon@movementarian.org>2021-10-22 13:56:38 +0100
committerGitHub <noreply@github.com>2021-10-22 13:56:38 +0100
commit7fd786fa7f0023e7bf74618c6ebc3999f5736bc6 (patch)
tree79a152071fe31d3f6bd0b5e1fbecabc310e3c895 /test/py/test_device_get_region_info.py
parent3111d8ec3ed5557b64434778fb2596908235bfa2 (diff)
downloadlibvfio-user-7fd786fa7f0023e7bf74618c6ebc3999f5736bc6.zip
libvfio-user-7fd786fa7f0023e7bf74618c6ebc3999f5736bc6.tar.gz
libvfio-user-7fd786fa7f0023e7bf74618c6ebc3999f5736bc6.tar.bz2
run python code through flake8 (#613)
Aside from general style goodness, this found a couple of accidental re-definitions, so it's worth taking the pain now. Also, only run rstlint as part of pre-push. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'test/py/test_device_get_region_info.py')
-rw-r--r--test/py/test_device_get_region_info.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/py/test_device_get_region_info.py b/test/py/test_device_get_region_info.py
index 710efd8..f7e63d2 100644
--- a/test/py/test_device_get_region_info.py
+++ b/test/py/test_device_get_region_info.py
@@ -30,18 +30,18 @@
from libvfio_user import *
import errno
import tempfile
-import os
ctx = None
sock = None
argsz = len(vfio_region_info())
+
def test_device_get_region_info_setup():
global ctx, sock
ctx = vfu_create_ctx(flags=LIBVFIO_USER_FLAG_ATTACH_NB)
- assert ctx != None
+ assert ctx is not None
ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_BAR1_REGION_IDX, size=4096,
flags=(VFU_REGION_FLAG_RW | VFU_REGION_FLAG_MEM))
@@ -50,7 +50,7 @@ def test_device_get_region_info_setup():
f = tempfile.TemporaryFile()
f.truncate(65536)
- mmap_areas = [ (0x2000, 0x1000), (0x4000, 0x2000) ]
+ mmap_areas = [(0x2000, 0x1000), (0x4000, 0x2000)]
ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_BAR2_REGION_IDX, size=0x8000,
flags=(VFU_REGION_FLAG_RW | VFU_REGION_FLAG_MEM),
@@ -60,7 +60,7 @@ def test_device_get_region_info_setup():
f = tempfile.TemporaryFile()
f.truncate(0x2000)
- mmap_areas = [ (0x1000, 0x1000) ]
+ mmap_areas = [(0x1000, 0x1000)]
ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_MIGR_REGION_IDX, size=0x2000,
flags=VFU_REGION_FLAG_RW, mmap_areas=mmap_areas,
@@ -72,6 +72,7 @@ def test_device_get_region_info_setup():
sock = connect_client(ctx)
+
def test_device_get_region_info_short_write():
payload = struct.pack("II", 0, 0)
@@ -79,6 +80,7 @@ def test_device_get_region_info_short_write():
msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload,
expect=errno.EINVAL)
+
def test_device_get_region_info_bad_argsz():
payload = vfio_region_info(argsz=8, flags=0,
@@ -88,6 +90,7 @@ def test_device_get_region_info_bad_argsz():
msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload,
expect=errno.EINVAL)
+
def test_device_get_region_info_bad_index():
payload = vfio_region_info(argsz=argsz, flags=0,
@@ -97,6 +100,7 @@ def test_device_get_region_info_bad_index():
msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_INFO, payload,
expect=errno.EINVAL)
+
def test_device_get_region_info_larger_argsz():
payload = vfio_region_info(argsz=argsz + 8, flags=0,
@@ -117,6 +121,7 @@ def test_device_get_region_info_larger_argsz():
assert info.size == 4096
assert info.offset == 0
+
def test_device_get_region_info_small_argsz_caps():
global sock
@@ -141,6 +146,7 @@ def test_device_get_region_info_small_argsz_caps():
# skip reading the SCM_RIGHTS
disconnect_client(ctx, sock)
+
def test_device_get_region_info_caps():
global sock
@@ -176,6 +182,7 @@ def test_device_get_region_info_caps():
# skip reading the SCM_RIGHTS
disconnect_client(ctx, sock)
+
def test_device_get_region_info_migr():
global sock
@@ -213,5 +220,6 @@ def test_device_get_region_info_migr():
# skip reading the SCM_RIGHTS
disconnect_client(ctx, sock)
+
def test_device_get_region_info_cleanup():
vfu_destroy_ctx(ctx)