diff options
author | Xin Li <delphij@google.com> | 2018-08-06 16:50:46 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2018-08-06 16:50:46 -0700 |
commit | da847891e1c9cd36d37a1f975e3b4b847d9c8d40 (patch) | |
tree | 2ee6dc8fe789340553a66e15d20aa4d7b8dee2a8 /tests/test_ftrace.py | |
parent | 31ccc081929e27f780a87a94deb20e4333c6b323 (diff) | |
parent | beecbc049b8ea9340930186d6936cd63557646a3 (diff) | |
download | trappy-da847891e1c9cd36d37a1f975e3b4b847d9c8d40.tar.gz |
Merge Android Pie into masterandroid-o-mr1-iot-release-smart-display-r3android-o-mr1-iot-release-1.0.5android-o-mr1-iot-release-1.0.4android-o-mr1-iot-release-1.0.3oreo-mr1-1.2-iot-releasemaster-cuttlefish-testing-release
Bug: 112104996
Change-Id: Icb7cf76bc97e423a4cff040b8a2800c679e6cb51
Diffstat (limited to 'tests/test_ftrace.py')
-rw-r--r-- | tests/test_ftrace.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_ftrace.py b/tests/test_ftrace.py index e6f6319..ea702e5 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""" @@ -351,6 +367,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") |