diff options
author | KP Singh <kpsingh@google.com> | 2017-07-14 11:26:51 +0200 |
---|---|---|
committer | KP Singh <kpsingh@google.com> | 2017-07-14 11:26:51 +0200 |
commit | e8632f13fa589b95e6c7bd0999fda99efc3f1b73 (patch) | |
tree | 75b65904ba32eb654aeb2f221eaf249d7d0d187c | |
parent | 46660d432e6ecb68dec8ff38180d93ba4e6ec7f0 (diff) | |
parent | 96f1148d408ef63a47db70eb97739189dce27f9f (diff) | |
download | trappy-e8632f13fa589b95e6c7bd0999fda99efc3f1b73.tar.gz |
Merge branch 'joelagnel-cache-corrupt-fix'
-rw-r--r-- | tests/test_caching.py | 22 | ||||
-rw-r--r-- | trappy/ftrace.py | 2 |
2 files changed, 23 insertions, 1 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/trappy/ftrace.py b/trappy/ftrace.py index 226cd96..2737086 100644 --- a/trappy/ftrace.py +++ b/trappy/ftrace.py @@ -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 |