Ejemplo n.º 1
0
    def get_additional_logs(self):
        from core.test_run import TestRun
        from connection.ssh_executor import SshExecutor
        from connection.local_executor import LocalExecutor
        from test_tools.fs_utils import check_if_file_exists
        messages_log = "/var/log/messages"
        if not check_if_file_exists(messages_log):
            messages_log = "/var/log/syslog"
        log_files = {
            "messages": messages_log,
            "dmesg": "/home/user/dmesg",
            "cas": "/var/log/opencas.log"
        }
        TestRun.executor.run(f"dmesg > {log_files['dmesg']}")

        for log_name, log_source_path in log_files.items():
            try:
                log_destination_path = os.path.join(self.base_dir, "dut_info",
                                                    f'{log_name}.log')
                TestRun.executor.rsync_from(log_source_path,
                                            log_destination_path)
            except Exception as e:
                TestRun.LOGGER.warning(
                    f"There was a problem during gathering {log_name} log.\n"
                    f"{str(e)}")
Ejemplo n.º 2
0
def get_system_disks():
    system_device = TestRun.executor.run_expect_success('mount | grep " / "').stdout.split()[0]
    readlink_output = readlink(system_device)
    device_name = readlink_output.split('/')[-1]
    sys_block_path = os_utils.get_sys_block_path()
    used_device_names = __get_slaves(device_name)
    if not used_device_names:
        used_device_names = [device_name]
    disk_names = []
    for device_name in used_device_names:
        if check_if_file_exists(f'{sys_block_path}/{device_name}/partition'):
            parent_device = readlink(f'{sys_block_path}/{device_name}/..').split('/')[-1]
            disk_names.append(parent_device)
        else:
            disk_names.append(device_name)

    return disk_names
Ejemplo n.º 3
0
def get_kernel_module_parameter(module_name, parameter):
    param_file_path = f"/sys/module/{module_name}/parameters/{parameter}"
    if not check_if_file_exists(param_file_path):
        raise FileNotFoundError(f"File {param_file_path} does not exist!")
    return File(param_file_path).read()