def test_signals_exceptions(self):
        """Test incorrect input combinations: signals"""

        trace1 = trappy.FTrace(name="first")
        trace2 = trappy.FTrace(name="second")

        with self.assertRaises(ValueError):
            l = trappy.LinePlot([trace1, trace2],
                            column=[
                                "dynamic_power",
                                "load1"],
                            signals=["cpu_in_power:dynamic_power",
                                 "cpu_out_power:power"],
                            pivot="cpus")

        with self.assertRaises(ValueError):
            l = trappy.LinePlot([trace1, trace2],
                            trappy.cpu_power.CpuInPower,
                            signals=["cpu_in_power:dynamic_power",
                                 "cpu_out_power:power"],
                            pivot="cpus")

        with self.assertRaises(ValueError):
            l = trappy.LinePlot([trace1, trace2],
                            trappy.cpu_power.CpuInPower,
                            column=[
                                "dynamic_power",
                                "load1"],
                            signals=["cpu_in_power:dynamic_power",
                                 "cpu_out_power:power"],
                            pivot="cpus")
    def test_signals_colors(self):
        """Test signals with colors in LinePlot"""

        trace1 = trappy.FTrace(name="first")
        trace2 = trappy.FTrace(name="second")

        l = trappy.LinePlot([trace1, trace2],
                         signals=["thermal:temp:1,2,3",
                                 "cpu_in_power:load2:200,100,0"],
                         pivot="cpus")

        self.assertTrue(isinstance(l.templates[0], type(trappy.thermal.Thermal)))
        self.assertEquals(l._attr["column"][0], "temp")
        self.assertEquals(l._attr["colors"][0], [1, 2, 3])
        self.assertTrue(l.templates[1], type(trappy.cpu_power.CpuInPower))
        self.assertEquals(l._attr["column"][1], "load2")
        self.assertEquals(l._attr["colors"][1], [200, 100, 0])

        # Check that plotting doesn't barf
        l.view(test=True)

        # Test hex color
        l = trappy.LinePlot([trace1, trace2],
                         signals=["thermal:prev_temp:0xff,0x3a,0x3"],
                         pivot="cpus")
        self.assertEquals(l._attr["colors"][0], [0xff, 0x3a, 0x3])
    def test_plotter_triplicates(self):
        """Test that plotter handles triplicates fine"""

        with open("trace.txt", "w") as fout:
            fout.write("""version = 6
cpus=6
       rcuos/2-22 [001] 0000.018510: sched_load_avg_sg: cpus=00000001 load=0 utilization=0
       rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000002 load=1 utilization=1
       rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000004 load=2 utilization=2
       rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000004 load=2 utilization=2
       rcuos/2-22 [001] 6550.018612: sched_load_avg_sg: cpus=00000001 load=2 utilization=3
       rcuos/2-22 [001] 6550.018624: sched_load_avg_sg: cpus=00000002 load=1 utilization=4
       rcuos/2-22 [001] 6550.018625: sched_load_avg_sg: cpus=00000002 load=2 utilization=5
       rcuos/2-22 [001] 6550.018626: sched_load_avg_sg: cpus=00000002 load=3 utilization=6
       rcuos/2-22 [001] 6550.018627: sched_load_avg_sg: cpus=00000002 load=1 utilization=7
       rcuos/2-22 [001] 6550.018628: sched_load_avg_sg: cpus=00000004 load=2 utilization=8\n"""
                       )
            fout.close()

        trace1 = trappy.FTrace(name="first")
        l = trappy.LinePlot(trace1,
                            trappy.sched.SchedLoadAvgSchedGroup,
                            column=['utilization'],
                            filters={"load": [1, 2]},
                            pivot="cpus",
                            marker='o',
                            linestyle='none',
                            per_line=3)
        l.view(test=True)
 def test_plot_multi_trace(self):
     """Tests LinePlot with no Pivot multi traces"""
     trace1 = trappy.FTrace(name="first")
     trace2 = trappy.FTrace(name="second")
     l = trappy.LinePlot(
         [trace1, trace2], trappy.thermal.Thermal, column="temp")
     l.view(test=True)
 def test_plot_multi_trace_pivot(self):
     """Tests LinePlot with Pivot multi traces"""
     trace1 = trappy.FTrace(name="first")
     trace2 = trappy.FTrace(name="second")
     l = trappy.LinePlot(
         [trace1, trace2], trappy.cpu_power.CpuOutPower, column="power", pivot="cpus")
     l.view(test=True)
Esempio n. 6
0
 def test_plot_filter(self):
     """Tests LinePlot with no Pivot with filters"""
     run1 = trappy.Run(name="first")
     run2 = trappy.Run(name="second")
     l = trappy.LinePlot([run1, run2], [trappy.cpu_power.CpuOutPower],
                         column=["power"],
                         filters={"cdev_state": [1]})
     l.view(test=True)
Esempio n. 7
0
 def test_plot_multi_run(self):
     """Tests LinePlot with no Pivot multi runs"""
     run1 = trappy.Run(name="first")
     run2 = trappy.Run(name="second")
     l = trappy.LinePlot([run1, run2],
                         trappy.thermal.Thermal,
                         column="temp")
     l.view(test=True)
Esempio n. 8
0
 def test_plot_pivot(self):
     """Tests LinePlot with Pivot"""
     trace1 = trappy.FTrace(name="first")
     l = trappy.LinePlot(trace1,
                         trappy.thermal.Thermal,
                         column="temp",
                         pivot="thermal_zone")
     l.view(test=True)
