mirror of
https://gitee.com/openharmony/testfwk_xdevice
synced 2024-12-02 12:46:52 +00:00
commit
26a0083809
@ -240,7 +240,8 @@ class Device(IDevice):
|
||||
timeout_msg = '' if timeout == 300.0 else \
|
||||
" with timeout %ss" % timeout
|
||||
if self.host != "127.0.0.1":
|
||||
cmd = [HdcHelper.CONNECTOR_NAME, "-s", "{}:{}".format(self.host, self.port)]
|
||||
cmd = [HdcHelper.CONNECTOR_NAME, "-s", "{}:{}".format(self.host, self.port),
|
||||
"-t", self.device_sn]
|
||||
else:
|
||||
cmd = [HdcHelper.CONNECTOR_NAME, "-t", self.device_sn]
|
||||
LOG.debug("{} execute command {} {}{}".format(convert_serial(self.device_sn),
|
||||
@ -406,7 +407,7 @@ class Device(IDevice):
|
||||
command = "hilog"
|
||||
if self.host != "127.0.0.1":
|
||||
cmd = [HdcHelper.CONNECTOR_NAME, "-s", "{}:{}".format(self.host, self.port),
|
||||
"shell", command]
|
||||
"-t", self.device_sn, "shell", command]
|
||||
else:
|
||||
cmd = [HdcHelper.CONNECTOR_NAME, "-t", self.device_sn, "shell", command]
|
||||
LOG.info("execute command: %s" % " ".join(cmd).replace(
|
||||
@ -558,14 +559,12 @@ class Device(IDevice):
|
||||
self.reconnecttimes = 0
|
||||
|
||||
def reset(self):
|
||||
if self.device_allocation_state != \
|
||||
DeviceAllocationState.ignored:
|
||||
self.log.debug("start stop rpc")
|
||||
if self._proxy is not None:
|
||||
self._proxy.close()
|
||||
self._proxy = None
|
||||
self.remove_ports()
|
||||
self.stop_harmony_rpc()
|
||||
self.log.debug("start stop rpc")
|
||||
if self._proxy is not None:
|
||||
self._proxy.close()
|
||||
self._proxy = None
|
||||
self.remove_ports()
|
||||
self.stop_harmony_rpc()
|
||||
|
||||
@property
|
||||
def proxy(self):
|
||||
@ -814,7 +813,7 @@ class Device(IDevice):
|
||||
def execute_shell_in_daemon(self, command):
|
||||
if self.host != "127.0.0.1":
|
||||
cmd = [HdcHelper.CONNECTOR_NAME, "-s", "{}:{}".format(
|
||||
self.host, self.port), "shell"]
|
||||
self.host, self.port), "-t", self.device_sn, "shell"]
|
||||
else:
|
||||
cmd = [HdcHelper.CONNECTOR_NAME, "-t", self.device_sn, "shell"]
|
||||
LOG.debug("{} execute command {} {} in daemon".format(
|
||||
|
@ -67,11 +67,6 @@ class ManagerDevice(IDeviceManager):
|
||||
def env_stop(self):
|
||||
self._stop_device_monitor()
|
||||
|
||||
def env_reset(self):
|
||||
for device in self.devices_list:
|
||||
if device and hasattr(device, "reset"):
|
||||
device.reset()
|
||||
|
||||
def _start_device_monitor(self, environment="", user_config_file=""):
|
||||
self.managed_device_listener = ManagedDeviceListener(self)
|
||||
device = UserConfigManager(
|
||||
@ -182,6 +177,10 @@ class ManagerDevice(IDeviceManager):
|
||||
LOG.debug("Release_device: release list con lock")
|
||||
self.list_con.release()
|
||||
|
||||
def reset_device(self, device):
|
||||
if device and hasattr(device, "reset"):
|
||||
device.reset()
|
||||
|
||||
def find_device(self, device_sn, device_os_type):
|
||||
for device in self.devices_list:
|
||||
if device.device_sn == device_sn and \
|
||||
|
@ -111,6 +111,9 @@ class ManagerLite(IDeviceManager):
|
||||
LOG.debug("Lite release device: release lock")
|
||||
self.list_con.release()
|
||||
|
||||
def reset_device(self, device):
|
||||
pass
|
||||
|
||||
def list_devices(self):
|
||||
print("Lite devices:")
|
||||
print("{0:<20}{1:<16}{2:<16}{3:<16}{4:<16}{5:<16}{6:<16}".
|
||||
|
@ -131,10 +131,6 @@ class EnvironmentManager(object):
|
||||
|
||||
EnvironmentManager.__init_flag = False
|
||||
|
||||
def env_reset(self):
|
||||
for manager in self.managers.values():
|
||||
manager.env_reset()
|
||||
|
||||
def apply_environment(self, device_options):
|
||||
environment = Environment()
|
||||
for device_option in device_options:
|
||||
@ -156,6 +152,10 @@ class EnvironmentManager(object):
|
||||
device.extend_value = {}
|
||||
self.release_device(device)
|
||||
|
||||
def reset_environment(self, used_devices):
|
||||
for _, device in used_devices:
|
||||
self.reset_device(device)
|
||||
|
||||
def apply_device(self, device_option, timeout=10):
|
||||
LOG.debug("Apply device from managers:%s" % self.managers)
|
||||
for manager_type, manager in self.managers.items():
|
||||
@ -233,6 +233,11 @@ class EnvironmentManager(object):
|
||||
if device in manager.devices_list:
|
||||
manager.release_device(device)
|
||||
|
||||
def reset_device(self, device):
|
||||
for manager in self.managers.values():
|
||||
if device in manager.devices_list:
|
||||
manager.reset_device(device)
|
||||
|
||||
def list_devices(self):
|
||||
LOG.info("List devices.")
|
||||
for manager in self.managers.values():
|
||||
|
@ -161,7 +161,6 @@ class Scheduler(object):
|
||||
|
||||
finally:
|
||||
Scheduler._clear_test_dict_source()
|
||||
self._reset_env()
|
||||
if getattr(task.config, ConfigConst.test_environment, "") or \
|
||||
getattr(task.config, ConfigConst.configfile, ""):
|
||||
self._restore_environment()
|
||||
@ -175,6 +174,7 @@ class Scheduler(object):
|
||||
try:
|
||||
self._dynamic_concurrent_execute(task, used_devices)
|
||||
finally:
|
||||
Scheduler.__reset_environment__(used_devices)
|
||||
# generate reports
|
||||
self._generate_task_report(task, used_devices)
|
||||
|
||||
@ -417,6 +417,11 @@ class Scheduler(object):
|
||||
env_manager = EnvironmentManager()
|
||||
env_manager.release_environment(environment)
|
||||
|
||||
@staticmethod
|
||||
def __reset_environment__(used_devices):
|
||||
env_manager = EnvironmentManager()
|
||||
env_manager.reset_environment(used_devices)
|
||||
|
||||
@classmethod
|
||||
def _check_device_spt(cls, kit, driver_request, device):
|
||||
kit_spt = cls._parse_property_value(ConfigConst.spt,
|
||||
@ -803,11 +808,6 @@ class Scheduler(object):
|
||||
env_manager.env_stop()
|
||||
EnvironmentManager()
|
||||
|
||||
@classmethod
|
||||
def _reset_env(cls):
|
||||
env_manager = EnvironmentManager()
|
||||
env_manager.env_reset()
|
||||
|
||||
@classmethod
|
||||
def start_task_log(cls, log_path):
|
||||
tool_file_name = "task_log.log"
|
||||
|
@ -60,6 +60,10 @@ class IDeviceManager(ABC):
|
||||
def release_device(self, device):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def reset_device(self, device):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def __subclasshook__(cls, class_info):
|
||||
if cls is IDevice:
|
||||
@ -74,10 +78,6 @@ class IDeviceManager(ABC):
|
||||
def env_stop(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def env_reset(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def list_devices(self):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user