Example #1
0
    def reboot(self, reboot_time=120, ping_time=15):
        # Send remote target a reboot command
        if self._feature('no-reboot'):
            logging.warning('%14s - Reboot disabled by conf features', 'Reboot')
        else:
            if 'reboot_time' in self.conf:
                reboot_time = int(self.conf['reboot_time'])

            if 'ping_time' in self.conf:
                ping_time = int(self.conf['ping_time'])

            # Before rebooting make sure to have IP and MAC addresses
            # of the target
            (self.mac, self.ip) = self.parse_arp_cache(self.ip)

            self.target.execute('sleep 2 && reboot -f &', as_root=True)

            # Wait for the target to complete the reboot
            logging.info('%14s - Waiting up to %s[s] for target [%s] to reboot...',
                    'Reboot', reboot_time, self.ip)

            ping_cmd = "ping -c 1 {} >/dev/null".format(self.ip)
            elapsed = 0
            start = time.time()
            while elapsed <= reboot_time:
                time.sleep(ping_time)
                logging.debug('%14s - Trying to connect to [%s] target...',
                        'Reboot', self.ip)
                if os.system(ping_cmd) == 0:
                    break
                elapsed = time.time() - start
            if elapsed > reboot_time:
                if self.mac:
                    logging.warning('%14s - target [%s] not responding to \
                            PINGs, trying to resolve MAC address...', 'Reboot', self.ip)
                    (self.mac, self.ip) = self.resolv_host(self.mac)
                else:
                    logging.warning('%14s - target [%s] not responding to PINGs, trying to continue...',
                        'Reboot', self.ip)

        # Force re-initialization of all the devlib modules
        force = True

        # Reset the connection to the target
        self._init(force)

        # Initialize FTrace events collection
        self._init_ftrace(force)

        # Initialize energy probe instrument
        self.emeter = EnergyMeter.getInstance(self.target, self.conf, force)
Example #2
0
File: env.py Project: BayLibre/lisa
    def reboot(self, reboot_time=120, ping_time=15):
        # Send remote target a reboot command
        if self._feature('no-reboot'):
            logging.warning('%14s - Reboot disabled by conf features', 'Reboot')
        else:
            if 'reboot_time' in self.conf:
                reboot_time = int(self.conf['reboot_time'])

            if 'ping_time' in self.conf:
                ping_time = int(self.conf['ping_time'])

            # Before rebooting make sure to have IP and MAC addresses
            # of the target
            (self.mac, self.ip) = self.parse_arp_cache(self.ip)

            self.target.execute('sleep 2 && reboot -f &', as_root=True)

            # Wait for the target to complete the reboot
            logging.info('%14s - Waiting up to %s[s] for target [%s] to reboot...',
                    'Reboot', reboot_time, self.ip)

            ping_cmd = "ping -c 1 {} >/dev/null".format(self.ip)
            elapsed = 0
            start = time.time()
            while elapsed <= reboot_time:
                time.sleep(ping_time)
                logging.debug('%14s - Trying to connect to [%s] target...',
                        'Reboot', self.ip)
                if os.system(ping_cmd) == 0:
                    break
                elapsed = time.time() - start
            if elapsed > reboot_time:
                if self.mac:
                    logging.warning('%14s - target [%s] not responding to \
                            PINGs, trying to resolve MAC address...', 'Reboot', self.ip)
                    (self.mac, self.ip) = self.resolv_host(self.mac)
                else:
                    logging.warning('%14s - target [%s] not responding to PINGs, trying to continue...',
                        'Reboot', self.ip)

        # Force re-initialization of all the devlib modules
        force = True

        # Reset the connection to the target
        self._init(force)

        # Initialize FTrace events collection
        self._init_ftrace(force)

        # Initialize energy probe instrument
        self.emeter = EnergyMeter.getInstance(self.target, self.conf, force)
Example #3
0
File: env.py Project: deggeman/lisa
    def reboot(self, reboot_time=60):
        # Send remote target a reboot command
        if self._feature('no-reboot'):
            logging.warning('%14s - Reboot disabled by conf features', 'Reboot')
        else:
            self.target.execute('sleep 2 && reboot -f &', as_root=True)

            # Wait for the target to complete the reboot
            logging.info('%14s - Waiting %s [s]for target to reboot...',
                    'Reboot', reboot_time)
            time.sleep(reboot_time)

        # Force re-initialization of all the devlib modules
        force = True

        # Reset the connection to the target
        self._init(force)

        # Initialize FTrace events collection
        self._init_ftrace(force)

        # Initialize energy probe instrument
        self.emeter = EnergyMeter.getInstance(self.target, self.conf, force)
