Javi Merino | 034e7cc | 2015-04-22 18:39:21 +0100 | [diff] [blame] | 1 | # $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 Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 15 | |
| 16 | import unittest |
| 17 | import matplotlib |
| 18 | import pandas as pd |
Kapileshwar Singh | 5ebf1a3 | 2015-02-06 15:50:41 +0000 | [diff] [blame] | 19 | import tempfile |
| 20 | import os |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 21 | |
| 22 | from test_thermal import BaseTestThermal |
| 23 | import cr2 |
| 24 | |
| 25 | |
| 26 | class 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 Singh | a204044 | 2015-02-23 12:19:18 +0000 | [diff] [blame] | 37 | l.view(test=True) |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 38 | |
| 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 Singh | a204044 | 2015-02-23 12:19:18 +0000 | [diff] [blame] | 45 | l.view(test=True) |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 46 | |
| 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 Singh | 1882075 | 2015-02-11 12:01:08 +0000 | [diff] [blame] | 52 | run2], |
| 53 | [cr2.thermal.Thermal, |
| 54 | cr2.thermal.ThermalGovernor], |
| 55 | column=["temp", |
| 56 | "power_range"]) |
Kapileshwar Singh | a204044 | 2015-02-23 12:19:18 +0000 | [diff] [blame] | 57 | l.view(test=True) |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 58 | |
| 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 Singh | 1882075 | 2015-02-11 12:01:08 +0000 | [diff] [blame] | 64 | run2], |
Javi Merino | 2cfd1e8 | 2015-04-21 17:22:28 +0100 | [diff] [blame] | 65 | [cr2.cpu_power.CpuOutPower], |
Kapileshwar Singh | 1882075 | 2015-02-11 12:01:08 +0000 | [diff] [blame] | 66 | column=["power"], |
| 67 | filters={"cdev_state": [1]}) |
Kapileshwar Singh | a204044 | 2015-02-23 12:19:18 +0000 | [diff] [blame] | 68 | l.view(test=True) |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 69 | |
| 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 Singh | a204044 | 2015-02-23 12:19:18 +0000 | [diff] [blame] | 78 | l.view(test=True) |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 79 | |
| 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 Merino | 2cfd1e8 | 2015-04-21 17:22:28 +0100 | [diff] [blame] | 85 | [run1, run2], cr2.cpu_power.CpuOutPower, column="power", pivot="cpus") |
Kapileshwar Singh | a204044 | 2015-02-23 12:19:18 +0000 | [diff] [blame] | 86 | l.view(test=True) |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 87 | |
| 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 Singh | 1882075 | 2015-02-11 12:01:08 +0000 | [diff] [blame] | 93 | run2], |
Javi Merino | 2cfd1e8 | 2015-04-21 17:22:28 +0100 | [diff] [blame] | 94 | [cr2.cpu_power.CpuInPower, |
| 95 | cr2.cpu_power.CpuOutPower], |
Kapileshwar Singh | 1882075 | 2015-02-11 12:01:08 +0000 | [diff] [blame] | 96 | column=["dynamic_power", |
| 97 | "power"], |
| 98 | pivot="cpus") |
Kapileshwar Singh | a204044 | 2015-02-23 12:19:18 +0000 | [diff] [blame] | 99 | l.view(test=True) |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 100 | |
| 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 Merino | 2cfd1e8 | 2015-04-21 17:22:28 +0100 | [diff] [blame] | 107 | cr2.cpu_power.CpuInPower, |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 108 | column=[ |
Kapileshwar Singh | 1882075 | 2015-02-11 12:01:08 +0000 | [diff] [blame] | 109 | "dynamic_power", |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 110 | "load1"], |
| 111 | filters={ |
| 112 | "cdev_state": [ |
| 113 | 1, |
| 114 | 0]}, |
| 115 | pivot="cpus") |
Kapileshwar Singh | a204044 | 2015-02-23 12:19:18 +0000 | [diff] [blame] | 116 | l.view(test=True) |
Kapileshwar Singh | 5ebf1a3 | 2015-02-06 15:50:41 +0000 | [diff] [blame] | 117 | |
| 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 Merino | 2cfd1e8 | 2015-04-21 17:22:28 +0100 | [diff] [blame] | 124 | cr2.cpu_power.CpuInPower, |
Kapileshwar Singh | 5ebf1a3 | 2015-02-06 15:50:41 +0000 | [diff] [blame] | 125 | 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) |