Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
5d5fbd42
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5d5fbd42
编写于
8月 12, 2021
作者:
T
tuxingsun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add faultlogger testcase
Signed-off-by:
N
tuxingsun
<
duanhaizhen@huawei.com
>
上级
61a656a8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
37 deletion
+29
-37
hiviewdfx/faultloggertest/faultloggercpptest/BUILD.gn
hiviewdfx/faultloggertest/faultloggercpptest/BUILD.gn
+5
-5
hiviewdfx/faultloggertest/faultloggercpptest/faultloggertest.cpp
...fx/faultloggertest/faultloggercpptest/faultloggertest.cpp
+3
-3
hiviewdfx/faultloggertest/faultloggercpptest/genfault.cpp
hiviewdfx/faultloggertest/faultloggercpptest/genfault.cpp
+15
-23
hiviewdfx/faultloggertest/faultloggercpptest/genfault.h
hiviewdfx/faultloggertest/faultloggercpptest/genfault.h
+1
-1
hiviewdfx/utils/native/file_utils.cpp
hiviewdfx/utils/native/file_utils.cpp
+5
-5
未找到文件。
hiviewdfx/faultloggertest/faultloggercpptest/BUILD.gn
浏览文件 @
5d5fbd42
...
...
@@ -21,15 +21,15 @@ config("faultloggertest_config") {
"../../utils/native",
"//utils/native/base/include/",
"//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
"genfault.h"
"genfault.h"
,
]
}
ohos_moduletest_suite("faultloggertest") {
module_out_path = module_output_path
sources = [
"faultloggertest.cpp",
"genfault.cpp"
]
sources = [
"faultloggertest.cpp",
"genfault.cpp",
]
deps = [
"../../utils/native:utilskit",
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
...
...
hiviewdfx/faultloggertest/faultloggercpptest/faultloggertest.cpp
浏览文件 @
5d5fbd42
...
...
@@ -67,7 +67,7 @@ pid_t faultloggertest::DoTestProcess(int faulttype)
std
::
cout
<<
"for pid failed"
<<
std
::
endl
;
break
;
case
0
:
g
enFault
(
faulttype
);
G
enFault
(
faulttype
);
break
;
default:
break
;
...
...
@@ -93,7 +93,7 @@ HWTEST_F(faultloggertest, Faultlogger_Faultdetect, Function|MediumTest|Level1)
faultfilelist
=
getfileinpath
(
"/data/log/faultlog/temp/"
);
printf
(
"sizeof faultfilelist is %d
\r\n
"
,
faultfilelist
.
size
());
bool
result
=
false
;
for
(
std
::
string
filename
:
faultfilelist
)
{
for
(
std
::
string
filename
:
faultfilelist
)
{
printf
(
"file list is %s
\r\n
"
,
filename
.
c_str
());
if
(
filename
.
find
(
"cppcrash-"
+
to_string
(
pid
)))
{
result
=
true
;
...
...
@@ -117,7 +117,7 @@ HWTEST_F(faultloggertest, Faultlogger_Faultdetect1, Function|MediumTest|Level1)
printf
(
"sizeof faultfilelist is %d
\r\n
"
,
faultfilelist
.
size
());
bool
result
=
false
;
std
::
string
faultloggerfile
=
""
;
for
(
std
::
string
filename
:
faultfilelist
)
{
for
(
std
::
string
filename
:
faultfilelist
)
{
if
(
filename
.
find
(
"cppcrash-"
+
to_string
(
pid
))
!=
std
::
string
::
npos
)
{
printf
(
"file list is %s
\r\n
"
,
filename
.
c_str
());
faultloggerfile
=
filename
;
...
...
hiviewdfx/faultloggertest/faultloggercpptest/genfault.cpp
浏览文件 @
5d5fbd42
...
...
@@ -20,19 +20,12 @@
#include <unistd.h>
typedef
enum
{
FAULT_DIVZERO
=
0
,
FAULT_HEAP_OVERFLOW
=
1
,
FAULT_STACK_OVERFLOW
=
2
,
FAULT_NULL_POINTER
=
3
,
FAULT_HEAP
=
1
,
FAULT_STACK
=
2
,
FAULT_NULLPTR
=
3
,
}
FaultType
;
void
faultdividezero
(
int
value
)
{
printf
(
"faultdividezero, param is %d
\r\n
"
,
value
);
printf
(
"faultdividezero result = %d
\r\n
"
,
123
/
value
);
}
void
faultheapoverflow
(
int
value
)
void
FaultHeap
(
int
value
)
{
int
*
arraytest
=
new
int
[
123
];
...
...
@@ -40,30 +33,29 @@ void faultheapoverflow(int value)
printf
(
"%d"
,
arraytest
[
value
]);
}
void
faultstackoverflow
(
int
value
)
void
FaultStack
(
int
value
)
{
int
arraytest
[
123
];
printf
(
"value of i is %d"
,
arraytest
[
value
]);
}
void
faultnullpointer
()
void
FaultNullPointer
()
{
const
int
num
=
80
;
int
*
i
=
NULL
;
int
*
i
=
nullptr
;
*
i
=
num
;
}
void
g
enFault
(
int
faulttype
)
void
G
enFault
(
int
faulttype
)
{
printf
(
"genFault, param is %d
\r\n
"
,
faulttype
);
switch
(
faulttype
)
{
case
FAULT_DIVZERO
:
faultdividezero
(
0
);
case
FAULT_HEAP_OVERFLOW
:
faultheapoverflow
(
125
);
case
FAULT_STACK_OVERFLOW
:
faultstackoverflow
(
125
);
case
FAULT_NULL_POINTER
:
faultnullpointer
();
case
FAULT_HEAP
:
FaultHeap
(
125
);
case
FAULT_STACK
:
FaultStack
(
125
);
case
FAULT_NULLPTR
:
FaultNullPointer
();
break
;
}
}
...
...
hiviewdfx/faultloggertest/faultloggercpptest/genfault.h
浏览文件 @
5d5fbd42
...
...
@@ -13,4 +13,4 @@
* limitations under the License.
*/
#include "file_utils.h"
void
genFault
(
int
faulttype
);
\ No newline at end of file
void
GenFault
(
int
faulttype
);
\ No newline at end of file
hiviewdfx/utils/native/file_utils.cpp
浏览文件 @
5d5fbd42
...
...
@@ -209,12 +209,12 @@ std::vector<std::string> getfileinpath(std::string path)
DIR
*
dir
;
struct
dirent
*
pdirent
;
dir
=
opendir
(
path
.
c_str
());
if
(
dir
!=
NULL
)
{
while
((
pdirent
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strncmp
(
pdirent
->
d_name
,
"."
,
strlen
(
pdirent
->
d_name
))
==
0
||
strncmp
(
pdirent
->
d_name
,
".."
,
strlen
(
pdirent
->
d_name
))
==
0
)
{
if
(
dir
!=
nullptr
)
{
while
((
pdirent
=
readdir
(
dir
))
!=
nullptr
)
{
if
(
strncmp
(
pdirent
->
d_name
,
"."
,
strlen
(
pdirent
->
d_name
))
==
0
||
strncmp
(
pdirent
->
d_name
,
".."
,
strlen
(
pdirent
->
d_name
))
==
0
)
{
continue
;
}
else
if
(
pdirent
->
d_type
==
4
)
{
}
else
if
(
pdirent
->
d_type
==
4
)
{
continue
;
}
else
{
filelist
.
push_back
(
pdirent
->
d_name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录