diff --git a/libs/utils/env.py b/libs/utils/env.py index 06d465813710dbd40e61cdebeafc3731982c4f87..9684a3d3527f35c764f10033d2c12d64cefd6d49 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,17 @@ 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'] - )) - - # 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 'modules' not in self.conf: - self.conf['modules'] = [] - self.__modules = list(set( - self.conf['modules'] + test_conf['modules'] + self.conf['tools'] + self.test_conf['tools'] )) # 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 @@ -278,19 +284,68 @@ 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'] + )) + + # 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) + + ######################################################################## + # 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 06d3fbf5620dd9c5dea2754ddb7f572215cdcd6a..ade4bd746a10a546f4db3d195a7444c6e3d9de88 100644 --- a/target.config +++ b/target.config @@ -42,8 +42,9 @@ "dtb" : "dtb.bin" }, - /* Devlib modules to enabled for all the experiments */ - "modules" : [ "bl" ], + /* 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 b24467deb82f6afd4304d23647039f03e3a490fc..70f8410c0014556c24188d4240389d985efa12c6 100644 --- a/tests/eas/rfc_eas.config +++ b/tests/eas/rfc_eas.config @@ -1,6 +1,7 @@ { - /* Devlib modules required by the experiments */ - "modules" : ["cpufreq", "hwmon", "bl"], + /* 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 d3bc8800104a43282d148cb6b031ce3eb874434e..7a9d51bf459b1b301b373ff03c85dffd5bc76931 100644 --- a/tests/eas/rfc_sfreq.config +++ b/tests/eas/rfc_sfreq.config @@ -1,7 +1,7 @@ { - /* Devlib modules required by the experiments */ - /* "modules" : ["cpufreq", "hwmon", "bl"], */ - "modules" : ["cpufreq", "hwmon", "bl"], + /* 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 8bee84125fe618e73a8bea4dc89b88b41b8a457d..6c6075ab80bf523824be6ef50bf7c46d0aa31164 100644 --- a/tests/eas/rfc_stune.config +++ b/tests/eas/rfc_stune.config @@ -1,6 +1,7 @@ { - /* Devlib modules required by the experiments */ - "modules" : ["cpufreq", "hwmon", "bl", "cgroups"], + /* Devlib modules to enable/disbale for all the experiments */ + "modules" : [ "cpufreq" ], + "exclude_modules" : [ ], /* Binary tools required by the experiments */ "tools" : ["rt-app"],