diff --git a/tests/functional/pyocf/types/cache.py b/tests/functional/pyocf/types/cache.py index afd1523..7592c29 100644 --- a/tests/functional/pyocf/types/cache.py +++ b/tests/functional/pyocf/types/cache.py @@ -63,8 +63,7 @@ class CacheConfig(Structure): class CacheDeviceConfig(Structure): _fields_ = [ - ("_uuid", Uuid), - ("_volume_type", c_uint8), + ("_volume", c_void_p), ("_perform_test", c_bool), ("_volume_params", c_void_p), ] @@ -459,12 +458,23 @@ class Cache: @staticmethod def generate_device_config(device, perform_test=True): + uuid = Uuid( + _data=cast(create_string_buffer(device.uuid.encode("ascii")), c_char_p), + _size=len(device.uuid) + 1, + ) + volume = c_void_p() + + lib = OcfLib.getInstance() + result = lib.ocf_volume_create( + byref(volume), + device.type, + byref(uuid) + ) + if result != 0: + raise OcfError("Cache volume initialization failed", result) + device_config = CacheDeviceConfig( - _uuid=Uuid( - _data=cast(create_string_buffer(device.uuid.encode("ascii")), c_char_p), - _size=len(device.uuid) + 1, - ), - _volume_type=device.type_id, + _volume=volume, _perform_test=perform_test, _volume_params=None, ) diff --git a/tests/functional/pyocf/types/ctx.py b/tests/functional/pyocf/types/ctx.py index 20a7883..b9b4fda 100644 --- a/tests/functional/pyocf/types/ctx.py +++ b/tests/functional/pyocf/types/ctx.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: BSD-3-Clause # -from ctypes import c_void_p, Structure, c_char_p, cast, pointer, byref, c_int +from ctypes import c_void_p, Structure, c_char_p, cast, pointer, byref, c_int, c_uint8 import weakref from .logger import LoggerOps, Logger @@ -77,6 +77,11 @@ class OcfCtx: if result != 0: raise OcfError("Volume type registration failed", result) + volume_type.type = self.lib.ocf_ctx_get_volume_type( + self.ctx_handle, + volume_type.type_id + ) + self.volume_types_count += 1 def unregister_volume_type(self, vol_type): @@ -108,3 +113,5 @@ class OcfCtx: lib = OcfLib.getInstance() lib.ocf_mngt_cache_get_by_name.argtypes = [c_void_p, c_void_p, c_void_p] lib.ocf_mngt_cache_get_by_name.restype = c_int +lib.ocf_ctx_get_volume_type.argtypes = [c_void_p, c_uint8] +lib.ocf_ctx_get_volume_type.restype = c_void_p