Example #4
0
    def reboot(self, reboot_time=60):
        # Send remote target a reboot command
        if self._feature('no-reboot'):
            logging.warning('%14s - Reboot disabled by conf features',
                            'Reboot')
        else:
            self.target.execute('sleep 2 && reboot -f &', as_root=True)

            # Wait for the target to complete the reboot
            logging.info('%14s - Waiting %s [s]for target to reboot...',
                         'Reboot', reboot_time)
            time.sleep(reboot_time)

        # Force re-initialization of all the devlib modules
        force = True

        # Reset the connection to the target
        self._init(force)

        # Initialize FTrace events collection
        self._init_ftrace(force)

        # Initialize energy probe instrument
        self.emeter = EnergyMeter.getInstance(self.target, self.conf, force)
Example #5
0
    def _init_energy(self, force):

        # Initialize energy probe to board default
        self.emeter = EnergyMeter.getInstance(self.target, self.conf, force,
                                              self.res_dir)
Example #6
0
    def _init_energy(self, force):

        # Initialize energy probe to board default
        self.emeter = EnergyMeter.getInstance(self.target, self.conf, force,
                                              self.res_dir)
Example #7
0
    def __init__(self, target_conf=None, test_conf=None, wipe=True):
        """
        Initialize the LISA test environment.

        The test environment is defined by:
        - a target configuration (target_conf) defining which HW platform we
        want to use to run the experiments
        - a test configuration (test_conf) defining which SW setups we need on
        that HW target
        - a folder to collect the experiments results, which can be specified
        using the test_conf::results_dir option and is by default wiped from
        all the previous contents (if wipe=True)

        :param target_conf: the HW target we want to use
        :type target_conf: dict

        :param test_conf: the SW setup of the HW target in use
        :type test_conf: dict

        :param wipe: set true to cleanup all previous content from the output
        folder
        :type wipe: bool
        """
        super(TestEnv, self).__init__()

        if self._initialized:
            return

        self.conf = None
        self.test_conf = None
        self.res_dir = None
        self.target = None
        self.ftrace = None
        self.workdir = WORKING_DIR_DEFAULT
        self.__tools = []
        self.__modules = []
        self.__connection_settings = None
        self._calib = None

        # Keep track of target IP and MAC address
        self.ip = None
        self.mac = None

        # Keep track of last installed kernel
        self.kernel = None
        self.dtb = None

        # Energy meter configuration
        self.emeter = None

        # The platform descriptor to be saved into the results folder
        self.platform = {}

        # Compute base installation path
        logging.info('%14s - Using base path: %s',
                'Target', basepath)

        # Setup target configuration
        if isinstance(target_conf, dict):
            logging.info('%14s - Loading custom (inline) target configuration',
                    'Target')
            self.conf = target_conf
        elif isinstance(target_conf, str):
            logging.info('%14s - Loading custom (file) target configuration',
                    'Target')
            self.conf = TestEnv.loadTargetConfig(target_conf)
        elif target_conf is None:
            logging.info('%14s - Loading default (file) target configuration',
                    'Target')
            self.conf = TestEnv.loadTargetConfig()
        logging.debug('%14s - Target configuration %s', 'Target', self.conf)

        # Setup test configuration
        if test_conf:
            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']

        # Initialize binary tools to deploy
        if 'tools' in self.conf:
            self.__tools = self.conf['tools']
        # Merge tests specific 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'] + self.test_conf['tools']
            ))

        # Initialize ftrace events
        # test configuration override target one
        if self.test_conf and 'ftrace' in self.test_conf:
            self.conf['ftrace'] = self.test_conf['ftrace']
        if 'ftrace' in self.conf and self.conf['ftrace']:
            self.__tools.append('trace-cmd')

        # Add tools dependencies
        if 'rt-app' in self.__tools:
            self.__tools.append('taskset')
            self.__tools.append('trace-cmd')
            self.__tools.append('perf')
            self.__tools.append('cgroup_run_into.sh')
        # Sanitize list of dependencies to remove duplicates
        self.__tools = list(set(self.__tools))

        # Initialize features
        if '__features__' not in self.conf:
            self.conf['__features__'] = []

        self._init()

        # Initialize FTrace events collection
        self._init_ftrace(True)

        # Initialize energy probe instrument
        self.emeter = EnergyMeter.getInstance(
                self.target, self.conf, force=True)

        # Initialize RT-App calibration values
        self.calibration()

        # Initialize local results folder
        # test configuration override target one
        if self.test_conf and 'results_dir' in self.test_conf:
            self.res_dir = self.test_conf['results_dir']
        if not self.res_dir and 'results_dir' in self.conf:
            self.res_dir = self.conf['results_dir']
        if self.res_dir and not os.path.isabs(self.res_dir):
                self.res_dir = os.path.join(basepath, 'results', self.res_dir)
        else:
            self.res_dir = os.path.join(basepath, OUT_PREFIX)
            self.res_dir = datetime.datetime.now()\
                            .strftime(self.res_dir + '/%Y%m%d_%H%M%S')
        if wipe and os.path.exists(self.res_dir):
            logging.warning('%14s - Wipe previous contents of the results folder:', 'TestEnv')
            logging.warning('%14s -    %s', 'TestEnv', self.res_dir)
            shutil.rmtree(self.res_dir, ignore_errors=True)
        if not os.path.exists(self.res_dir):
            os.makedirs(self.res_dir)

        res_lnk = os.path.join(basepath, LATEST_LINK)
        if os.path.islink(res_lnk):
            os.remove(res_lnk)
        os.symlink(self.res_dir, res_lnk)

        logging.info('%14s - Set results folder to:', 'TestEnv')
        logging.info('%14s -    %s', 'TestEnv', self.res_dir)
        logging.info('%14s - Experiment results available also in:', 'TestEnv')
        logging.info('%14s -    %s', 'TestEnv', res_lnk)

        self._initialized = True
