From c37ffea4c29efd26e8a47f37d546a210cd2d7714 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Wed, 29 Dec 2021 23:57:27 +0100 Subject: [PATCH] pyocf: add from_page() method to Size class Signed-off-by: Adam Rutkowski --- tests/functional/pyocf/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/functional/pyocf/utils.py b/tests/functional/pyocf/utils.py index 3e00dbc..689b581 100644 --- a/tests/functional/pyocf/utils.py +++ b/tests/functional/pyocf/utils.py @@ -1,5 +1,5 @@ # -# Copyright(c) 2019-2021 Intel Corporation +# Copyright(c) 2019-2022 Intel Corporation # SPDX-License-Identifier: BSD-3-Clause # @@ -72,6 +72,7 @@ class Size: _GiB = _MiB * 1024 _TiB = _GiB * 1024 _SECTOR_SIZE = 512 + _PAGE_SIZE = 4096 def __init__(self, b: int, sector_aligned: bool = False): if sector_aligned: @@ -130,6 +131,10 @@ class Size: def from_sector(cls, value): return cls(value * cls._SECTOR_SIZE) + @classmethod + def from_page(cls, value): + return cls(value * cls._PAGE_SIZE) + @property def B(self): return self.bytes