From 155b36fc5e9d6150b184cf4f50340e7f108ede32 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Tue, 10 Apr 2018 11:42:37 +0100 Subject: [PATCH 1/2] env.py: Simplify some logic Simplify some configuration merging logic. --- libs/utils/env.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/libs/utils/env.py b/libs/utils/env.py index 8eb826d7e..c0879b375 100644 --- a/libs/utils/env.py +++ b/libs/utils/env.py @@ -709,25 +709,13 @@ class TestEnv(ShareState): if not force and self.ftrace is not None: return self.ftrace - if conf is None and 'ftrace' not in self.conf: - return None - - if conf is not None: - ftrace = conf - else: - ftrace = self.conf['ftrace'] - - events = FTRACE_EVENTS_DEFAULT - if 'events' in ftrace: - events = ftrace['events'] - - functions = None - if 'functions' in ftrace: - functions = ftrace['functions'] + ftrace = conf or self.conf.get('ftrace') + if ftrace is None: + return - buffsize = FTRACE_BUFSIZE_DEFAULT - if 'buffsize' in ftrace: - buffsize = ftrace['buffsize'] + events = ftrace.get('events', FTRACE_EVENTS_DEFAULT) + functions = ftrace.get('functions', None) + buffsize = ftrace.get('buffsize', FTRACE_BUFSIZE_DEFAULT) self.ftrace = devlib.FtraceCollector( self.target, -- GitLab From e110e7d2a7c40a09e70a0140fe5fdab305de46c6 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Tue, 10 Apr 2018 11:45:19 +0100 Subject: [PATCH 2/2] env.py: Add debug_events key to target.config Add new key "ftrace" to target config. The format is the same as tests' ftrace key. The only supported key for now is "events" to allow adding extra events to collect, in addition to the mandatory ones specified in tests configuration. This is to support investigations of tests failures. Co-authored-by: Elieva Pignat --- libs/utils/env.py | 21 +++++++++++++++++---- target.config | 5 +++++ tests/lisa/test_executor.py | 4 ++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/libs/utils/env.py b/libs/utils/env.py index c0879b375..a357d7115 100644 --- a/libs/utils/env.py +++ b/libs/utils/env.py @@ -109,9 +109,11 @@ class TestEnv(ShareState): Directory path containing kernels and DTB images for the target. LISA does *not* manage this TFTP server, it must be provided externally. Optional. - **results_dir** location of results of the experiments. + **ftrace** + Ftrace configuration merged with test-specific configuration. + Currently, only additional events through "events" key is supported. :param test_conf: Configuration of software for target experiments. Takes the same form as target_conf. Fields are: @@ -265,9 +267,16 @@ class TestEnv(ShareState): # Initialize ftrace events # test configuration override target one - if 'ftrace' in self.test_conf: - self.conf['ftrace'] = self.test_conf['ftrace'] - if self.conf.get('ftrace'): + test_ftrace = self.test_conf.get('ftrace', {}) + target_ftrace = self.conf.get('ftrace', {}) + ftrace = test_ftrace or target_ftrace + # Merge the events from target config and test config + ftrace['events'] = sorted( + set(test_ftrace.get('events', [])) + | set(target_ftrace.get('events', [])) + ) + self.conf['ftrace'] = ftrace + if ftrace['events']: self.__tools.append('trace-cmd') # Initialize features @@ -717,6 +726,10 @@ class TestEnv(ShareState): functions = ftrace.get('functions', None) buffsize = ftrace.get('buffsize', FTRACE_BUFSIZE_DEFAULT) + # If no events are specified, do not create the FtraceCollector + if not events: + return + self.ftrace = devlib.FtraceCollector( self.target, events = events, diff --git a/target.config b/target.config index b9ab29377..770b15e49 100644 --- a/target.config +++ b/target.config @@ -41,6 +41,11 @@ "rtapp-calib" : { "0": 302, "1": 302, "2": 302, "3": 302, "4": 136, "5": 136, "6": 136, "7": 136 }, + + /* Additional ftrace events collected regardless of the test configuration */ + "ftrace": { + "events": [] + }, /* FTFP Image server */ /* This is the folder from where the target gets kernel/DTB */ diff --git a/tests/lisa/test_executor.py b/tests/lisa/test_executor.py index 0745d4b64..6502521e1 100644 --- a/tests/lisa/test_executor.py +++ b/tests/lisa/test_executor.py @@ -40,6 +40,10 @@ class SetUpTarget(TestCase): test_conf={ # Don't load cpufreq, it won't work when platform=host 'exclude_modules': ['cpufreq'], + # Empty list of events to avoid getting the default ones + 'ftrace': { + 'events': [] + } }, force_new=True) -- GitLab