1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-20 20:09:11 +00:00

Gem5LinuxDevice: Added login_prompt and login_password_prompt parameters

Added two parameters which allow the user to change the strings used
to match the login prompt and the following password prompt to match
their device configurations.
This commit is contained in:
Sascha Bischoff 2015-12-09 11:32:30 +00:00
parent 9ccf256ee8
commit 845d577482

View File

@ -19,6 +19,7 @@ import logging
from wlauto import LinuxDevice, Parameter
from wlauto.common.gem5.device import BaseGem5Device
from wlauto.utils import types
class Gem5LinuxDevice(BaseGem5Device, LinuxDevice):
@ -78,6 +79,11 @@ class Gem5LinuxDevice(BaseGem5Device, LinuxDevice):
Parameter('core_clusters', default=[], override=True),
Parameter('host', default='localhost', override=True,
description='Host name or IP address for the device.'),
Parameter('login_prompt', kind=types.list_of_strs,
default=['login:', 'AEL login:', 'username:'],
mandatory=False),
Parameter('login_password_prompt', kind=types.list_of_strs,
default=['password:'], mandatory=False),
]
# Overwritten from Device. For documentation, see corresponding method in
@ -90,14 +96,14 @@ class Gem5LinuxDevice(BaseGem5Device, LinuxDevice):
def login_to_device(self):
# Wait for the login prompt
i = self.sckt.expect([r'login:', r'username:', self.sckt.UNIQUE_PROMPT],
timeout=10)
prompt = self.login_prompt + [self.sckt.UNIQUE_PROMPT]
i = self.sckt.expect(prompt, timeout=10)
# Check if we are already at a prompt, or if we need to log in.
if i < 2:
if i < len(prompt) - 1:
self.sckt.sendline("{}".format(self.username))
j = self.sckt.expect([r'password:', r'# ', self.sckt.UNIQUE_PROMPT],
timeout=self.delay)
if j == 2:
password_prompt = self.login_password_prompt + [r'# ', self.sckt.UNIQUE_PROMPT]
j = self.sckt.expect(password_prompt, timeout=self.delay)
if j < len(password_prompt) - 2:
self.sckt.sendline("{}".format(self.password))
self.sckt.expect([r'# ', self.sckt.UNIQUE_PROMPT], timeout=self.delay)