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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!/usr/bin/python
import os
import re
import matplotlib, tempfile
import cr2
from test_thermal import BaseTestThermal
class TestCR2(BaseTestThermal):
def __init__(self, *args, **kwargs):
super(TestCR2, self).__init__(*args, **kwargs)
self.map_label = {"00000000,00000039": "A53", "00000000,00000006": "A57"}
self.actor_order = ["GPU", "A57", "A53"]
def test_summary_plots(self):
"""Test summary_plots()
Can't check that the graphs are ok, so just see that the method doesn't blow up"""
cr2.summary_plots(self.actor_order, self.map_label)
matplotlib.pyplot.close('all')
cr2.summary_plots(self.actor_order, self.map_label, width=14,
title="Foo")
matplotlib.pyplot.close('all')
def test_summary_plots_bad_parameters(self):
"""When summary_plots() receives bad parameters, it offers an understandable error"""
self.assertRaises(TypeError, cr2.summary_plots,
(self.map_label, self.actor_order))
try:
cr2.summary_plots(self.map_label, self.actor_order)
self.fail()
except TypeError as exception:
pass
self.assertTrue("actor_order" in str(exception))
try:
cr2.summary_plots(self.actor_order, self.actor_order)
self.fail()
except TypeError as exception:
pass
self.assertTrue("map_label" in str(exception))
def test_summary_other_dir(self):
"""Test summary_plots() with another directory"""
other_random_dir = tempfile.mkdtemp()
os.chdir(other_random_dir)
cr2.summary_plots(self.actor_order, self.map_label, path=self.out_dir)
matplotlib.pyplot.close('all')
# Sanity check that the test actually ran from another directory
self.assertEquals(os.getcwd(), other_random_dir)
def test_summary_plots_only_power_allocator_trace(self):
"""Test that summary_plots() work if there is only power allocator
trace"""
# Strip out "thermal_temperature" from the trace
trace_out = ""
with open("trace.txt") as fin:
for line in fin:
if not re.search("thermal_temperature:", line):
trace_out += line
with open("trace.txt", "w") as fout:
fout.write(trace_out)
cr2.summary_plots(self.actor_order, self.map_label)
matplotlib.pyplot.close('all')
def test_compare_runs(self):
"""Basic compare_runs() functionality"""
cr2.compare_runs(self.actor_order, self.map_label,
runs=[("new", "."), ("old", self.out_dir)])
matplotlib.pyplot.close('all')
|