提交 a8c57c18 编写于 作者: C caozhizhan

modify drivers.py

Signed-off-by: Ncaozhizhan <caozhizhan@kaihongdigi.com>
上级 4ad7ffbe
...@@ -25,6 +25,7 @@ import platform ...@@ -25,6 +25,7 @@ import platform
import zipfile import zipfile
import stat import stat
from dataclasses import dataclass from dataclasses import dataclass
from json import JSONDecodeError
from xdevice import DeviceTestType from xdevice import DeviceTestType
from xdevice import DeviceLabelType from xdevice import DeviceLabelType
...@@ -658,11 +659,18 @@ class JSUnitTestDriver(IDriver): ...@@ -658,11 +659,18 @@ class JSUnitTestDriver(IDriver):
def _run_jsunit(self, suite_file, device_log_file): def _run_jsunit(self, suite_file, device_log_file):
filename = os.path.basename(suite_file) filename = os.path.basename(suite_file)
_, suffix_name = os.path.splitext(filename)
resource_manager = ResourceManager() resource_manager = ResourceManager()
resource_data_dic, resource_dir = \ resource_data_dic, resource_dir = resource_manager.get_resource_data_dic(suite_file)
resource_manager.get_resource_data_dic(suite_file) if suffix_name == ".hap":
timeout = ResourceManager.get_nodeattrib_data(resource_data_dic) json_file_path = suite_file.replace(".hap", ".json")
if os.path.exists(json_file_path):
timeout = self._get_json_shell_timeout(json_file_path)
else:
timeout = ResourceManager.get_nodeattrib_data(resource_data_dic)
else:
timeout = ResourceManager.get_nodeattrib_data(resource_data_dic)
resource_manager.process_preparer_data(resource_data_dic, resource_dir, resource_manager.process_preparer_data(resource_data_dic, resource_dir,
self.config.device) self.config.device)
...@@ -800,6 +808,23 @@ class JSUnitTestDriver(IDriver): ...@@ -800,6 +808,23 @@ class JSUnitTestDriver(IDriver):
_sleep_according_to_result(return_message) _sleep_according_to_result(return_message)
return return_message return return_message
@classmethod
def _get_json_shell_timeout(cls, json_filepath):
test_timeout = 300
try:
with open(json_filepath, 'r') as json_file:
data_dic = json.load(json_file)
if not data_dic:
return test_timeout
else:
if "driver" in data_dic.keys():
driver_dict = data_dic.get("driver")
if driver_dict and "test-timeout" in driver_dict.keys():
test_timeout = int(driver_dict["shell-timeout"]) / 1000
return test_timeout
except JSONDecodeError:
return test_timeout
@staticmethod @staticmethod
def _get_package_and_ability_name(hap_filepath): def _get_package_and_ability_name(hap_filepath):
package_name = "" package_name = ""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册