aboutsummaryrefslogtreecommitdiff
path: root/tests/test_sched_assert.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_sched_assert.py')
-rw-r--r--tests/test_sched_assert.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/test_sched_assert.py b/tests/test_sched_assert.py
index f746a77..029dde6 100644
--- a/tests/test_sched_assert.py
+++ b/tests/test_sched_assert.py
@@ -14,13 +14,14 @@
#
+from bart.sched.SchedAssert import SchedAssert
+from bart.sched.SchedMultiAssert import SchedMultiAssert
import trappy
from trappy.stats.Topology import Topology
import unittest
import utils_tests
-from bart.sched.SchedAssert import SchedAssert
@unittest.skipUnless(utils_tests.trace_cmd_installed(),
"trace-cmd not installed")
@@ -68,3 +69,41 @@ class TestSchedAssert(utils_tests.SetupDirectory):
expected_time = 0.000817
self.assertAlmostEqual(s.getRuntime(window=window), expected_time,
places=9)
+
+class TestSchedMultiAssert(utils_tests.SetupDirectory):
+ def __init__(self, *args, **kwargs):
+ self.big = [1,2]
+ self.little = [0, 3, 4, 5]
+ self.clusters = [self.big, self.little]
+ self.all_cpus = sorted(self.big + self.little)
+ self.topology = Topology(clusters=self.clusters)
+ super(TestSchedMultiAssert, self).__init__(
+ [("raw_trace.dat", "trace.dat")],
+ *args,
+ **kwargs)
+
+ def test_cpu_busy_time(self):
+ """SchedMultiAssert.getCPUBusyTime() work"""
+
+ # precalculated values against these processes in the trace
+ pids = [4729, 4734]
+ first_time = .000214
+ last_time = .003171
+
+ tr = trappy.FTrace()
+ sma = SchedMultiAssert(tr, self.topology, pids=pids)
+
+ expected_busy_time = 0.0041839999754810708
+ busy_time = sma.getCPUBusyTime("all", self.all_cpus, window=(first_time, last_time))
+ self.assertAlmostEqual(busy_time, expected_busy_time)
+
+ # percent calculation
+ expected_busy_pct = 23.582459561949445
+ busy_pct= sma.getCPUBusyTime("all", self.all_cpus, percent=True,
+ window=(first_time, last_time))
+ self.assertAlmostEqual(busy_pct, expected_busy_pct)
+
+ # percent without a window
+ expected_busy_pct = 23.018818156540004
+ busy_pct= sma.getCPUBusyTime("cluster", self.little, percent=True)
+ self.assertAlmostEqual(busy_pct, expected_busy_pct)