aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrendan Jackman <brendan.jackman@arm.com>2017-01-05 12:24:13 +0000
committerBrendan Jackman <brendan.jackman@arm.com>2017-01-10 13:00:14 +0000
commitfbbbd40195803d95fb4f2a2d704f3a93118c8342 (patch)
tree1f4e7b2c885b0adb6b5bdd42d1e88aa379ad9ed7 /tests
parent5d488a4f480e12e9276cf8ded997eefd30bb3c94 (diff)
downloadtrappy-fbbbd40195803d95fb4f2a2d704f3a93118c8342.tar.gz
stats/grammar: Raise helpful error when asked to parse absent events
If you use the Parser to access events that Trappy understands, but that are not present in the trace, you currently get an inscrutable exception when trying to access `.loc[ self._window[0]:]` on the empty DataFrame in _get_data_frame. Ideally attempting to parse absent events would just return an empty DataFrame, but then we don't know what columns it should have. So instead let's just raise a more helpful error saying that the event is not present.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stats_grammar.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_stats_grammar.py b/tests/test_stats_grammar.py
index de62f21..5138efc 100644
--- a/tests/test_stats_grammar.py
+++ b/tests/test_stats_grammar.py
@@ -244,3 +244,13 @@ trappy.thermal.Thermal:temp"
prs = Parser(trace, filters={"cdev_state": 3})
dfr_res = prs.solve("devfreq_out_power:freq")
self.assertEquals(len(dfr_res), 1)
+
+ def test_no_events(self):
+ """Test trying to parse absent data"""
+ trace = trappy.FTrace()
+ prs = Parser(trace)
+
+ # cpu_frequency is an event we know how to parse, but it isn't present
+ # in the test trace.
+ self.assertRaisesRegexp(ValueError, "No events found for cpu_frequency",
+ prs.solve, "cpu_frequency:frequency")