Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
1542c60a
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1542c60a
编写于
6月 28, 2021
作者:
Z
zhangchunle
提交者:
GitHub
6月 28, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test=document_fix (#33799)
上级
0f31ed71
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
84 addition
and
26 deletion
+84
-26
paddle/scripts/paddle_build.sh
paddle/scripts/paddle_build.sh
+0
-1
tools/analysisPyXml.py
tools/analysisPyXml.py
+18
-4
tools/get_single_test_cov.py
tools/get_single_test_cov.py
+30
-7
tools/get_ut_file_map.py
tools/get_ut_file_map.py
+35
-13
tools/handle_h_cu_file.py
tools/handle_h_cu_file.py
+1
-1
未找到文件。
paddle/scripts/paddle_build.sh
浏览文件 @
1542c60a
...
...
@@ -1445,7 +1445,6 @@ function precise_card_test_single {
mkdir
${
PADDLE_ROOT
}
/build/ut_map/
$case
fi
set
-x
mkdir
${
PADDLE_ROOT
}
/build/ut_map/
$case
find paddle/fluid
-name
'*.gcda'
|
xargs
-I
{}
cp
--path
{}
ut_map/
$case
find paddle/fluid
-name
'*.gcno'
|
xargs
-I
{}
cp
--path
{}
ut_map/
$case
python
${
PADDLE_ROOT
}
/tools/get_single_test_cov.py
${
PADDLE_ROOT
}
$case
&
...
...
tools/analysisPyXml.py
浏览文件 @
1542c60a
...
...
@@ -25,7 +25,10 @@ import sys
def
analysisPyXml
(
rootPath
,
ut
):
xml_path
=
'%s/build/pytest/%s/python-coverage.xml'
%
(
rootPath
,
ut
)
ut_map_file
=
'%s/build/ut_map/%s/%s.txt'
%
(
rootPath
,
ut
,
ut
)
related_ut_map_file
=
'%s/build/ut_map/%s/related_%s.txt'
%
(
rootPath
,
ut
,
ut
)
notrelated_ut_map_file
=
'%s/build/ut_map/%s/notrelated_%s.txt'
%
(
rootPath
,
ut
,
ut
)
tree
=
ElementTree
.
parse
(
xml_path
)
root
=
tree
.
getroot
()
error_files
=
[]
...
...
@@ -46,16 +49,27 @@ def analysisPyXml(rootPath, ut):
'@'
,
'
\'\'\'
'
,
'logger'
,
'_logger'
,
'logging'
,
'r"""'
,
'pass'
,
'try'
,
'except'
,
'if __name__ == "__main__"'
))
==
False
:
#print(line_hits, line_number)
pattern
=
"(.*) = ('*')|(.*) = (
\"
*
\"
)|(.*) = (\d)|(.*) = (-\d)|(.*) = (None)|(.*) = (True)|(.*) = (False)|(.*) = (URL_PREFIX*)|(.*) = (\[)|(.*) = (\{)|(.*) = (\()"
#a='b'/a="b"/a=0
if
re
.
match
(
pattern
,
output
.
strip
())
==
None
:
pyCov_file
.
append
(
clazz_filename
)
os
.
system
(
'echo %s >> %s'
%
(
clazz_filename
,
ut_map_file
))
coverageMessage
=
'RELATED'
break
else
:
coverageMessage
=
'FILTER'
#hit filter logic
else
:
coverageMessage
=
'FILTER'
else
:
coverageMessage
=
'ERROR'
error_files
.
append
(
clazz_filename
)
break
else
:
coverageMessage
=
'NOT_RELATED'
if
coverageMessage
in
[
'NOT_RELATED'
,
'ERROR'
,
'FILTER'
]:
os
.
system
(
'echo %s >> %s'
%
(
clazz_filename
,
notrelated_ut_map_file
))
elif
coverageMessage
==
'RELATED'
:
os
.
system
(
'echo %s >> %s'
%
(
clazz_filename
,
related_ut_map_file
))
print
(
"============len(pyCov_file)"
)
print
(
len
(
pyCov_file
))
print
(
"============error"
)
...
...
tools/get_single_test_cov.py
浏览文件 @
1542c60a
...
...
@@ -37,24 +37,47 @@ def getFNDAFile(rootPath, test):
def
analysisFNDAFile
(
rootPath
,
test
):
ut_map_file
=
'%s/build/ut_map/%s/%s.txt'
%
(
rootPath
,
test
,
test
)
os
.
system
(
'touch %s'
%
ut_map_file
)
related_ut_map_file
=
'%s/build/ut_map/%s/related_%s.txt'
%
(
rootPath
,
test
,
test
)
notrelated_ut_map_file
=
'%s/build/ut_map/%s/notrelated_%s.txt'
%
(
rootPath
,
test
,
test
)
os
.
system
(
'touch %s'
%
related_ut_map_file
)
os
.
system
(
'touch %s'
%
notrelated_ut_map_file
)
fn_filename
=
'%s/build/ut_map/%s/fnda.tmp'
%
(
rootPath
,
test
)
f
=
open
(
fn_filename
)
data
=
f
.
read
().
split
(
'SF:'
)
related_file_list
=
[]
for
message
in
data
:
if
'FNDA:'
in
message
:
message_list
=
message
.
split
(
'
\n
'
)
clazz_filename
=
message_list
[
0
]
#if not clazz_filename.endswith('.h'): #filter .h's Analysis
if
'/build/'
in
clazz_filename
:
clazz_filename
=
clazz_filename
.
replace
(
'/build'
,
''
)
if
'.pb.h'
in
clazz_filename
:
clazz_filename
=
clazz_filename
.
replace
(
'.pb.h'
,
'.proto'
)
if
'.pb.cc'
in
clazz_filename
:
clazz_filename
=
clazz_filename
.
replace
(
'.pb.cc'
,
'.proto'
)
if
'FNDA:'
in
message
:
OP_REGIST
=
True
for
i
in
range
(
1
,
len
(
message_list
)
-
1
):
fn
=
message_list
[
i
]
matchObj
=
re
.
match
(
r
'(.*)Maker(.*)|(.*)Touch(.*)Regist(.*)|(.*)Touch(.*)JitKernel(.*)|(.*)converterC2Ev(.*)'
,
fn
,
re
.
I
)
if
matchObj
==
None
:
os
.
system
(
'echo %s >> %s'
%
(
clazz_filename
,
ut_map_file
))
OP_REGIST
=
False
break
if
OP_REGIST
==
False
:
related_file_list
.
append
(
clazz_filename
)
os
.
system
(
'echo %s >> %s'
%
(
clazz_filename
,
related_ut_map_file
))
else
:
os
.
system
(
'echo %s >> %s'
%
(
clazz_filename
,
notrelated_ut_map_file
))
else
:
if
clazz_filename
!=
''
:
if
clazz_filename
not
in
related_file_list
:
# xx.pb.cc in RELATED xx.pb.h not in RELATED
os
.
system
(
'echo %s >> %s'
%
(
clazz_filename
,
notrelated_ut_map_file
))
f
.
close
()
...
...
@@ -64,7 +87,7 @@ def getCovinfo(rootPath, test):
'cd %s && lcov --capture -d . -o coverage.info --rc lcov_branch_coverage=0 > /dev/null 2>&1'
%
ut_map_path
)
os
.
system
(
"cd %s && lcov --extract coverage.info '/paddle/paddle/fluid/framework/*' '/paddle/paddle/fluid/imperative/*' '/paddle/paddle/fluid/inference/*' '/paddle/paddle/fluid/memory/*' '/paddle/paddle/fluid/operators/*' '/paddle/paddle/fluid/string/*' '/paddle/paddle/fluid/distributed/*' '/paddle/paddle/fluid/extension/*' '/paddle/paddle/fluid/platform/*' '/paddle/paddle/fluid/pybind/*' -o coverage.info.tmp --rc lcov_branch_coverage=0 > /dev/null 2>&1"
"cd %s && lcov --extract coverage.info '/paddle/paddle/fluid/framework/*' '/paddle/paddle/fluid/imperative/*' '/paddle/paddle/fluid/inference/*' '/paddle/paddle/fluid/memory/*' '/paddle/paddle/fluid/operators/*' '/paddle/paddle/fluid/string/*' '/paddle/paddle/fluid/distributed/*' '/paddle/paddle/fluid/extension/*' '/paddle/paddle/fluid/platform/*' '/paddle/paddle/fluid/pybind/*'
'/paddle/build/*'
-o coverage.info.tmp --rc lcov_branch_coverage=0 > /dev/null 2>&1"
%
ut_map_path
)
os
.
system
(
'rm -rf %s/paddle'
%
ut_map_path
)
os
.
system
(
'rm -rf %s/coverage.info'
%
ut_map_path
)
...
...
tools/get_ut_file_map.py
浏览文件 @
1542c60a
...
...
@@ -20,7 +20,7 @@ import json
def
get_all_paddle_file
(
rootPath
):
"""get all file in Paddle repo: paddle/fluild, python"""
traverse_files
=
[
'%s
/paddle/fluid'
%
rootPath
,
'%s/python
'
%
rootPath
]
traverse_files
=
[
'%s'
%
rootPath
]
all_file_paddle
=
'%s/build/all_file_paddle'
%
rootPath
all_file_paddle_list
=
[]
with
open
(
all_file_paddle
,
'w'
)
as
f
:
...
...
@@ -56,7 +56,7 @@ def remove_useless_file(rootPath):
def
handle_ut_file_map
(
rootPath
):
utNotSuccess
=
''
utNotSuccess
_list
=
[]
ut_map_path
=
"%s/build/ut_map"
%
rootPath
files
=
os
.
listdir
(
ut_map_path
)
ut_file_map
=
{}
...
...
@@ -67,7 +67,7 @@ def handle_ut_file_map(rootPath):
print
(
"ut %s: %s"
%
(
count
,
ut
))
coverage_info
=
'%s/%s/coverage.info.tmp'
%
(
ut_map_path
,
ut
)
if
os
.
path
.
exists
(
coverage_info
):
filename
=
'%s/%s/%s.txt'
%
(
ut_map_path
,
ut
,
ut
)
filename
=
'%s/%s/
related_
%s.txt'
%
(
ut_map_path
,
ut
,
ut
)
f
=
open
(
filename
)
lines
=
f
.
readlines
()
for
line
in
lines
:
...
...
@@ -86,19 +86,33 @@ def handle_ut_file_map(rootPath):
ut_file_map
[
source_file
]
=
[]
if
ut
not
in
ut_file_map
[
source_file
]:
ut_file_map
[
source_file
].
append
(
ut
)
else
:
not_success_file
.
write
(
'%s
\n
'
%
ut
)
utNotSuccess
=
utNotSuccess
+
'^%s$|'
%
ut
utNotSuccess_list
.
append
(
ut
)
not_success_file
.
close
()
print
(
"utNotSuccess:"
)
print
(
utNotSuccess_list
)
for
ut
in
files
:
if
ut
not
in
utNotSuccess_list
:
filename
=
'%s/%s/notrelated_%s.txt'
%
(
ut_map_path
,
ut
,
ut
)
f
=
open
(
filename
)
lines
=
f
.
readlines
()
for
line
in
lines
:
line
=
line
.
replace
(
'
\n
'
,
''
).
strip
()
if
line
==
''
:
continue
elif
line
.
startswith
(
'/paddle/build'
):
source_file
=
line
.
replace
(
'/build'
,
''
)
else
:
source_file
=
line
if
source_file
not
in
ut_file_map
:
ut_file_map
[
source_file
]
=
[]
with
open
(
"%s/build/ut_file_map.json"
%
rootPath
,
"w"
)
as
f
:
json
.
dump
(
ut_file_map
,
f
,
indent
=
4
)
print
(
"utNotSuccess:"
)
print
(
utNotSuccess
)
def
notsuccessfuc
(
rootPath
):
utNotSuccess
=
''
...
...
@@ -153,9 +167,6 @@ def ut_file_map_supplement(rootPath):
for
filename
in
load_dict_old
:
if
filename
not
in
load_dict_new
:
if
filename
.
endswith
((
'.h'
)):
load_dict_new
[
filename
]
=
[]
else
:
load_dict_new
[
filename
]
=
load_dict_old
[
filename
]
with
open
(
"/pre_test/ut_file_map.json"
,
"w"
)
as
f
:
...
...
@@ -182,6 +193,8 @@ def ut_file_map_supplement(rootPath):
if
ut
in
all_uts_paddle_list
:
if
not
os
.
path
.
exists
(
filename
)
and
ut
not
in
prec_delta_new_list
:
prec_delta_new_list
.
append
(
ut
)
prec_delta_new_list
.
append
(
'test_py_reader_error_msg'
)
#add a python case for pycoverage
prec_delta_file
=
open
(
"/pre_test/prec_delta"
,
'w'
)
for
ut
in
prec_delta_new_list
:
prec_delta_file
.
write
(
ut
+
'
\n
'
)
...
...
@@ -189,6 +202,15 @@ def ut_file_map_supplement(rootPath):
prec_delta_file
.
close
()
def
utmap_analysis
(
rootPath
):
ut_file_map_new
=
"%s/build/ut_file_map.json"
%
rootPath
with
open
(
ut_file_map_new
,
'r'
)
as
load_f
:
load_dict_new
=
json
.
load
(
load_f
)
print
(
len
(
load_dict_new
))
for
filename
in
load_dict_new
:
print
(
filename
,
len
(
load_dict_new
[
filename
]))
if
__name__
==
"__main__"
:
func
=
sys
.
argv
[
1
]
if
func
==
'get_not_success_ut'
:
...
...
tools/handle_h_cu_file.py
浏览文件 @
1542c60a
...
...
@@ -85,7 +85,7 @@ def get_h_cu_file(file_path):
filename
=
file_path
[
2
]
ut
=
filename
.
replace
(
'^'
,
''
).
replace
(
'$'
,
''
).
replace
(
'.log'
,
''
)
os
.
system
(
"cat %s/%s | grep 'precise test map fileeee:'| uniq >> %s/build/ut_map/%s/%s.txt"
"cat %s/%s | grep 'precise test map fileeee:'| uniq >> %s/build/ut_map/%s/
related_
%s.txt"
%
(
dir_path
,
filename
,
rootPath
,
ut
,
ut
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录