Merge pull request #1182 from mmichal10/test-standby-corrupt-md

Test standby corrupt md
This commit is contained in:
Karolina Rogowska
2022-04-20 12:45:26 +02:00
committed by GitHub
2 changed files with 291 additions and 0 deletions

View 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)