Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Test Xdevice
提交
e2c2ec25
T
Test Xdevice
项目概览
OpenHarmony
/
Test Xdevice
大约 1 年 前同步成功
通知
6
Star
23
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Test Xdevice
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e2c2ec25
编写于
10月 28, 2021
作者:
O
openharmony_ci
提交者:
Gitee
10月 28, 2021
浏览文件
操作
浏览文件
下载
差异文件
!56 解决issue:
https://gitee.com/openharmony/xts_acts/issues/I4EXQA?from=project-issue
Merge pull request !56 from alex_hold/cherry-pick-1635333693
上级
bbf98218
1b3c1ef4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
38 deletion
+42
-38
extension/src/xdevice_extension/_core/driver/drivers.py
extension/src/xdevice_extension/_core/driver/drivers.py
+42
-38
未找到文件。
extension/src/xdevice_extension/_core/driver/drivers.py
浏览文件 @
e2c2ec25
...
@@ -1610,9 +1610,9 @@ class JSUnitTestDriver(IDriver):
...
@@ -1610,9 +1610,9 @@ class JSUnitTestDriver(IDriver):
self
.
result
=
check_result_report
(
self
.
result
=
check_result_report
(
request
.
config
.
report_path
,
self
.
result
,
self
.
error_message
)
request
.
config
.
report_path
,
self
.
result
,
self
.
error_message
)
def
generate_console_output
(
self
,
device_log_file
,
request
):
def
generate_console_output
(
self
,
device_log_file
,
request
,
timeout
):
LOG
.
info
(
"prepare to read device log, may wait some time"
)
LOG
.
info
(
"prepare to read device log, may wait some time"
)
result_message
=
self
.
read_device_log
(
device_log_file
,
""
)
result_message
=
self
.
read_device_log
(
device_log_file
,
timeout
)
report_name
=
request
.
get_module_name
()
report_name
=
request
.
get_module_name
()
parsers
=
get_plugin
(
parsers
=
get_plugin
(
...
@@ -1632,21 +1632,26 @@ class JSUnitTestDriver(IDriver):
...
@@ -1632,21 +1632,26 @@ class JSUnitTestDriver(IDriver):
handler
=
ShellHandler
(
parser_instances
)
handler
=
ShellHandler
(
parser_instances
)
process_command_ret
(
result_message
,
handler
)
process_command_ret
(
result_message
,
handler
)
def
read_device_log
(
self
,
device_log_file
,
result_message
):
def
read_device_log
(
self
,
device_log_file
,
timeout
=
60
):
device_log_file_open
=
os
.
open
(
device_log_file
,
os
.
O_RDONLY
,
LOG
.
info
(
"The timeout is {} seconds"
.
format
(
timeout
))
stat
.
S_IWUSR
|
stat
.
S_IRUSR
)
while
time
.
time
()
-
self
.
start_time
<=
timeout
:
result_message
=
""
with
os
.
fdopen
(
device_log_file_open
,
"r"
,
encoding
=
'utf-8'
)
\
with
open
(
device_log_file
,
"r"
,
encoding
=
'utf-8'
)
\
as
file_read_pipe
:
as
file_read_pipe
:
while
True
:
lines
=
file_read_pipe
.
readlines
()
data
=
file_read_pipe
.
readline
()
for
line
in
lines
:
if
not
data
or
not
data
.
strip
():
if
line
.
find
(
"JSApp:"
)
!=
-
1
:
break
result_message
+=
line
# only filter JSApp log
if
"[end] run suites end"
in
line
:
if
data
.
find
(
"JSApp:"
)
!=
-
1
:
LOG
.
info
(
"Find the end mark then analysis result"
)
result_message
+=
data
return
result_message
if
data
.
find
(
"[end] run suites end"
)
!=
-
1
:
# if test not finished, wait 5 seconds
break
else
:
LOG
.
info
(
"did not find the end mark then wait 5 seconds"
)
time
.
sleep
(
5
)
else
:
LOG
.
error
(
"Hjsunit run timeout {}s reached"
.
format
(
timeout
))
raise
RuntimeError
(
"Hjsunit run timeout!"
)
return
result_message
return
result_message
def
_run_jsunit
(
self
,
config_file
,
request
):
def
_run_jsunit
(
self
,
config_file
,
request
):
...
@@ -1674,30 +1679,29 @@ class JSUnitTestDriver(IDriver):
...
@@ -1674,30 +1679,29 @@ class JSUnitTestDriver(IDriver):
hilog_open
=
os
.
open
(
hilog
,
os
.
O_WRONLY
|
os
.
O_CREAT
|
os
.
O_APPEND
,
hilog_open
=
os
.
open
(
hilog
,
os
.
O_WRONLY
|
os
.
O_CREAT
|
os
.
O_APPEND
,
0o755
)
0o755
)
# execute test case
command
=
"shell aa start -d 123 -a %s -b %s"
\
%
(
ability_name
,
package
)
result_value
=
self
.
config
.
device
.
hdc_command
(
command
)
if
result_value
and
"success"
in
str
(
result_value
).
lower
():
setattr
(
self
,
"start_success"
,
True
)
LOG
.
info
(
"execute %s's testcase success. result value=%s"
%
(
package
,
result_value
))
else
:
LOG
.
info
(
"execute %s's testcase failed. result value=%s"
%
(
package
,
result_value
))
raise
RuntimeError
(
"hjsunit test run error happened!"
)
with
os
.
fdopen
(
hilog_open
,
"a"
)
as
hilog_file_pipe
:
with
os
.
fdopen
(
hilog_open
,
"a"
)
as
hilog_file_pipe
:
self
.
config
.
device
.
start_catch_device_log
(
hilog_file_pipe
)
self
.
config
.
device
.
start_catch_device_log
(
hilog_file_pipe
)
# execute test case
command
=
"shell aa start -d 123 -a %s -b %s"
\
self
.
start_time
=
time
.
time
()
%
(
ability_name
,
package
)
timeout_config
=
get_config_value
(
'test-timeout'
,
json_config
.
get_driver
(),
result_value
=
self
.
config
.
device
.
hdc_command
(
command
)
False
,
60000
)
if
"success"
in
str
(
result_value
).
lower
():
timeout
=
int
(
timeout_config
)
/
1000
setattr
(
self
,
"start_success"
,
True
)
self
.
generate_console_output
(
hilog
,
request
,
timeout
)
LOG
.
info
(
"execute %s's testcase success. result value=%s"
%
(
package
,
result_value
))
else
:
LOG
.
info
(
"execute %s's testcase failed. result value=%s"
%
(
package
,
result_value
))
self
.
start_time
=
time
.
time
()
timeout_config
=
get_config_value
(
'test-timeout'
,
json_config
.
get_driver
(),
False
,
60000
)
timeout
=
int
(
timeout_config
)
/
1000
LOG
.
info
(
"wait {}s to keep app log"
.
format
(
timeout
))
time
.
sleep
(
timeout
)
hilog_file_pipe
.
flush
()
self
.
generate_console_output
(
hilog
,
request
)
finally
:
finally
:
do_module_kit_teardown
(
request
)
do_module_kit_teardown
(
request
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录