blob: 971585ed97c04c1f0fb6633e1b42372e5d3d3ab8 [file] [log] [blame]
Javi Merino034e7cc2015-04-22 18:39:21 +01001# $Copyright:
2# ----------------------------------------------------------------
3# This confidential and proprietary software may be used only as
4# authorised by a licensing agreement from ARM Limited
5# (C) COPYRIGHT 2015 ARM Limited
6# ALL RIGHTS RESERVED
7# The entire notice above must be reproduced on all authorised
8# copies and copies may only be made to the extent permitted
9# by a licensing agreement from ARM Limited.
10# ----------------------------------------------------------------
11# File: test_plotter.py
12# ----------------------------------------------------------------
13# $
14#
KP Singh7319a882014-12-24 18:18:01 +000015
16import unittest
17import matplotlib
18import pandas as pd
Kapileshwar Singh5ebf1a32015-02-06 15:50:41 +000019import tempfile
20import os
KP Singh7319a882014-12-24 18:18:01 +000021
22from test_thermal import BaseTestThermal
23import cr2
24
25
26class TestPlotter(BaseTestThermal):
27
28 """No Bombing testcases for plotter"""
29
30 def __init__(self, *args, **kwargs):
31 super(TestPlotter, self).__init__(*args, **kwargs)
32
33 def test_plot_no_pivot(self):
34 """Tests LinePlot with no pivot"""
35 run1 = cr2.Run(name="first")
36 l = cr2.LinePlot(run1, cr2.thermal.Thermal, column="temp")
Kapileshwar Singha2040442015-02-23 12:19:18 +000037 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000038
39 def test_plot_multi_run(self):
40 """Tests LinePlot with no Pivot multi runs"""
41 run1 = cr2.Run(name="first")
42 run2 = cr2.Run(name="second")
43 l = cr2.LinePlot(
44 [run1, run2], cr2.thermal.Thermal, column="temp")
Kapileshwar Singha2040442015-02-23 12:19:18 +000045 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000046
47 def test_plot_multi(self):
48 """Tests LinePlot with no Pivot multi attrs"""
49 run1 = cr2.Run(name="first")
50 run2 = cr2.Run(name="second")
51 l = cr2.LinePlot([run1,
Kapileshwar Singh18820752015-02-11 12:01:08 +000052 run2],
53 [cr2.thermal.Thermal,
54 cr2.thermal.ThermalGovernor],
55 column=["temp",
56 "power_range"])
Kapileshwar Singha2040442015-02-23 12:19:18 +000057 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000058
59 def test_plot_filter(self):
60 """Tests LinePlot with no Pivot with filters"""
61 run1 = cr2.Run(name="first")
62 run2 = cr2.Run(name="second")
63 l = cr2.LinePlot([run1,
Kapileshwar Singh18820752015-02-11 12:01:08 +000064 run2],
Javi Merino2cfd1e82015-04-21 17:22:28 +010065 [cr2.cpu_power.CpuOutPower],
Kapileshwar Singh18820752015-02-11 12:01:08 +000066 column=["power"],
67 filters={"cdev_state": [1]})
Kapileshwar Singha2040442015-02-23 12:19:18 +000068 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000069
70 def test_plot_pivot(self):
71 """Tests LinePlot with Pivot"""
72 run1 = cr2.Run(name="first")
73 l = cr2.LinePlot(
74 run1,
75 cr2.thermal.Thermal,
76 column="temp",
77 pivot="thermal_zone")
Kapileshwar Singha2040442015-02-23 12:19:18 +000078 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000079
80 def test_plot_multi_run_pivot(self):
81 """Tests LinePlot with Pivot multi runs"""
82 run1 = cr2.Run(name="first")
83 run2 = cr2.Run(name="second")
84 l = cr2.LinePlot(
Javi Merino2cfd1e82015-04-21 17:22:28 +010085 [run1, run2], cr2.cpu_power.CpuOutPower, column="power", pivot="cpus")
Kapileshwar Singha2040442015-02-23 12:19:18 +000086 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000087
88 def test_plot_multi_pivot(self):
89 """Tests LinePlot with Pivot with multi attrs"""
90 run1 = cr2.Run(name="first")
91 run2 = cr2.Run(name="second")
92 l = cr2.LinePlot([run1,
Kapileshwar Singh18820752015-02-11 12:01:08 +000093 run2],
Javi Merino2cfd1e82015-04-21 17:22:28 +010094 [cr2.cpu_power.CpuInPower,
95 cr2.cpu_power.CpuOutPower],
Kapileshwar Singh18820752015-02-11 12:01:08 +000096 column=["dynamic_power",
97 "power"],
98 pivot="cpus")
Kapileshwar Singha2040442015-02-23 12:19:18 +000099 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +0000100
101 def test_plot_multi_pivot_filter(self):
102 """Tests LinePlot with Pivot and filters"""
103 run1 = cr2.Run(name="first")
104 run2 = cr2.Run(name="second")
105 l = cr2.LinePlot(
106 run1,
Javi Merino2cfd1e82015-04-21 17:22:28 +0100107 cr2.cpu_power.CpuInPower,
KP Singh7319a882014-12-24 18:18:01 +0000108 column=[
Kapileshwar Singh18820752015-02-11 12:01:08 +0000109 "dynamic_power",
KP Singh7319a882014-12-24 18:18:01 +0000110 "load1"],
111 filters={
112 "cdev_state": [
113 1,
114 0]},
115 pivot="cpus")
Kapileshwar Singha2040442015-02-23 12:19:18 +0000116 l.view(test=True)
Kapileshwar Singh5ebf1a32015-02-06 15:50:41 +0000117
118 def test_plot_savefig(self):
119 """Tests plotter: savefig"""
120 run1 = cr2.Run(name="first")
121 run2 = cr2.Run(name="second")
122 l = cr2.LinePlot(
123 run1,
Javi Merino2cfd1e82015-04-21 17:22:28 +0100124 cr2.cpu_power.CpuInPower,
Kapileshwar Singh5ebf1a32015-02-06 15:50:41 +0000125 column=[
126 "dynamic_power",
127 "load1"],
128 filters={
129 "cdev_state": [
130 1,
131 0]},
132 pivot="cpus")
133 png_file = tempfile.mktemp(dir="/tmp", suffix=".png")
134 l.savefig(png_file)
135 self.assertTrue(os.path.isfile(png_file))
136 os.remove(png_file)