blob: 1cd7a0e686e2bdc2d65b0bfc5494800ae5907bb1 [file] [log] [blame]
KP Singh7319a882014-12-24 18:18:01 +00001#!/usr/bin/env python
Javi Merino034e7cc2015-04-22 18:39:21 +01002# $Copyright:
3# ----------------------------------------------------------------
4# This confidential and proprietary software may be used only as
5# authorised by a licensing agreement from ARM Limited
6# (C) COPYRIGHT 2015 ARM Limited
7# ALL RIGHTS RESERVED
8# The entire notice above must be reproduced on all authorised
9# copies and copies may only be made to the extent permitted
10# by a licensing agreement from ARM Limited.
11# ----------------------------------------------------------------
12# File: test_plotter.py
13# ----------------------------------------------------------------
14# $
15#
KP Singh7319a882014-12-24 18:18:01 +000016
17import unittest
18import matplotlib
19import pandas as pd
Kapileshwar Singh5ebf1a32015-02-06 15:50:41 +000020import tempfile
21import os
KP Singh7319a882014-12-24 18:18:01 +000022
23from test_thermal import BaseTestThermal
24import cr2
25
26
27class TestPlotter(BaseTestThermal):
28
29 """No Bombing testcases for plotter"""
30
31 def __init__(self, *args, **kwargs):
32 super(TestPlotter, self).__init__(*args, **kwargs)
33
34 def test_plot_no_pivot(self):
35 """Tests LinePlot with no pivot"""
36 run1 = cr2.Run(name="first")
37 l = cr2.LinePlot(run1, cr2.thermal.Thermal, column="temp")
Kapileshwar Singha2040442015-02-23 12:19:18 +000038 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000039
40 def test_plot_multi_run(self):
41 """Tests LinePlot with no Pivot multi runs"""
42 run1 = cr2.Run(name="first")
43 run2 = cr2.Run(name="second")
44 l = cr2.LinePlot(
45 [run1, run2], cr2.thermal.Thermal, column="temp")
Kapileshwar Singha2040442015-02-23 12:19:18 +000046 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000047
48 def test_plot_multi(self):
49 """Tests LinePlot with no Pivot multi attrs"""
50 run1 = cr2.Run(name="first")
51 run2 = cr2.Run(name="second")
52 l = cr2.LinePlot([run1,
Kapileshwar Singh18820752015-02-11 12:01:08 +000053 run2],
54 [cr2.thermal.Thermal,
55 cr2.thermal.ThermalGovernor],
56 column=["temp",
57 "power_range"])
Kapileshwar Singha2040442015-02-23 12:19:18 +000058 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000059
60 def test_plot_filter(self):
61 """Tests LinePlot with no Pivot with filters"""
62 run1 = cr2.Run(name="first")
63 run2 = cr2.Run(name="second")
64 l = cr2.LinePlot([run1,
Kapileshwar Singh18820752015-02-11 12:01:08 +000065 run2],
Javi Merino2cfd1e82015-04-21 17:22:28 +010066 [cr2.cpu_power.CpuOutPower],
Kapileshwar Singh18820752015-02-11 12:01:08 +000067 column=["power"],
68 filters={"cdev_state": [1]})
Kapileshwar Singha2040442015-02-23 12:19:18 +000069 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000070
71 def test_plot_pivot(self):
72 """Tests LinePlot with Pivot"""
73 run1 = cr2.Run(name="first")
74 l = cr2.LinePlot(
75 run1,
76 cr2.thermal.Thermal,
77 column="temp",
78 pivot="thermal_zone")
Kapileshwar Singha2040442015-02-23 12:19:18 +000079 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000080
81 def test_plot_multi_run_pivot(self):
82 """Tests LinePlot with Pivot multi runs"""
83 run1 = cr2.Run(name="first")
84 run2 = cr2.Run(name="second")
85 l = cr2.LinePlot(
Javi Merino2cfd1e82015-04-21 17:22:28 +010086 [run1, run2], cr2.cpu_power.CpuOutPower, column="power", pivot="cpus")
Kapileshwar Singha2040442015-02-23 12:19:18 +000087 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +000088
89 def test_plot_multi_pivot(self):
90 """Tests LinePlot with Pivot with multi attrs"""
91 run1 = cr2.Run(name="first")
92 run2 = cr2.Run(name="second")
93 l = cr2.LinePlot([run1,
Kapileshwar Singh18820752015-02-11 12:01:08 +000094 run2],
Javi Merino2cfd1e82015-04-21 17:22:28 +010095 [cr2.cpu_power.CpuInPower,
96 cr2.cpu_power.CpuOutPower],
Kapileshwar Singh18820752015-02-11 12:01:08 +000097 column=["dynamic_power",
98 "power"],
99 pivot="cpus")
Kapileshwar Singha2040442015-02-23 12:19:18 +0000100 l.view(test=True)
KP Singh7319a882014-12-24 18:18:01 +0000101
102 def test_plot_multi_pivot_filter(self):
103 """Tests LinePlot with Pivot and filters"""
104 run1 = cr2.Run(name="first")
105 run2 = cr2.Run(name="second")
106 l = cr2.LinePlot(
107 run1,
Javi Merino2cfd1e82015-04-21 17:22:28 +0100108 cr2.cpu_power.CpuInPower,
KP Singh7319a882014-12-24 18:18:01 +0000109 column=[
Kapileshwar Singh18820752015-02-11 12:01:08 +0000110 "dynamic_power",
KP Singh7319a882014-12-24 18:18:01 +0000111 "load1"],
112 filters={
113 "cdev_state": [
114 1,
115 0]},
116 pivot="cpus")
Kapileshwar Singha2040442015-02-23 12:19:18 +0000117 l.view(test=True)
Kapileshwar Singh5ebf1a32015-02-06 15:50:41 +0000118
119 def test_plot_savefig(self):
120 """Tests plotter: savefig"""
121 run1 = cr2.Run(name="first")
122 run2 = cr2.Run(name="second")
123 l = cr2.LinePlot(
124 run1,
Javi Merino2cfd1e82015-04-21 17:22:28 +0100125 cr2.cpu_power.CpuInPower,
Kapileshwar Singh5ebf1a32015-02-06 15:50:41 +0000126 column=[
127 "dynamic_power",
128 "load1"],
129 filters={
130 "cdev_state": [
131 1,
132 0]},
133 pivot="cpus")
134 png_file = tempfile.mktemp(dir="/tmp", suffix=".png")
135 l.savefig(png_file)
136 self.assertTrue(os.path.isfile(png_file))
137 os.remove(png_file)