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