Example #8
0
File: env.py Project: deggeman/lisa
    def __init__(self, target_conf=None, test_conf=None):
        super(TestEnv, self).__init__()

        if self._initialized:
            return

        self.conf = None
        self.target = None
        self.ftrace = None
        self.workdir = WORKING_DIR_DEFAULT
        self.__tools = []
        self.__modules = []
        self.__connection_settings = None
        self._calib = None

        # Keep track of target IP and MAC address
        self.ip = None
        self.mac = None

        # Keep track of last installed kernel
        self.kernel = None
        self.dtb = None

        # Energy meter configuration
        self.emeter = None

        # The platform descriptor to be saved into the results folder
        self.platform = {}

        # Compute base installation path
        logging.info('%14s - Using base path: %s',
                'Target', basepath)

        # Setup target configuration
        if isinstance(target_conf, dict):
            logging.info('%14s - Loading custom (inline) target configuration',
                    'Target')
            self.conf = target_conf
        elif isinstance(target_conf, str):
            logging.info('%14s - Loading custom (file) target configuration',
                    'Target')
            self.conf = TestEnv.loadTargetConfig(target_conf)
        elif target_conf is None:
            logging.info('%14s - Loading default (file) target configuration',
                    'Target')
            self.conf = TestEnv.loadTargetConfig()
        else:
            raise ValueError('target_conf must be either a dictionary or a filepath')

        logging.debug('%14s - Target configuration %s', 'Target', self.conf)

        if 'workdir' in self.conf:
            self.workdir = self.conf['workdir']

        # Initialize binary tools to deploy
        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 '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']
            ))

        # Initialize ftrace events
        if test_conf and 'ftrace' in test_conf:
            self.conf['ftrace'] = test_conf['ftrace']
            self.__tools.append('trace-cmd')

        # Add tools dependencies
        if 'rt-app' in self.__tools:
            self.__tools.append('taskset')
            self.__tools.append('trace-cmd')
            self.__tools.append('perf')
            self.__tools.append('cgroup_run_into.sh')
        # Sanitize list of dependencies to remove duplicates
        self.__tools = list(set(self.__tools))

        # Initialize features
        if '__features__' not in self.conf:
            self.conf['__features__'] = []

        self._init()

        # Initialize FTrace events collection
        self._init_ftrace(True)

        # Initialize energy probe instrument
        self.emeter = EnergyMeter.getInstance(
                self.target, self.conf, force=True)

        # Initialize RT-App calibration values
        self.calibration()

        # Initialize local results folder
        res_dir = os.path.join(basepath, OUT_PREFIX)
        self.res_dir = datetime.datetime.now()\
                .strftime(res_dir + '/%Y%m%d_%H%M%S')
        os.makedirs(self.res_dir)

        res_lnk = os.path.join(basepath, LATEST_LINK)
        if os.path.islink(res_lnk):
            os.remove(res_lnk)
        os.symlink(self.res_dir, res_lnk)

        self._initialized = True
