diff options
-rw-r--r-- | tests/test_caching.py | 22 | ||||
-rw-r--r-- | tests/test_ftrace.py | 20 | ||||
-rw-r--r-- | tests/test_systrace.py | 10 | ||||
-rw-r--r-- | trappy/bare_trace.py | 2 | ||||
-rw-r--r-- | trappy/ftrace.py | 4 |
5 files changed, 55 insertions, 3 deletions
diff --git a/tests/test_caching.py b/tests/test_caching.py index d0893b7..9fcd33a 100644 --- a/tests/test_caching.py +++ b/tests/test_caching.py @@ -191,3 +191,25 @@ class TestCaching(utils_tests.SetupDirectory): window=(0, None)) self.assertEqual(len(trace1.sched_wakeup.data_frame), 2) + + def test_cache_delete_single(self): + GenericFTrace.disable_cache = False + trace = trappy.FTrace() + + trace_path = os.path.abspath(trace.trace_path) + trace_dir = os.path.dirname(trace_path) + trace_file = os.path.basename(trace_path) + cache_dir = '.' + trace_file + '.cache' + self.assertEquals(len(os.listdir(cache_dir)), 22) + + os.remove(os.path.join(cache_dir, 'SchedWakeup.csv')) + self.assertEquals(len(os.listdir(cache_dir)), 21) + + # Generate trace again, should regenerate only the missing item + trace = trappy.FTrace() + self.assertEquals(len(os.listdir(cache_dir)), 22) + for c in trace.trace_classes: + if isinstance(c, trace.class_definitions['sched_wakeup']): + self.assertEquals(c.cached, False) + continue + self.assertEquals(c.cached, True) diff --git a/tests/test_ftrace.py b/tests/test_ftrace.py index f07813c..ea702e5 100644 --- a/tests/test_ftrace.py +++ b/tests/test_ftrace.py @@ -367,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") diff --git a/tests/test_systrace.py b/tests/test_systrace.py index 667bf2c..5f8899b 100644 --- a/tests/test_systrace.py +++ b/tests/test_systrace.py @@ -93,6 +93,16 @@ class TestSystrace(utils_tests.SetupDirectory): self.assertEquals(dfr['__line'].iloc[1], 6) self.assertEquals(dfr['__line'].iloc[-1], 2505) + def test_parse_tracing_mark_write_events(self): + """Check that tracing_mark_write events are parsed without errors""" + events = ['tracing_mark_write'] + try: + trace = trappy.SysTrace("trace.html", events=events) + except TypeError as e: + self.fail("tracing_mark_write parsing failed with {} exception"\ + .format(e.message)) + + class TestLegacySystrace(utils_tests.SetupDirectory): def __init__(self, *args, **kwargs): diff --git a/trappy/bare_trace.py b/trappy/bare_trace.py index 93a1c6b..c2f4b04 100644 --- a/trappy/bare_trace.py +++ b/trappy/bare_trace.py @@ -140,5 +140,5 @@ class BareTrace(object): trace_class.create_dataframe() trace_class.finalize_object() - def generate_data_dict(self): + def generate_data_dict(self, data_str): return None diff --git a/trappy/ftrace.py b/trappy/ftrace.py index 226cd96..7d23432 100644 --- a/trappy/ftrace.py +++ b/trappy/ftrace.py @@ -66,7 +66,7 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace.""" dynamic_classes = {} - disable_cache = False + disable_cache = True def _trace_cache_path(self): trace_file = self.trace_path @@ -216,7 +216,7 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace.""" if not self.__class__.disable_cache: try: # Recreate basic cache directories only if nothing cached - if not all([c.cached for c in self.trace_classes]): + if not any([c.cached for c in self.trace_classes]): self._create_trace_cache(params) # Write out only events that weren't cached before |