From 8a253f227ad6b1c8a2076913d30f5ed01ac92abd Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Mon, 7 Aug 2017 11:48:35 +0100 Subject: bare_trace: fix signature of generate_data_dict Classes that implement the generate_data_dict method have an additional argument to the signature. This leads to errors in case the base class method is called with the additional argument. This patch also adds two tests for FTrace and SysTrace parsing. --- tests/test_ftrace.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/test_ftrace.py') diff --git a/tests/test_ftrace.py b/tests/test_ftrace.py index e6f6319..fbc761d 100644 --- a/tests/test_ftrace.py +++ b/tests/test_ftrace.py @@ -351,6 +351,26 @@ class TestFTrace(BaseTestThermal): self.assertEquals(trace.thermal.data_frame.iloc[0]["temp"], 68989) self.assertEquals(trace.thermal.data_frame.iloc[-1]["temp"], 69530) + def test_parse_tracing_mark_write_events(self): + """Check that tracing_mark_write events are parsed without errors""" + + in_data = """ sh-1379 [002] 353.397813: print: tracing_mark_write: TRACE_MARKER_START + shutils-1381 [001] 353.680439: print: tracing_mark_write: cpu_frequency: state=450000 cpu_id=5""" + + with open("trace.txt", "w") as fout: + fout.write(in_data) + + try: + trace = trappy.FTrace() + except TypeError as e: + self.fail("tracing_mark_write parsing failed with {} exception"\ + .format(e.message)) + # The second event is recognised as a cpu_frequency event and therefore + # put under trace.cpu_frequency + self.assertEquals(trace.tracing_mark_write.data_frame.iloc[-1]["string"], + "TRACE_MARKER_START") + self.assertEquals(len(trace.tracing_mark_write.data_frame), 1) + @unittest.skipUnless(utils_tests.trace_cmd_installed(), "trace-cmd not installed") -- cgit v1.2.3 From 581f936a426783d289b0b0ff4e9dfafa874dcddd Mon Sep 17 00:00:00 2001 From: Valentin Schneider Date: Mon, 18 Sep 2017 12:36:58 +0100 Subject: tests/test_ftrace: Add window duration tests --- tests/test_ftrace.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/test_ftrace.py') diff --git a/tests/test_ftrace.py b/tests/test_ftrace.py index e6f6319..f07813c 100644 --- a/tests/test_ftrace.py +++ b/tests/test_ftrace.py @@ -170,6 +170,22 @@ class TestFTrace(BaseTestThermal): self.assertEqual(trace.get_duration(), duration) + def test_ftrace_duration_window(self): + """Test that duration is correct with time window (normalize_time=True)""" + trace = trappy.FTrace(normalize_time=True, window=[1, 5]) + + duration = trace.thermal_governor.data_frame.index[-1] - trace.thermal.data_frame.index[0] + + self.assertEqual(trace.get_duration(), duration) + + def test_ftrace_duration_window_not_normalized(self): + """Test that duration is correct with time window (normalize_time=False)""" + trace = trappy.FTrace(normalize_time=False, window=[1, 5]) + + duration = trace.thermal_governor.data_frame.index[-1] - trace.thermal.data_frame.index[0] + + self.assertEqual(trace.get_duration(), duration) + def test_ftrace_duration_not_normalized(self): """Test get_duration: normalize_time=True""" -- cgit v1.2.3