Example #9
0
File: env.py Project: BayLibre/lisa
    def __init__(self, target_conf=None, test_conf=None, wipe=True):
        """
        Initialize the LISA test environment.

        The test environment is defined by:
        - a target configuration (target_conf) defining which HW platform we
        want to use to run the experiments
        - a test configuration (test_conf) defining which SW setups we need on
        that HW target
        - a folder to collect the experiments results, which can be specified
        using the test_conf::results_dir option and is by default wiped from
        all the previous contents (if wipe=True)

        :param target_conf: the HW target we want to use
        :type target_conf: dict

        :param test_conf: the SW setup of the HW target in use
        :type test_conf: dict

        :param wipe: set true to cleanup all previous content from the output
        folder
        :type wipe: bool
        """
        super(TestEnv, self).__init__()

        if self._initialized:
            return

        self.conf = None
        self.test_conf = None
        self.res_dir = None
        self.target = None
        self.ftrace = None
        self.workdir = WORKING_DIR_DEFAULT
        self.__tools = []
        self.__modules = []
        self.__connection_settings = None
        self._calib = None

        # Keep track of target IP and MAC address
        self.ip = None
        self.mac = None

        # Keep track of last installed kernel
        self.kernel = None
        self.dtb = None

        # Energy meter configuration
        self.emeter = None

        # The platform descriptor to be saved into the results folder
        self.platform = {}

        # Compute base installation path
        logging.info('%14s - Using base path: %s',
                'Target', basepath)

        # Setup target configuration
        if isinstance(target_conf, dict):
            logging.info('%14s - Loading custom (inline) target configuration',
                    'Target')
            self.conf = target_conf
        elif isinstance(target_conf, str):
            logging.info('%14s - Loading custom (file) target configuration',
                    'Target')
            self.conf = TestEnv.loadTargetConfig(target_conf)
        elif target_conf is None:
            logging.info('%14s - Loading default (file) target configuration',
                    'Target')
            self.conf = TestEnv.loadTargetConfig()
        logging.debug('%14s - Target configuration %s', 'Target', self.conf)

        # Setup test configuration
        if test_conf:
            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']

        # Initialize binary tools to deploy
        if 'tools' in self.conf:
            self.__tools = self.conf['tools']
        # Merge tests specific 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'] + self.test_conf['tools']
            ))

        # Initialize ftrace events
        # test configuration override target one
        if self.test_conf and 'ftrace' in self.test_conf:
            self.conf['ftrace'] = self.test_conf['ftrace']
        if 'ftrace' in self.conf and self.conf['ftrace']:
            self.__tools.append('trace-cmd')

        # Add tools dependencies
        if 'rt-app' in self.__tools:
            self.__tools.append('taskset')
            self.__tools.append('trace-cmd')
            self.__tools.append('perf')
            self.__tools.append('cgroup_run_into.sh')
        # Sanitize list of dependencies to remove duplicates
        self.__tools = list(set(self.__tools))

        # Initialize features
        if '__features__' not in self.conf:
            self.conf['__features__'] = []

        self._init()

        # Initialize FTrace events collection
        self._init_ftrace(True)

        # Initialize energy probe instrument
        self.emeter = EnergyMeter.getInstance(
                self.target, self.conf, force=True)

        # Initialize RT-App calibration values
        self.calibration()

        # Initialize local results folder
        # test configuration override target one
        if self.test_conf and 'results_dir' in self.test_conf:
            self.res_dir = self.test_conf['results_dir']
        if not self.res_dir and 'results_dir' in self.conf:
            self.res_dir = self.conf['results_dir']
        if self.res_dir and not os.path.isabs(self.res_dir):
                self.res_dir = os.path.join(basepath, 'results', self.res_dir)
        else:
            self.res_dir = os.path.join(basepath, OUT_PREFIX)
            self.res_dir = datetime.datetime.now()\
                            .strftime(self.res_dir + '/%Y%m%d_%H%M%S')
        if wipe and os.path.exists(self.res_dir):
            logging.warning('%14s - Wipe previous contents of the results folder:', 'TestEnv')
            logging.warning('%14s -    %s', 'TestEnv', self.res_dir)
            shutil.rmtree(self.res_dir, ignore_errors=True)
        if not os.path.exists(self.res_dir):
            os.makedirs(self.res_dir)

        res_lnk = os.path.join(basepath, LATEST_LINK)
        if os.path.islink(res_lnk):
            os.remove(res_lnk)
        os.symlink(self.res_dir, res_lnk)

        logging.info('%14s - Set results folder to:', 'TestEnv')
        logging.info('%14s -    %s', 'TestEnv', self.res_dir)
        logging.info('%14s - Experiment results available also in:', 'TestEnv')
        logging.info('%14s -    %s', 'TestEnv', res_lnk)

        self._initialized = True
