aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test_plotter.py10
-rw-r--r--trappy/plotter/AbstractDataPlotter.py5
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_plotter.py b/tests/test_plotter.py
index 6a9a9f0..dae91c4 100644
--- a/tests/test_plotter.py
+++ b/tests/test_plotter.py
@@ -193,6 +193,16 @@ class TestPlotter(BaseTestThermal):
"cpu_out_power:power"],
pivot="cpus")
+ 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)
+
def test_signals_colors(self):
"""Test signals with colors in LinePlot"""
diff --git a/trappy/plotter/AbstractDataPlotter.py b/trappy/plotter/AbstractDataPlotter.py
index e4891d8..254709c 100644
--- a/trappy/plotter/AbstractDataPlotter.py
+++ b/trappy/plotter/AbstractDataPlotter.py
@@ -76,6 +76,11 @@ class AbstractDataPlotter(object):
match = re.match(r"(?P<event>[^:]+):(?P<column>[^:]+)(?P<color>:.+)?",
signal_def)
+ if not match:
+ raise ValueError(
+ 'Invalid signal definition "{}". '
+ 'Should have the form "trace_class:column" '
+ 'e.g. "cpu_frequency:frequency"'.format(signal_def))
event = match.group("event")
column = match.group("column")
color_match = match.group("color")