1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# Copyright 2015-2016 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
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")
class TestSchedAssert(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.topology = Topology(clusters=self.clusters)
super(TestSchedAssert, self).__init__(
[("raw_trace.dat", "trace.dat")],
*args,
**kwargs)
def test_get_runtime(self):
r = trappy.FTrace()
# The ls process is process we are
# testing against with pre calculated
# values
process = "ls"
# Complete duration
expected_time = 0.0034740000264719129
s = SchedAssert(r, self.topology, execname=process)
self.assertAlmostEqual(s.getRuntime(), expected_time, places=9)
self.assertAlmostEqual(s.getRuntime(), expected_time, places=9)
# Non Interrupted Window
window = (0.0034, 0.003525)
expected_time = 0.000125
self.assertAlmostEqual(s.getRuntime(window=window), expected_time,
places=9)
# Interrupted Window
window = (0.0030, 0.0032)
expected_time = 0.000166
self.assertAlmostEqual(s.getRuntime(window=window), expected_time,
places=9)
# A window with multiple interruptions
window = (0.0027, 0.0036)
expected_time = 0.000817
self.assertAlmostEqual(s.getRuntime(window=window), expected_time,
places=9)
|