diff --git a/tests/functional/pyocf/types/core.py b/tests/functional/pyocf/types/core.py index f980e6c..8defc8f 100644 --- a/tests/functional/pyocf/types/core.py +++ b/tests/functional/pyocf/types/core.py @@ -121,14 +121,17 @@ class Core: return Volume.get_instance(lib.ocf_core_get_volume(self.handle)) def new_core_io( - self, queue: Queue, addr: int, length: int, direction: IoDir, - io_class: int, flags: int + self, + queue: Queue, + addr: int, + length: int, + direction: IoDir, + io_class: int, + flags: int, ): - lib = OcfLib.getInstance() - volume = lib.ocf_core_get_volume(self.handle) - io = lib.ocf_volume_new_io( - volume, queue.handle, addr, length, direction, io_class, flags) - return Io.from_pointer(io) + return self.get_volume().new_io( + queue, addr, length, direction, io_class, flags + ) def get_default_queue(self): return self.cache.get_default_queue() @@ -233,16 +236,6 @@ class Core: lib = OcfLib.getInstance() lib.ocf_core_get_uuid_wrapper.restype = POINTER(Uuid) lib.ocf_core_get_uuid_wrapper.argtypes = [c_void_p] -lib.ocf_volume_new_io.argtypes = [ - c_void_p, - c_void_p, - c_uint64, - c_uint32, - c_uint32, - c_uint32, - c_uint64, -] -lib.ocf_volume_new_io.restype = c_void_p lib.ocf_core_get_volume.argtypes = [c_void_p] lib.ocf_core_get_volume.restype = c_void_p lib.ocf_core_get_front_volume.argtypes = [c_void_p] diff --git a/tests/functional/pyocf/types/volume.py b/tests/functional/pyocf/types/volume.py index ed8e211..e6a852c 100644 --- a/tests/functional/pyocf/types/volume.py +++ b/tests/functional/pyocf/types/volume.py @@ -24,6 +24,7 @@ from hashlib import md5 import weakref from .io import Io, IoOps, IoDir +from .queue import Queue from .shared import OcfErrorCode, Uuid from ..ocf import OcfLib from ..utils import print_buffer, Size as S @@ -139,6 +140,7 @@ class Volume: return -OcfErrorCode.OCF_ERR_NOT_OPEN_EXC Volume._instances_[ref] = volume + volume.handle = ref return volume.do_open() @@ -306,6 +308,21 @@ class Volume: else: self._reject_io(io) + def new_io( + self, + queue: Queue, + addr: int, + length: int, + direction: IoDir, + io_class: int, + flags: int, + ): + lib = OcfLib.getInstance() + io = lib.ocf_volume_new_io( + self.handle, queue.handle, addr, length, direction, io_class, flags + ) + return Io.from_pointer(io) + class RamVolume(Volume): props = None @@ -451,3 +468,13 @@ lib.ocf_io_get_volume.argtypes = [c_void_p] lib.ocf_io_get_volume.restype = c_void_p lib.ocf_io_get_data.argtypes = [c_void_p] lib.ocf_io_get_data.restype = c_void_p +lib.ocf_volume_new_io.argtypes = [ + c_void_p, + c_void_p, + c_uint64, + c_uint32, + c_uint32, + c_uint32, + c_uint64, +] +lib.ocf_volume_new_io.restype = c_void_p