From 1883a9a289597f787d9834157f502ebc9ba2f4d3 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Fri, 29 Jan 2016 10:18:10 +0000 Subject: [PATCH 1/3] libs/utils/env: add suppor to load test configuration from file At TestEnv initialisation, the target configuration can be specified either inline or as a JSON file to load. The test configuration is instead forced to be inlined. This patch align test configuration handling to target configuration. The required code to load the test configuration from a file is added and the test configuration is now tracked with the self.test_conf local variable. Signed-off-by: Patrick Bellasi --- libs/utils/env.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/libs/utils/env.py b/libs/utils/env.py index 06d465813..454c607b5 100644 --- a/libs/utils/env.py +++ b/libs/utils/env.py @@ -64,6 +64,7 @@ class TestEnv(ShareState): return self.conf = None + self.test_conf = None self.target = None self.ftrace = None self.workdir = WORKING_DIR_DEFAULT @@ -108,6 +109,21 @@ class TestEnv(ShareState): logging.debug('%14s - Target configuration %s', 'Target', self.conf) + # Setup test configuration + if isinstance(test_conf, dict): + logging.info('%14s - Loading custom (inline) test configuration', + 'Target') + self.test_conf = test_conf + elif isinstance(test_conf, str): + logging.info('%14s - Loading custom (file) test configuration', + 'Target') + self.test_conf = TestEnv.loadTargetConfig(test_conf) + else: + raise ValueError('test_conf must be either a dictionary or a filepath') + + logging.debug('%14s - Test configuration %s', 'Target', self.conf) + + # Setup target working directory if 'workdir' in self.conf: self.workdir = self.conf['workdir'] @@ -115,27 +131,29 @@ class TestEnv(ShareState): if 'tools' in self.conf: self.__tools = self.conf['tools'] # Merge tests specific tools - if test_conf and 'tools' in test_conf and test_conf['tools']: + if self.test_conf and 'tools' in self.test_conf and \ + self.test_conf['tools']: if 'tools' not in self.conf: self.conf['tools'] = [] self.__tools = list(set( - self.conf['tools'] + test_conf['tools'] + self.conf['tools'] + self.test_conf['tools'] )) # Initialize modules to use on the target if 'modules' in self.conf: self.__modules = self.conf['modules'] # Merge tests specific modules - if test_conf and 'modules' in test_conf and test_conf['modules']: + if self.test_conf and 'modules' in self.test_conf and \ + self.test_conf['modules']: if 'modules' not in self.conf: self.conf['modules'] = [] self.__modules = list(set( - self.conf['modules'] + test_conf['modules'] + self.conf['modules'] + self.test_conf['modules'] )) # Initialize ftrace events - if test_conf and 'ftrace' in test_conf: - self.conf['ftrace'] = test_conf['ftrace'] + if self.test_conf and 'ftrace' in self.test_conf: + self.conf['ftrace'] = self.test_conf['ftrace'] self.__tools.append('trace-cmd') # Add tools dependencies -- GitLab From 4e2673a38945e9c50caa8e2a684eb6a37015cb28 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Fri, 29 Jan 2016 10:27:45 +0000 Subject: [PATCH 2/3] libs/utils/env: move modules definition into board specific section The specification of devlib modules to load into the target and/or test configuration file is a not portable solution, especially when we need to run the same test on different boards which do not support the same set of modules, e.g. SMP platform does not support "bl" module. This patch update the modules configuration by moving their definition into the specific board configuration section of the TestEnv intialization code. Each board can now list the *complete* list of modules which are supported and only these will be initialized. Still the target and test specific configuration file allows to add additional modules eventually not loaded by a specific board configuration. The list of modules being loaded is now clearly reported as a log message. Signed-off-by: Patrick Bellasi --- libs/utils/env.py | 52 ++++++++++++++++++++++++++++---------- target.config | 2 +- tests/eas/rfc_eas.config | 2 +- tests/eas/rfc_sfreq.config | 3 +-- tests/eas/rfc_stune.config | 2 +- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/libs/utils/env.py b/libs/utils/env.py index 454c607b5..e270fa26b 100644 --- a/libs/utils/env.py +++ b/libs/utils/env.py @@ -139,18 +139,6 @@ class TestEnv(ShareState): self.conf['tools'] + self.test_conf['tools'] )) - # Initialize modules to use on the target - if 'modules' in self.conf: - self.__modules = self.conf['modules'] - # Merge tests specific modules - if self.test_conf and 'modules' in self.test_conf and \ - self.test_conf['modules']: - if 'modules' not in self.conf: - self.conf['modules'] = [] - self.__modules = list(set( - self.conf['modules'] + self.test_conf['modules'] - )) - # Initialize ftrace events if self.test_conf and 'ftrace' in self.test_conf: self.conf['ftrace'] = self.test_conf['ftrace'] @@ -296,19 +284,57 @@ class TestEnv(ShareState): except KeyError: raise ValueError('Config error: missing [platform] parameter') + + ######################################################################## + # Board configuration + ######################################################################## + # Setup board default if not specified by configuration if 'board' not in self.conf: self.conf['board'] = 'UNKNOWN' - # Initialize a specific board (if known) + # Initialize TC2 board if self.conf['board'].upper() == 'TC2': platform = devlib.platform.arm.TC2() + self.__modules = ['bl', 'hwmon', 'cpufreq'] + + # Initialize JUNO board elif self.conf['board'].upper() == 'JUNO': platform = devlib.platform.arm.Juno() + self.__modules = ['bl', 'hwmon', 'cpufreq'] + + # Initialize OAK board elif self.conf['board'].upper() == 'OAK': platform = Platform(model='MT8173') + self.__modules = ['bl', 'cpufreq'] + + # Initialize default UNKNOWN board else: platform = None + self.__modules = [] + + ######################################################################## + # Modules configuration + ######################################################################## + + # Rinfine modules list based on target.conf options + if 'modules' in self.conf: + self.__modules = list(set( + self.__modules + self.conf['modules'] + )) + # Merge tests specific modules + if self.test_conf and 'modules' in self.test_conf and \ + self.test_conf['modules']: + self.__modules = list(set( + self.__modules + self.test_conf['modules'] + )) + + logging.info(r'%14s - Devlib modules to load: %s', + 'Target', self.__modules) + + ######################################################################## + # Devlib target setup (based on target.config::platform) + ######################################################################## # If the target is Android, we need just (eventually) the device if platform_type.lower() == 'android': diff --git a/target.config b/target.config index 06d3fbf56..6aa8bbd79 100644 --- a/target.config +++ b/target.config @@ -43,7 +43,7 @@ }, /* Devlib modules to enabled for all the experiments */ - "modules" : [ "bl" ], + "modules" : [], /* Binary tools to install by default for all experiments */ "tools" : [], diff --git a/tests/eas/rfc_eas.config b/tests/eas/rfc_eas.config index b24467deb..3ef601162 100644 --- a/tests/eas/rfc_eas.config +++ b/tests/eas/rfc_eas.config @@ -1,6 +1,6 @@ { /* Devlib modules required by the experiments */ - "modules" : ["cpufreq", "hwmon", "bl"], + "modules" : [ "cpufreq" ], /* Binary tools required by the experiments */ "tools" : ["rt-app"], diff --git a/tests/eas/rfc_sfreq.config b/tests/eas/rfc_sfreq.config index d3bc88001..05e69937c 100644 --- a/tests/eas/rfc_sfreq.config +++ b/tests/eas/rfc_sfreq.config @@ -1,7 +1,6 @@ { /* Devlib modules required by the experiments */ - /* "modules" : ["cpufreq", "hwmon", "bl"], */ - "modules" : ["cpufreq", "hwmon", "bl"], + "modules" : [ "cpufreq" ], /* Binary tools required by the experiments */ "tools" : ["rt-app"], diff --git a/tests/eas/rfc_stune.config b/tests/eas/rfc_stune.config index 8bee84125..13615b72b 100644 --- a/tests/eas/rfc_stune.config +++ b/tests/eas/rfc_stune.config @@ -1,6 +1,6 @@ { /* Devlib modules required by the experiments */ - "modules" : ["cpufreq", "hwmon", "bl", "cgroups"], + "modules" : [ "cpufreq" ], /* Binary tools required by the experiments */ "tools" : ["rt-app"], -- GitLab From 62152a55282d427b36f419d60bea590d33175096 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Fri, 29 Jan 2016 10:31:37 +0000 Subject: [PATCH 3/3] libs/utils/env: add support to exlude a list of modules Boards defined a *complete* list of supported modules. However, sometimes for a specific experiment we do not need all of them. This patch adds the required support to specify, either in the target or test specific configuration files, a list of devlib modules which we do not want to be loaded. This allows for example to avoid loading "hwmon" on JUNO/TC2 in case we are not interested in energy measurements. Signed-off-by: Patrick Bellasi --- libs/utils/env.py | 11 +++++++++++ target.config | 3 ++- tests/eas/rfc_eas.config | 3 ++- tests/eas/rfc_sfreq.config | 3 ++- tests/eas/rfc_stune.config | 3 ++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/libs/utils/env.py b/libs/utils/env.py index e270fa26b..9684a3d35 100644 --- a/libs/utils/env.py +++ b/libs/utils/env.py @@ -329,6 +329,17 @@ class TestEnv(ShareState): self.__modules + self.test_conf['modules'] )) + # Initialize modules to exclude on the target + if 'exclude_modules' in self.conf: + for module in self.conf['exclude_modules']: + if module in self.__modules: + self.__modules.remove(module) + # Remove tests specific modules + if self.test_conf and 'exclude_modules' in self.test_conf: + for module in self.test_conf['exclude_modules']: + if module in self.__modules: + self.__modules.remove(module) + logging.info(r'%14s - Devlib modules to load: %s', 'Target', self.__modules) diff --git a/target.config b/target.config index 6aa8bbd79..ade4bd746 100644 --- a/target.config +++ b/target.config @@ -42,8 +42,9 @@ "dtb" : "dtb.bin" }, - /* Devlib modules to enabled for all the experiments */ + /* Devlib modules to enable/disbale for all the experiments */ "modules" : [], + "exclude_modules" : [], /* Binary tools to install by default for all experiments */ "tools" : [], diff --git a/tests/eas/rfc_eas.config b/tests/eas/rfc_eas.config index 3ef601162..70f8410c0 100644 --- a/tests/eas/rfc_eas.config +++ b/tests/eas/rfc_eas.config @@ -1,6 +1,7 @@ { - /* Devlib modules required by the experiments */ + /* Devlib modules to enable/disbale for all the experiments */ "modules" : [ "cpufreq" ], + "exclude_modules" : [ ], /* Binary tools required by the experiments */ "tools" : ["rt-app"], diff --git a/tests/eas/rfc_sfreq.config b/tests/eas/rfc_sfreq.config index 05e69937c..7a9d51bf4 100644 --- a/tests/eas/rfc_sfreq.config +++ b/tests/eas/rfc_sfreq.config @@ -1,6 +1,7 @@ { - /* Devlib modules required by the experiments */ + /* Devlib modules to enable/disbale for all the experiments */ "modules" : [ "cpufreq" ], + "exclude_modules" : [ ], /* Binary tools required by the experiments */ "tools" : ["rt-app"], diff --git a/tests/eas/rfc_stune.config b/tests/eas/rfc_stune.config index 13615b72b..6c6075ab8 100644 --- a/tests/eas/rfc_stune.config +++ b/tests/eas/rfc_stune.config @@ -1,6 +1,7 @@ { - /* Devlib modules required by the experiments */ + /* Devlib modules to enable/disbale for all the experiments */ "modules" : [ "cpufreq" ], + "exclude_modules" : [ ], /* Binary tools required by the experiments */ "tools" : ["rt-app"], -- GitLab