Example #10
0
    def __init__(self, target_conf=None, test_conf=None):
        super(TestEnv, self).__init__()

        if self._initialized:
            return

        self.conf = None
        self.target = None
        self.ftrace = None
        self.workdir = WORKING_DIR_DEFAULT
        self.__tools = []
        self.__modules = []
        self.__connection_settings = None
        self._calib = None

        # Keep track of target IP and MAC address
        self.ip = None
        self.mac = None

        # Keep track of last installed kernel
        self.kernel = None
        self.dtb = None

        # Energy meter configuration
        self.emeter = None

        # The platform descriptor to be saved into the results folder
        self.platform = {}

        # Compute base installation path
        logging.info('%14s - Using base path: %s', 'Target', basepath)

        # Setup target configuration
        if isinstance(target_conf, dict):
            logging.info('%14s - Loading custom (inline) target configuration',
                         'Target')
            self.conf = target_conf
        elif isinstance(target_conf, str):
            logging.info('%14s - Loading custom (file) target configuration',
                         'Target')
            self.conf = TestEnv.loadTargetConfig(target_conf)
        elif target_conf is None:
            logging.info('%14s - Loading default (file) target configuration',
                         'Target')
            self.conf = TestEnv.loadTargetConfig()
        else:
            raise ValueError(
                'target_conf must be either a dictionary or a filepath')

        logging.debug('%14s - Target configuration %s', 'Target', self.conf)

        if 'workdir' in self.conf:
            self.workdir = self.conf['workdir']

        # Initialize binary tools to deploy
        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 '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']))

        # Initialize ftrace events
        if test_conf and 'ftrace' in test_conf:
            self.conf['ftrace'] = test_conf['ftrace']
            self.__tools.append('trace-cmd')

        # Add tools dependencies
        if 'rt-app' in self.__tools:
            self.__tools.append('taskset')
            self.__tools.append('trace-cmd')
            self.__tools.append('perf')
            self.__tools.append('cgroup_run_into.sh')
        # Sanitize list of dependencies to remove duplicates
        self.__tools = list(set(self.__tools))

        # Initialize features
        if '__features__' not in self.conf:
            self.conf['__features__'] = []

        self._init()

        # Initialize FTrace events collection
        self._init_ftrace(True)

        # Initialize energy probe instrument
        self.emeter = EnergyMeter.getInstance(self.target,
                                              self.conf,
                                              force=True)

        # Initialize RT-App calibration values
        self.calibration()

        # Initialize local results folder
        res_dir = os.path.join(basepath, OUT_PREFIX)
        self.res_dir = datetime.datetime.now()\
                .strftime(res_dir + '/%Y%m%d_%H%M%S')
        os.makedirs(self.res_dir)

        res_lnk = os.path.join(basepath, LATEST_LINK)
        if os.path.islink(res_lnk):
            os.remove(res_lnk)
        os.symlink(self.res_dir, res_lnk)

        self._initialized = True