GitLab maintenance scheduled form Friday, 2021-06-18 5:00pm to Satursday, 2021-06-19 10:00pm CT - Services will be unavailable during this time.

Commit 37097b20 authored by Swann Perarnau's avatar Swann Perarnau

[test] Add a clr_rapl test matching current code

This patch adds a test for the nrm/coolr/ code, based on
the __main__ code added to it recently. This is an example of how the
modules should be tested automatically, instead of relying on __main__
snippets everywhere.

We should replace those snippets bits by bits by tests similar to this
one. The end goal is to able to active a gitlab pipeline that validate
merge requests automatically.
parent ec563afb
"""Tests for the Coolr RAPL module."""
import nrm
import nrm.coolr
import nrm.coolr.clr_rapl
import pytest
def rapl_reader():
"""Fixture for a regular rapl reader."""
rr = nrm.coolr.clr_rapl.rapl_reader()
assert rr.initialized(), "no rapl sysfs detected"
return rr
def test_read_powerdomains(rapl_reader):
"""Ensure we can read the power domains."""
assert rapl_reader.get_powerdomains()
def test_get_powerlimits(rapl_reader):
"""Ensure we can read the power limits."""
data = rapl_reader.get_powerlimits()
for k in data:
if data[k]['enabled']:
assert False, "No power domain enabled."
def test_set_powerlimits(rapl_reader):
"""Ensure we can set a power limit."""
data = rapl_reader.get_powerlimits()
for k in data:
if data[k]['enabled']:
# compute a new limit in between cur and max
newlim = (data[k]['maxW'] - data[k]['curW'])/2.0
def test_sample(rapl_reader):
"""Ensure we can sample power consumption properly."""
import time
for i in range(0, 3):
assert rapl_reader.sample(accflag=True)
assert rapl_reader.total_energy_json()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment