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

!1041 规范代码风格

Merge pull request !1041 from zzulilyw/master
...@@ -51,8 +51,12 @@ ...@@ -51,8 +51,12 @@
_rc; \ _rc; \
}) })
#endif #endif
#define ENABLE_TRACE system("echo 1 > /sys/kernel/debug/tracing/tracing_on"); #define SET_TRACE(str) \
#define DISABLE_TRACE system("echo 0 > /sys/kernel/debug/tracing/tracing_on"); do \
{ \
system("echo "#str" > /sys/kernel/debug/tracing/tracing_on"); \
} while (0)
typedef void (*TEST_FUN)(void); typedef void (*TEST_FUN)(void);
static const int WAIT_TIME = 1; static const int WAIT_TIME = 1;
...@@ -98,10 +102,10 @@ static void dump_trace(int trace_fd) ...@@ -98,10 +102,10 @@ static void dump_trace(int trace_fd)
static void trace_marker_0010(void) static void trace_marker_0010(void)
{ {
clear_trace(); clear_trace();
ENABLE_TRACE SET_TRACE(1);
trace_marker_begin(HITRACE_TAG_MUSL, "Musl_Trace_Marker_0010", ""); trace_marker_begin(HITRACE_TAG_MUSL, "Musl_Trace_Marker_0010", "");
trace_marker_end(HITRACE_TAG_MUSL); trace_marker_end(HITRACE_TAG_MUSL);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -149,10 +153,10 @@ static void trace_marker_0010(void) ...@@ -149,10 +153,10 @@ static void trace_marker_0010(void)
static void trace_marker_0020(void) static void trace_marker_0020(void)
{ {
clear_trace(); clear_trace();
ENABLE_TRACE SET_TRACE(1);
trace_marker_async_begin(HITRACE_TAG_MUSL, "async_begin_0200", "trace_async",1); trace_marker_async_begin(HITRACE_TAG_MUSL, "async_begin_0200", "trace_async",1);
trace_marker_async_end(HITRACE_TAG_MUSL, "async_end_0200", "trace_async",1); trace_marker_async_end(HITRACE_TAG_MUSL, "async_end_0200", "trace_async",1);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -200,10 +204,10 @@ static void trace_marker_0020(void) ...@@ -200,10 +204,10 @@ static void trace_marker_0020(void)
static void trace_marker_0030(void) static void trace_marker_0030(void)
{ {
clear_trace(); clear_trace();
ENABLE_TRACE SET_TRACE(1);
int traceCount = 5; int traceCount = 5;
trace_marker_count(HITRACE_TAG_MUSL, "traceCount", traceCount); trace_marker_count(HITRACE_TAG_MUSL, "traceCount", traceCount);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -258,10 +262,10 @@ static void trace_marker_0040(void) ...@@ -258,10 +262,10 @@ static void trace_marker_0040(void)
printf("error in fork! \n"); printf("error in fork! \n");
} else if (fpid == 0) { } else if (fpid == 0) {
int pidChild = getpid(); int pidChild = getpid();
ENABLE_TRACE SET_TRACE(1);
trace_marker_begin(HITRACE_TAG_MUSL, "Trace_Marker0400_Forkfir", ""); trace_marker_begin(HITRACE_TAG_MUSL, "Trace_Marker0400_Forkfir", "");
trace_marker_end(HITRACE_TAG_MUSL); trace_marker_end(HITRACE_TAG_MUSL);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -296,10 +300,10 @@ static void trace_marker_0040(void) ...@@ -296,10 +300,10 @@ static void trace_marker_0040(void)
close(trace_fd); close(trace_fd);
exit(pidChild); exit(pidChild);
} else { } else {
ENABLE_TRACE SET_TRACE(1);
trace_marker_begin(HITRACE_TAG_MUSL, "Trace_Marker0400_Forksec", ""); trace_marker_begin(HITRACE_TAG_MUSL, "Trace_Marker0400_Forksec", "");
trace_marker_end(HITRACE_TAG_MUSL); trace_marker_end(HITRACE_TAG_MUSL);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -355,10 +359,10 @@ static void trace_marker_0050(void) ...@@ -355,10 +359,10 @@ static void trace_marker_0050(void)
printf("error in fork! \n"); printf("error in fork! \n");
} else if (fpid == 0) { } else if (fpid == 0) {
int pidChild = getpid(); int pidChild = getpid();
ENABLE_TRACE SET_TRACE(1);
trace_marker_async_begin(HITRACE_TAG_MUSL, "async0500_Forkfir", "begin_fir", 2); trace_marker_async_begin(HITRACE_TAG_MUSL, "async0500_Forkfir", "begin_fir", 2);
trace_marker_async_end(HITRACE_TAG_MUSL, "async0500_Forkfir", "end_fir", 2); trace_marker_async_end(HITRACE_TAG_MUSL, "async0500_Forkfir", "end_fir", 2);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -393,10 +397,10 @@ static void trace_marker_0050(void) ...@@ -393,10 +397,10 @@ static void trace_marker_0050(void)
close(trace_fd); close(trace_fd);
exit(pidChild); exit(pidChild);
} else { } else {
ENABLE_TRACE SET_TRACE(1);
trace_marker_async_begin(HITRACE_TAG_MUSL, "async0500_Forksec", "begin_sec", 3); trace_marker_async_begin(HITRACE_TAG_MUSL, "async0500_Forksec", "begin_sec", 3);
trace_marker_async_end(HITRACE_TAG_MUSL, "async0500_Forksec", "end_sec", 3); trace_marker_async_end(HITRACE_TAG_MUSL, "async0500_Forksec", "end_sec", 3);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -453,9 +457,9 @@ static void trace_marker_0060(void) ...@@ -453,9 +457,9 @@ static void trace_marker_0060(void)
} else if (fpid == 0) { } else if (fpid == 0) {
int pidChild = getpid(); int pidChild = getpid();
ENABLE_TRACE SET_TRACE(1);
trace_marker_count(HITRACE_TAG_MUSL, "traceCount_forkfir", traceCount); trace_marker_count(HITRACE_TAG_MUSL, "traceCount_forkfir", traceCount);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -484,9 +488,9 @@ static void trace_marker_0060(void) ...@@ -484,9 +488,9 @@ static void trace_marker_0060(void)
close(trace_fd); close(trace_fd);
exit(pidChild); exit(pidChild);
} else { } else {
ENABLE_TRACE SET_TRACE(1);
trace_marker_count(HITRACE_TAG_MUSL, "traceCount_forksec", traceCount); trace_marker_count(HITRACE_TAG_MUSL, "traceCount_forksec", traceCount);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY | O_APPEND);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -611,7 +615,7 @@ static void *ThreadTraceMarkerSec(void *arg) ...@@ -611,7 +615,7 @@ static void *ThreadTraceMarkerSec(void *arg)
*/ */
static void trace_marker_0070(void) static void trace_marker_0070(void)
{ {
ENABLE_TRACE SET_TRACE(1);
clear_trace(); clear_trace();
int res; int res;
const char msgThread1[1024] = {"msgThread1"}; const char msgThread1[1024] = {"msgThread1"};
...@@ -627,7 +631,7 @@ static void trace_marker_0070(void) ...@@ -627,7 +631,7 @@ static void trace_marker_0070(void)
} }
pthread_join(fatalMessageThread1, NULL); pthread_join(fatalMessageThread1, NULL);
pthread_join(fatalMessageThread2, NULL); pthread_join(fatalMessageThread2, NULL);
DISABLE_TRACE SET_TRACE(0);
} }
static void *ThreadTraceMarkerAsyncFir(void *arg) static void *ThreadTraceMarkerAsyncFir(void *arg)
...@@ -725,7 +729,7 @@ static void *ThreadTraceMarkerAsyncSec(void *arg) ...@@ -725,7 +729,7 @@ static void *ThreadTraceMarkerAsyncSec(void *arg)
*/ */
static void trace_marker_0080(void) static void trace_marker_0080(void)
{ {
ENABLE_TRACE SET_TRACE(1);
clear_trace(); clear_trace();
int res; int res;
const char msgThread1[1024] = {"msgThread3"}; const char msgThread1[1024] = {"msgThread3"};
...@@ -741,7 +745,7 @@ static void trace_marker_0080(void) ...@@ -741,7 +745,7 @@ static void trace_marker_0080(void)
} }
pthread_join(fatalMessageThread1, NULL); pthread_join(fatalMessageThread1, NULL);
pthread_join(fatalMessageThread2, NULL); pthread_join(fatalMessageThread2, NULL);
DISABLE_TRACE SET_TRACE(0);
} }
static void *ThreadTraceMarkerCountFir(void *arg) static void *ThreadTraceMarkerCountFir(void *arg)
...@@ -828,7 +832,7 @@ static void *ThreadTraceMarkerCountSec(void *arg) ...@@ -828,7 +832,7 @@ static void *ThreadTraceMarkerCountSec(void *arg)
*/ */
static void trace_marker_0090(void) static void trace_marker_0090(void)
{ {
ENABLE_TRACE SET_TRACE(1);
clear_trace(); clear_trace();
int res; int res;
const char msgThread1[1024] = {"msgThread5"}; const char msgThread1[1024] = {"msgThread5"};
...@@ -844,7 +848,7 @@ static void trace_marker_0090(void) ...@@ -844,7 +848,7 @@ static void trace_marker_0090(void)
} }
pthread_join(fatalMessageThread1, NULL); pthread_join(fatalMessageThread1, NULL);
pthread_join(fatalMessageThread2, NULL); pthread_join(fatalMessageThread2, NULL);
DISABLE_TRACE SET_TRACE(0);
} }
/** /**
...@@ -855,10 +859,10 @@ static void trace_marker_0090(void) ...@@ -855,10 +859,10 @@ static void trace_marker_0090(void)
static void trace_marker_0100(void) static void trace_marker_0100(void)
{ {
clear_trace(); clear_trace();
ENABLE_TRACE SET_TRACE(1);
trace_marker_begin(HITRACE_TAG_MUSL, "Musl_Trace_Marker_0100", NULL); trace_marker_begin(HITRACE_TAG_MUSL, "Musl_Trace_Marker_0100", NULL);
trace_marker_end(HITRACE_TAG_MUSL); trace_marker_end(HITRACE_TAG_MUSL);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -911,10 +915,10 @@ static void trace_marker_0110(void) ...@@ -911,10 +915,10 @@ static void trace_marker_0110(void)
memset(message, 1, 1025); memset(message, 1, 1025);
message[1025] = '\0'; message[1025] = '\0';
ENABLE_TRACE SET_TRACE(1);
trace_marker_begin(HITRACE_TAG_MUSL, message, ""); trace_marker_begin(HITRACE_TAG_MUSL, message, "");
trace_marker_end(HITRACE_TAG_MUSL); trace_marker_end(HITRACE_TAG_MUSL);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -964,10 +968,10 @@ static void trace_marker_0110(void) ...@@ -964,10 +968,10 @@ static void trace_marker_0110(void)
static void trace_marker_0120(void) static void trace_marker_0120(void)
{ {
clear_trace(); clear_trace();
ENABLE_TRACE SET_TRACE(1);
trace_marker_begin(HITRACE_TAG_MUSL, NULL, ""); trace_marker_begin(HITRACE_TAG_MUSL, NULL, "");
trace_marker_end(HITRACE_TAG_MUSL); trace_marker_end(HITRACE_TAG_MUSL);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -1008,10 +1012,10 @@ static void trace_marker_0120(void) ...@@ -1008,10 +1012,10 @@ static void trace_marker_0120(void)
static void trace_marker_0140(void) static void trace_marker_0140(void)
{ {
clear_trace(); clear_trace();
ENABLE_TRACE SET_TRACE(1);
trace_marker_async_begin(HITRACE_TAG_MUSL, "async_begin_0200", NULL,1); trace_marker_async_begin(HITRACE_TAG_MUSL, "async_begin_0200", NULL,1);
trace_marker_async_end(HITRACE_TAG_MUSL, "async_end_0200", NULL,1); trace_marker_async_end(HITRACE_TAG_MUSL, "async_end_0200", NULL,1);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -1065,10 +1069,10 @@ static void trace_marker_0150(void) ...@@ -1065,10 +1069,10 @@ static void trace_marker_0150(void)
memset(message, 1, 1025); memset(message, 1, 1025);
message[1025] = '\0'; message[1025] = '\0';
ENABLE_TRACE SET_TRACE(1);
trace_marker_async_begin(HITRACE_TAG_MUSL, message, "trace_async",1); trace_marker_async_begin(HITRACE_TAG_MUSL, message, "trace_async",1);
trace_marker_async_end(HITRACE_TAG_MUSL, message, "trace_async",1); trace_marker_async_end(HITRACE_TAG_MUSL, message, "trace_async",1);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -1116,10 +1120,10 @@ static void trace_marker_0150(void) ...@@ -1116,10 +1120,10 @@ static void trace_marker_0150(void)
static void trace_marker_0160(void) static void trace_marker_0160(void)
{ {
clear_trace(); clear_trace();
ENABLE_TRACE SET_TRACE(1);
trace_marker_async_begin(HITRACE_TAG_MUSL, NULL, "trace_async",1); trace_marker_async_begin(HITRACE_TAG_MUSL, NULL, "trace_async",1);
trace_marker_async_end(HITRACE_TAG_MUSL, NULL, "trace_async",1); trace_marker_async_end(HITRACE_TAG_MUSL, NULL, "trace_async",1);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -1167,14 +1171,14 @@ static void trace_marker_0160(void) ...@@ -1167,14 +1171,14 @@ static void trace_marker_0160(void)
static void trace_marker_0180(void) static void trace_marker_0180(void)
{ {
clear_trace(); clear_trace();
ENABLE_TRACE SET_TRACE(1);
int traceCount = 5; int traceCount = 5;
char message[1026]= {0}; char message[1026]= {0};
memset(message, 1, 1025); memset(message, 1, 1025);
message[1025] = '\0'; message[1025] = '\0';
trace_marker_count(HITRACE_TAG_MUSL, message, traceCount); trace_marker_count(HITRACE_TAG_MUSL, message, traceCount);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
...@@ -1217,10 +1221,10 @@ static void trace_marker_0180(void) ...@@ -1217,10 +1221,10 @@ static void trace_marker_0180(void)
static void trace_marker_0190(void) static void trace_marker_0190(void)
{ {
clear_trace(); clear_trace();
ENABLE_TRACE SET_TRACE(1);
int traceCount = 5; int traceCount = 5;
trace_marker_count(HITRACE_TAG_MUSL, NULL, traceCount); trace_marker_count(HITRACE_TAG_MUSL, NULL, traceCount);
DISABLE_TRACE SET_TRACE(0);
int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY); int trace_fd = open("/sys/kernel/tracing/trace", O_CLOEXEC | O_RDONLY);
if (trace_fd == -1) { if (trace_fd == -1) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册