未验证 提交 23a37e27 编写于 作者: O openharmony_ci 提交者: Gitee

!139 OHJSunitTest新增testcase-timeout参数配置,以及修复部分bug

Merge pull request !139 from liguangjie/cherry-pick-1658390862
......@@ -1630,24 +1630,31 @@ class JSUnitTestDriver(IDriver):
LOG.warning("there is no suites end")
if len(label_list[0]) > 0 and sum(label_list[0]) != 0:
# the problem happened! when the sum of label list is not zero
for i in range(len(label_list[0])):
if label_list[0][i] == 1: # this is the start label
if i + 1 < len(label_list[0]): # peek backward
if label_list[0][i + 1] == 1: # lack the end label
message_list.insert(label_list[1][i + 1],
"app Log: [suite end]\n")
LOG.warning("there is no suite end")
for j in range(i + 1, len(label_list[1])):
label_list[1][j] += 1 # move the index to next
else: # at the tail
message_list.insert(-1, "app Log: [suite end]\n")
LOG.warning("there is no suite end")
self._insert_suite_end(label_list, message_list)
result_message = "".join(message_list)
message_list.clear()
expect_tests_dict = self._parse_suite_info(suite_info)
self._analyse_tests(request, result_message, expect_tests_dict)
@classmethod
def _insert_suite_end(cls, label_list, message_list):
for i in range(len(label_list[0])):
if label_list[0][i] != 1: # skipp
continue
# check the start label, then peek next position
if i + 1 == len(label_list[0]): # next position at the tail
message_list.insert(-1, "app Log: [suite end]\n")
LOG.warning("there is no suite end")
continue
if label_list[0][i + 1] != 1: # 0 present the end label
continue
message_list.insert(label_list[1][i + 1],
"app Log: [suite end]\n")
LOG.warning("there is no suite end")
for j in range(i + 1, len(label_list[1])):
label_list[1][j] += 1 # move the index to next
def _analyse_tests(self, request, result_message, expect_tests_dict):
listener_copy = request.listeners.copy()
parsers = get_plugin(
......@@ -1682,6 +1689,7 @@ class JSUnitTestDriver(IDriver):
for test_name in test_name_dict.values():
test = TestDescription(class_name, test_name)
tests_dict.get(class_name).append(test)
test_count += 1
except json.decoder.JSONDecodeError as json_error:
LOG.warning("Suites info is invalid: %s" % json_error)
LOG.debug("Collect suite count is %s, test count is %s" %
......@@ -1712,7 +1720,7 @@ class JSUnitTestDriver(IDriver):
_, pos = re.match(".+\\[suites info]", line).span()
suite_info.append(line[pos:].strip())
if "[start] start run suites" in line: # ʼǩ
if "[start] start run suites" in line: # 发现了任务开始标签
pid, is_update = \
self._init_suites_start(line, pattern, pid)
if is_update:
......@@ -1926,7 +1934,7 @@ class LTPPosixTestDriver(IDriver):
parser_instances.append(parser_instance)
self.handler = ShellHandler(parser_instances)
result_message = self.config.device.hdc_command(
"shell {}{}".format(dst, test_bin))
"shell {}".format(test_bin))
LOG.info("get result from command {}".
format(result_message))
process_command_ret(result_message, self.handler)
......@@ -1972,7 +1980,6 @@ class OHKernelTestDriver(IDriver):
request.config.report_path,
request.config.device.__get_serial__(),
"device_hilog")
hilog_open = os.open(hilog, os.O_WRONLY | os.O_CREAT | os.O_APPEND,
FilePermission.mode_755)
with os.fdopen(hilog_open, "a") as hilog_file_pipe:
......
......@@ -290,7 +290,7 @@ class OHJSUnitTestDriver(IDriver):
if not package and not module:
raise ParamError("Neither package nor moodle is found"
" in config file.", error_no="03201")
timeout_config = get_config_value("test-timeout",
timeout_config = get_config_value("shell-timeout",
json_config.get_driver(), False)
if timeout_config:
self.config.timeout = int(timeout_config)
......@@ -303,6 +303,11 @@ class OHJSUnitTestDriver(IDriver):
if test_timeout:
self.runner.add_arg("wait_time", int(test_timeout))
testcase_timeout = get_config_value('testcase-timeout',
json_config.get_driver(), False)
if testcase_timeout:
self.runner.add_arg("timeout", int(testcase_timeout))
def _do_test_run(self, listener):
test_to_run = self._collect_test_to_run()
LOG.info("Collected test count is: %s" % (len(test_to_run)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册