Esempio n. 9
0
    def test_dynamic_event_plot(self):
        """Test if plotter can accept a dynamic class
            for a template argument"""

        cls = trappy.register_dynamic("DynamicEvent", "dynamic_test_key")
        r = trappy.Run(name="first")
        l = trappy.LinePlot(r, cls, column="load")
        l.view(test=True)
Esempio n. 10
0
 def test_plot_filter(self):
     """Tests LinePlot with no Pivot with filters"""
     trace1 = trappy.FTrace(name="first")
     trace2 = trappy.FTrace(name="second")
     l = trappy.LinePlot([trace1, trace2], [trappy.cpu_power.CpuOutPower],
                         column=["power"],
                         filters={"cdev_state": [0]})
     l.view(test=True)
Esempio n. 11
0
 def test_plot_multi_run_pivot(self):
     """Tests LinePlot with Pivot multi runs"""
     run1 = trappy.Run(name="first")
     run2 = trappy.Run(name="second")
     l = trappy.LinePlot([run1, run2],
                         trappy.cpu_power.CpuOutPower,
                         column="power",
                         pivot="cpus")
     l.view(test=True)
    def test_signals_invalid(self):
        """Test that invalid signal defs result in a helpful errror"""
        trace = trappy.FTrace()

        with self.assertRaises(ValueError) as assertion:
            l = trappy.LinePlot(trace, signals=["INVALID_SIGNAL_DEF"])
        msg = str(assertion.exception)
        self.assertIn("Invalid signal definition", msg)
        self.assertIn("INVALID_SIGNAL_DEF", msg)
Esempio n. 13
0
 def test_plot_multi(self):
     """Tests LinePlot with no Pivot multi attrs"""
     trace1 = trappy.FTrace(name="first")
     trace2 = trappy.FTrace(name="second")
     l = trappy.LinePlot(
         [trace1, trace2],
         [trappy.thermal.Thermal, trappy.thermal.ThermalGovernor],
         column=["temp", "power_range"])
     l.view(test=True)
Esempio n. 14
0
 def test_plot_multi_pivot_filter(self):
     """Tests LinePlot with Pivot and filters"""
     trace1 = trappy.FTrace(name="first")
     trace2 = trappy.FTrace(name="second")
     l = trappy.LinePlot(trace1,
                         trappy.cpu_power.CpuInPower,
                         column=["dynamic_power", "load1"],
                         filters={"cdev_state": [1, 0]},
                         pivot="cpus")
     l.view(test=True)
Esempio n. 15
0
 def test_plot_multi_pivot(self):
     """Tests LinePlot with Pivot with multi attrs"""
     trace1 = trappy.FTrace(name="first")
     trace2 = trappy.FTrace(name="second")
     l = trappy.LinePlot(
         [trace1, trace2],
         [trappy.cpu_power.CpuInPower, trappy.cpu_power.CpuOutPower],
         column=["dynamic_power", "power"],
         pivot="cpus")
     l.view(test=True)
Esempio n. 16
0
    def test_signals(self):
        """Test signals input for LinePlot"""

        trace1 = trappy.FTrace(name="first")
        trace2 = trappy.FTrace(name="second")

        l = trappy.LinePlot(
            [trace1, trace2],
            signals=["cpu_in_power:dynamic_power", "cpu_out_power:power"],
            pivot="cpus")

        l.view(test=True)
Esempio n. 17
0
 def test_plot_savefig(self):
     """Tests plotter: savefig"""
     trace1 = trappy.FTrace(name="first")
     trace2 = trappy.FTrace(name="second")
     l = trappy.LinePlot(trace1,
                         trappy.cpu_power.CpuInPower,
                         column=["dynamic_power", "load1"],
                         filters={"cdev_state": [1, 0]},
                         pivot="cpus")
     png_file = tempfile.mktemp(dir="/tmp", suffix=".png")
     l.savefig(png_file)
     self.assertTrue(os.path.isfile(png_file))
     os.remove(png_file)
    def test_signals(self):
        """Test signals input for LinePlot"""

        trace1 = trappy.FTrace(name="first")
        trace2 = trappy.FTrace(name="second")

        l = trappy.LinePlot([trace1,
                          trace2],
                         signals=["cpu_in_power:dynamic_power",
                                 "cpu_out_power:power"],
                         pivot="cpus")

        self.assertTrue(isinstance(l.templates[0], type(trappy.cpu_power.CpuInPower)))
        self.assertEquals(l._attr["column"][0], "dynamic_power")
        self.assertTrue(l.templates[1], type(trappy.cpu_power.CpuOutPower))
        self.assertEquals(l._attr["column"][1], "power")
        self.assertTrue("colors" not in l._attr)

        # Check that plotting doesn't barf
        l.view(test=True)
 def test_lineplot_dataframe(self):
     """LinePlot plots DataFrames without exploding"""
     data = np.random.randn(4, 2)
     dfr = pd.DataFrame(data, columns=["tick", "tock"]).cumsum()
     trappy.LinePlot(dfr, column=["tick"]).view(test=True)
Esempio n. 20
0
 def test_plot_no_pivot(self):
     """Tests LinePlot with no pivot"""
     run1 = trappy.Run(name="first")
     l = trappy.LinePlot(run1, trappy.thermal.Thermal, column="temp")
     l.view(test=True)