Skip to content

Commit

Permalink
feat: Enhance od_cpu_dma_latency miss strip (#4321)
Browse files Browse the repository at this point in the history
Signed-off-by: jiazhang <[email protected]>

rh-pre-commit.version: 2.3.1
rh-pre-commit.check-secrets: ENABLED
  • Loading branch information
wushiqinlou authored Dec 27, 2024
1 parent 747e52d commit 721cb83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions insights/parsers/od_cpu_dma_latency.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class OdCpuDmaLatency(CommandParser):
"""

def parse_content(self, content):
if content and content[0].isdigit():
self.force_latency = int(content[0])
if content and content[0].strip().isdigit():
self.force_latency = int(content[0].strip())
else:
raise SkipComponent('Nothing to parse.')
10 changes: 4 additions & 6 deletions insights/tests/parsers/test_od_cpu_dma_latency.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@
from insights.parsers.od_cpu_dma_latency import OdCpuDmaLatency
from insights.tests import context_wrap

CONTENT_OD_CPU_DMA_LATENCY = """
2000000000
"""
CONTENT_OD_CPU_DMA_LATENCY = """ 2000000000"""

CONTENT_OD_CPU_DMA_LATENCY_EMPTY = ""


def test_doc_examples():
env = {'cpu_dma_latency': OdCpuDmaLatency(context_wrap(CONTENT_OD_CPU_DMA_LATENCY))}
env = {'cpu_dma_latency': OdCpuDmaLatency(context_wrap(CONTENT_OD_CPU_DMA_LATENCY, strip=False))}
failed, total = doctest.testmod(od_cpu_dma_latency, globs=env)
assert failed == 0


def test_OdCpuDmaLatency():
d = OdCpuDmaLatency(context_wrap(CONTENT_OD_CPU_DMA_LATENCY))
d = OdCpuDmaLatency(context_wrap(CONTENT_OD_CPU_DMA_LATENCY, strip=False))
assert d.force_latency == 2000000000

with pytest.raises(SkipComponent):
OdCpuDmaLatency(context_wrap(CONTENT_OD_CPU_DMA_LATENCY_EMPTY))
OdCpuDmaLatency(context_wrap(CONTENT_OD_CPU_DMA_LATENCY_EMPTY, strip=False))

0 comments on commit 721cb83

Please sign in to comment.