test api: utility to extract info about CAS md
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
82e76e768d
commit
f124611e10
39
test/functional/api/cas/dmesg.py
Normal file
39
test/functional/api/cas/dmesg.py
Normal file
@ -0,0 +1,39 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import re
|
||||
|
||||
from test_utils.size import Size, Unit
|
||||
|
||||
|
||||
def get_metadata_size(dmesg):
|
||||
for s in dmesg.split("\n"):
|
||||
if "Metadata capacity:" in s:
|
||||
size = re.search("[0-9]* MiB", s).group()
|
||||
return Size(int(re.search("[0-9]*", size).group()), Unit.MebiByte)
|
||||
|
||||
raise ValueError("Can't find the metadata size in the privded dmesg output")
|
||||
|
||||
|
||||
def _get_metadata_info(dmesg, section_name):
|
||||
for s in dmesg.split("\n"):
|
||||
if section_name in s:
|
||||
size, unit = re.search("[0-9]* (B|kiB)", s).group().split()
|
||||
unit = Unit.KibiByte if unit == "kiB" else Unit.Byte
|
||||
return Size(int(re.search("[0-9]*", size).group()), unit)
|
||||
|
||||
raise ValueError(f'"{section_name}" entry doesn\'t exist in the given dmesg output')
|
||||
|
||||
|
||||
def get_md_section_size(section_name, dmesg):
|
||||
section_name = section_name.strip()
|
||||
section_name += " size"
|
||||
return _get_metadata_info(dmesg, section_name)
|
||||
|
||||
|
||||
def get_md_section_offset(section_name, dmesg):
|
||||
section_name = section_name.strip()
|
||||
section_name += " offset"
|
||||
return _get_metadata_info(dmesg, section_name)
|
Loading…
Reference in New Issue
Block a user