From 2ebaa24eb8ead664e78395c9b552c2ca69c70f45 Mon Sep 17 00:00:00 2001 From: Lassi Marttala Date: Fri, 28 Sep 2012 16:36:34 +0200 Subject: [GDLT-120]: More precise data sizes. Add automatic tests. [GDLT-120]: Fix warnings. --- src/lib/dlt_user.c | 23 +- src/tests/dlt-test-client.c | 799 +++++++++++++++++++++++++++++- src/tests/dlt-test-user.c | 1132 ++++++++++++++++++++++++------------------- 3 files changed, 1444 insertions(+), 510 deletions(-) diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index da30734..0edea8c 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -1878,7 +1878,7 @@ int dlt_user_trace_network_segmented_start(uint16_t *id, DltContext *handle, Dlt } /* Write stream handle */ - if(dlt_user_log_write_uint(&log, *id) < 0) + if(dlt_user_log_write_uint16(&log, *id) < 0) { return -1; } @@ -1890,7 +1890,7 @@ int dlt_user_trace_network_segmented_start(uint16_t *id, DltContext *handle, Dlt } /* Write size of payload */ - if(dlt_user_log_write_uint(&log, payload_len) < 0) + if(dlt_user_log_write_uint16(&log, payload_len) < 0) { return -1; } @@ -1904,13 +1904,13 @@ int dlt_user_trace_network_segmented_start(uint16_t *id, DltContext *handle, Dlt segment_count--; } - if(dlt_user_log_write_uint(&log, segment_count) < 0) + if(dlt_user_log_write_uint16(&log, segment_count) < 0) { return -1; } /* Write length of one segment */ - if(dlt_user_log_write_uint(&log, DLT_MAX_TRACE_SEGMENT_SIZE) < 0) + if(dlt_user_log_write_uint16(&log, DLT_MAX_TRACE_SEGMENT_SIZE) < 0) { return -1; } @@ -1968,13 +1968,13 @@ int dlt_user_trace_network_segmented_segment(uint16_t id, DltContext *handle, Dl } /* Write stream handle */ - if(dlt_user_log_write_uint(&log, id) < 0) + if(dlt_user_log_write_uint16(&log, id) < 0) { return -1; } /* Write segment sequence number */ - if(dlt_user_log_write_uint(&log, sequence) < 0) + if(dlt_user_log_write_uint16(&log, sequence) < 0) { return -1; } @@ -2246,8 +2246,6 @@ int dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_ /* If truncation is allowed, check if we must do it */ if(allow_truncate > 0 && (header_len+payload_len+sizeof(uint16_t))>DLT_USER_BUF_MAX_SIZE) { - int truncated_payload_len = DLT_USER_BUF_MAX_SIZE - header_len - 40; // 40 == overhead bytes - /* Identify as truncated */ if(dlt_user_log_write_string(&log, "NWTR") < 0) { @@ -2261,11 +2259,18 @@ int dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_ } /* Write original size of payload */ - if(dlt_user_log_write_uint(&log, payload_len) < 0) + if(dlt_user_log_write_uint16(&log, payload_len) < 0) { return -1; } + /** + * Calculate maximum avaialble space in sending buffer after headers. + */ + + int truncated_payload_len = DLT_USER_BUF_MAX_SIZE - + log.size - sizeof(uint16_t) - sizeof(uint32_t); + /* Write truncated payload */ if (dlt_user_log_write_raw(&log, payload, truncated_payload_len) < 0) { diff --git a/src/tests/dlt-test-client.c b/src/tests/dlt-test-client.c index 318bd32..6f1e972 100755 --- a/src/tests/dlt-test-client.c +++ b/src/tests/dlt-test-client.c @@ -78,7 +78,7 @@ #define DLT_TESTCLIENT_TEXTBUFSIZE 10024 /* Size of buffer for text output */ #define DLT_TESTCLIENT_ECU_ID "ECU1" -#define DLT_TESTCLIENT_NUM_TESTS 7 +#define DLT_TESTCLIENT_NUM_TESTS 9 /* Function prototypes */ int dlt_testclient_message_callback(DltMessage *message, void *data); @@ -1191,11 +1191,396 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) } } + /* check test 8m */ + if (strcmp(text,"Test 8: (Macro IF) Test truncated network trace")==0) + { + printf("Test8m: (Macro IF) Test truncated network trace\n"); + dltdata->running_test = 8; + dltdata->test_counter_macro[7]=0; + } + else if (strcmp(text,"Test8: (Macro IF) finished")==0) + { + if (dltdata->test_counter_macro[7]==20) + { + printf("Test8m PASSED\n"); + dltdata->tests_passed++; + } + else + { + printf("Test8m FAILED\n"); + dltdata->tests_failed++; + } + dltdata->running_test = 0; + } + else if (dltdata->running_test==8) + { + if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) + { + if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE) + { + /* Check message type information*/ + /* Each correct message type increases the counter by 1 */ + mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin); + + if (mtin==DLT_NW_TRACE_IPC) + { + dltdata->test_counter_macro[7]++; + } + if (mtin==DLT_NW_TRACE_CAN) + { + dltdata->test_counter_macro[7]++; + } + if (mtin==DLT_NW_TRACE_FLEXRAY) + { + dltdata->test_counter_macro[7]++; + } + if (mtin==DLT_NW_TRACE_MOST) + { + dltdata->test_counter_macro[7]++; + } + + /* Check payload, must be two arguments (2 raw data blocks) */ + /* If the payload is correct, the counter is increased by 1 */ + if (message->extendedheader->noar==4) + { + type_info=0; + type_info_tmp=0; + length=0,length_tmp=0; /* the macro can set this variable to -1 */ + + ptr = message->databuffer; + datalength = message->datasize; + + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_STRG) + { + // Read NWTR + char chdr[10]; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + DLT_MSG_READ_STRING(chdr, ptr, datalength, length); + + if(strcmp((char *)chdr, "NWTR")==0) + { + dltdata->test_counter_macro[7]++; + } + + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_RAWD) + { + char hdr[2048]; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + DLT_MSG_READ_STRING(hdr, ptr, datalength, length); + + if(length == 16 && hdr[15] == 15) + { + dltdata->test_counter_macro[7]++; + } + + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t orig_size; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + orig_size=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + if(orig_size == 1024*5) + { + dltdata->test_counter_macro[7]++; + } + + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_RAWD) + { + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + // Size of the truncated message after headers + if(length == 2003) + { + dltdata->test_counter_macro[7]++; + } + } + } + } + } + } + } + } + } + + + /* check test 9m */ + if (strcmp(text,"Test 9: (Macro IF) Test segmented network trace")==0) + { + printf("Test9m: (Macro IF) Test segmented network trace\n"); + dltdata->running_test = 9; + dltdata->test_counter_macro[8]=0; + } + else if (strcmp(text,"Test9: (Macro IF) finished")==0) + { + /* (Interface types) * (results per packet)*/ + if (dltdata->test_counter_macro[8]==4*35) + { + printf("Test9m PASSED\n"); + dltdata->tests_passed++; + } + else + { + printf("Test9m FAILED\n"); + dltdata->tests_failed++; + } + dltdata->running_test = 0; + } + else if (dltdata->running_test==9) + { + if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) + { + if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE) + { + /* Check message type information*/ + /* Each correct message type increases the counter by 1 */ + mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin); + + if (mtin==DLT_NW_TRACE_IPC) + { + dltdata->test_counter_macro[8]++; + } + if (mtin==DLT_NW_TRACE_CAN) + { + dltdata->test_counter_macro[8]++; + } + if (mtin==DLT_NW_TRACE_FLEXRAY) + { + dltdata->test_counter_macro[8]++; + } + if (mtin==DLT_NW_TRACE_MOST) + { + dltdata->test_counter_macro[8]++; + } + + /* Payload for first segmented message */ + if (message->extendedheader->noar==6) + { + /* verbose mode */ + type_info=0; + type_info_tmp=0; + length=0,length_tmp=0; /* the macro can set this variable to -1 */ + + ptr = message->databuffer; + datalength = message->datasize; + + /* NWST */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_STRG) + { + char chdr[10]; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + DLT_MSG_READ_STRING(chdr, ptr, datalength, length); + if(strcmp((char *)chdr, "NWST")==0) + { + dltdata->test_counter_macro[8]++; + } + + /* Streahandle */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t handle; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + if(handle > 0) + { + dltdata->test_counter_macro[8]++; + } + + /* Header */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_RAWD) + { + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + + // Test packet header size 16 + if(length == 16) + { + dltdata->test_counter_macro[8]++; + } + /* Skip data */ + ptr+=length; + datalength-=length; + + /* Payload size */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t pl_sz; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + pl_sz=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + + // Test packet payload size. + if(pl_sz == 5120) + { + dltdata->test_counter_macro[8]++; + } + + /* Segmentcount */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t scount; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + scount=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + + /* Test packet segment count 5 */ + if(scount == 5) + { + dltdata->test_counter_macro[8]++; + } + + /* Segment length */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t slen; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + slen=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + /* Default segment size 1024 */ + if(slen == 1024) + { + dltdata->test_counter_macro[8]++; + } + } + } + } + } + } + } + } + /* Data segment */ + else if (message->extendedheader->noar==4) + { + /* verbose mode */ + type_info=0; + type_info_tmp=0; + length=0,length_tmp=0; /* the macro can set this variable to -1 */ + + ptr = message->databuffer; + datalength = message->datasize; + + /* NWCH */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_STRG) + { + char chdr[10]; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + DLT_MSG_READ_STRING(chdr, ptr, datalength, length); + if(strcmp((char *)chdr, "NWCH")==0) + { + dltdata->test_counter_macro[8]++; + } + + /* handle */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t handle; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + if(handle > 0) + { + dltdata->test_counter_macro[8]++; + } + + /* Sequence */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t seq; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + dltdata->test_counter_macro[8]++; + + /* Data */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_RAWD) + { + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + + // Segment size by default, 1024 + if(length == 1024) + { + dltdata->test_counter_macro[8]++; + } + } + } + } + } + } + /* End segment */ + else if (message->extendedheader->noar==2) + { + /* verbose mode */ + type_info=0; + type_info_tmp=0; + length=0,length_tmp=0; /* the macro can set this variable to -1 */ + + ptr = message->databuffer; + datalength = message->datasize; + + /* NWEN */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_STRG) + { + char chdr[10]; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + DLT_MSG_READ_STRING(chdr, ptr, datalength, length); + if(strcmp((char *)chdr, "NWEN")==0) + { + dltdata->test_counter_macro[8]++; + } + + /* handle */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t handle; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + if(handle > 0) + { + dltdata->test_counter_macro[8]++; + } + } + } + } + } + } + } + /* check test 1f */ if (strcmp(text,"Test1: (Function IF) Test all log levels")==0) { printf("Test1f: (Function IF) Test all log levels\n"); - dltdata->running_test = 8; + dltdata->running_test = 10; dltdata->test_counter_function[0] = 0; } else if (strcmp(text,"Test1: (Function IF) finished")==0) @@ -1213,7 +1598,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) } dltdata->running_test = 0; } - else if (dltdata->running_test==8) + else if (dltdata->running_test==10) { if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) { @@ -1253,7 +1638,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) if (strcmp(text,"Test2: (Function IF) Test all variable types (verbose)")==0) { printf("Test2f: (Function IF) Test all variable types (verbose)\n"); - dltdata->running_test = 9; + dltdata->running_test = 11; dltdata->test_counter_function[1] = 0; } else if (strcmp(text,"Test2: (Function IF) finished")==0) @@ -1270,7 +1655,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) } dltdata->running_test = 0; } - else if (dltdata->running_test==9) + else if (dltdata->running_test==11) { /* Verbose */ if (!(DLT_MSG_IS_NONVERBOSE(message))) @@ -1457,7 +1842,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) if (strcmp(text,"Test3: (Function IF) Test all variable types (non-verbose)")==0) { printf("Test3f: (Function IF) Test all variable types (non-verbose)\n"); - dltdata->running_test = 10; + dltdata->running_test = 12; dltdata->test_counter_function[2]=0; } else if (strcmp(text,"Test3: (Function IF) finished")==0) @@ -1474,7 +1859,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) } dltdata->running_test = 0; } - else if (dltdata->running_test==10) + else if (dltdata->running_test==12) { /* Nonverbose */ if (DLT_MSG_IS_NONVERBOSE(message)) @@ -1668,7 +2053,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) if (strcmp(text,"Test4: (Function IF) Test different message sizes")==0) { printf("Test4f: (Function IF) Test different message sizes\n"); - dltdata->running_test = 11; + dltdata->running_test = 13; dltdata->test_counter_function[3]=0; } else if (strcmp(text,"Test4: (Function IF) finished")==0) @@ -1685,7 +2070,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) } dltdata->running_test = 0; } - else if (dltdata->running_test==11) + else if (dltdata->running_test==13) { /* Extended header */ if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) @@ -1752,7 +2137,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) if (strcmp(text,"Test5: (Function IF) Test high-level API")==0) { printf("Test5f: (Function IF) Test high-level API\n"); - dltdata->running_test = 12; + dltdata->running_test = 14; dltdata->test_counter_function[4]=0; } else if (strcmp(text,"Test5: (Function IF) finished")==0) @@ -1769,7 +2154,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) } dltdata->running_test = 0; } - else if (dltdata->running_test==12) + else if (dltdata->running_test==14) { if (strcmp(text,"Next line: dlt_log_int()")==0) { @@ -1830,7 +2215,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) if (strcmp(text,"Test 6: (Function IF) Test local printing")==0) { printf("Test6f: (Function IF) Test local printing\n"); - dltdata->running_test = 13; + dltdata->running_test = 15; dltdata->test_counter_function[5]=0; } else if (strcmp(text,"Test6: (Function IF) finished")==0) @@ -1847,7 +2232,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) } dltdata->running_test = 0; } - else if (dltdata->running_test==13) + else if (dltdata->running_test==15) { if (strcmp(text,"Message (visible: locally printed)")==0) { @@ -1865,7 +2250,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) if (strcmp(text,"Test 7: (Function IF) Test network trace")==0) { printf("Test7f: (Function IF) Test network trace\n"); - dltdata->running_test = 14; + dltdata->running_test = 16; dltdata->test_counter_function[6]=0; } else if (strcmp(text,"Test7: (Function IF) finished")==0) @@ -1882,7 +2267,7 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) } dltdata->running_test = 0; } - else if (dltdata->running_test==14) + else if (dltdata->running_test==16) { if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) { @@ -1961,6 +2346,390 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) } } + /* check test 8f */ + if (strcmp(text,"Test 8: (Function IF) Test truncated network trace")==0) + { + printf("Test8f: (Function IF) Test truncated network trace\n"); + dltdata->running_test = 17; + dltdata->test_counter_function[7]=0; + } + else if (strcmp(text,"Test8: (Function IF) finished")==0) + { + if (dltdata->test_counter_function[7]==20) + { + printf("Test8f PASSED\n"); + dltdata->tests_passed++; + } + else + { + printf("Test8f FAILED\n"); + dltdata->tests_failed++; + } + dltdata->running_test = 0; + } + else if (dltdata->running_test==17) + { + if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) + { + if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE) + { + /* Check message type information*/ + /* Each correct message type increases the counter by 1 */ + mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin); + + if (mtin==DLT_NW_TRACE_IPC) + { + dltdata->test_counter_function[7]++; + } + if (mtin==DLT_NW_TRACE_CAN) + { + dltdata->test_counter_function[7]++; + } + if (mtin==DLT_NW_TRACE_FLEXRAY) + { + dltdata->test_counter_function[7]++; + } + if (mtin==DLT_NW_TRACE_MOST) + { + dltdata->test_counter_function[7]++; + } + + /* Check payload, must be two arguments (2 raw data blocks) */ + /* If the payload is correct, the counter is increased by 1 */ + if (message->extendedheader->noar==4) + { + //TODO: CHECK ACTUAL CONTENT + type_info=0; + type_info_tmp=0; + length=0,length_tmp=0; /* the macro can set this variable to -1 */ + + ptr = message->databuffer; + datalength = message->datasize; + + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_STRG) + { + // Read NWTR + char chdr[10]; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + DLT_MSG_READ_STRING(chdr, ptr, datalength, length); + + if(strcmp((char *)chdr, "NWTR")==0) + { + dltdata->test_counter_function[7]++; + } + + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_RAWD) + { + char hdr[2048]; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + DLT_MSG_READ_STRING(hdr, ptr, datalength, length); + + if(length == 16 && hdr[15] == 15) + { + dltdata->test_counter_function[7]++; + } + + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t orig_size; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + orig_size=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + if(orig_size == 1024*5) + { + dltdata->test_counter_function[7]++; + } + + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_RAWD) + { + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + // Size of the truncated message after headers + if(length == 2003) + { + dltdata->test_counter_function[7]++; + } + } + } + } + } + } + } + } + } + + /* check test 9f */ + if (strcmp(text,"Test 9: (Function IF) Test segmented network trace")==0) + { + printf("Test9f: (Function IF) Test segmented network trace\n"); + dltdata->running_test = 18; + dltdata->test_counter_function[8]=0; + } + else if (strcmp(text,"Test9: (Function IF) finished")==0) + { + /* (Interface types) * (number of messages per complete message) */ + if (dltdata->test_counter_function[8]==4*35) + { + printf("Test9f PASSED\n"); + dltdata->tests_passed++; + } + else + { + printf("Test9f FAILED\n"); + dltdata->tests_failed++; + } + dltdata->running_test = 0; + } + else if (dltdata->running_test==18) + { + if (DLT_IS_HTYP_UEH(message->standardheader->htyp)) + { + if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE) + { + /* Check message type information*/ + /* Each correct message type increases the counter by 1 */ + mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin); + + if (mtin==DLT_NW_TRACE_IPC) + { + dltdata->test_counter_function[8]++; + } + if (mtin==DLT_NW_TRACE_CAN) + { + dltdata->test_counter_function[8]++; + } + if (mtin==DLT_NW_TRACE_FLEXRAY) + { + dltdata->test_counter_function[8]++; + } + if (mtin==DLT_NW_TRACE_MOST) + { + dltdata->test_counter_function[8]++; + } + + /* Payload for first segmented message */ + if (message->extendedheader->noar==6) + { + /* verbose mode */ + type_info=0; + type_info_tmp=0; + length=0,length_tmp=0; /* the macro can set this variable to -1 */ + + ptr = message->databuffer; + datalength = message->datasize; + + /* NWST */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_STRG) + { + char chdr[10]; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + DLT_MSG_READ_STRING(chdr, ptr, datalength, length); + if(strcmp((char *)chdr, "NWST")==0) + { + dltdata->test_counter_function[8]++; + } + + /* Streahandle */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t handle; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + if(handle > 0) + { + dltdata->test_counter_function[8]++; + } + + /* Header */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_RAWD) + { + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + + // Test packet header size 16 + if(length == 16) + { + dltdata->test_counter_function[8]++; + } + /* Skip data */ + ptr+=length; + datalength-=length; + + /* Payload size */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t pl_sz; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + pl_sz=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + + // Test packet payload size. + if(pl_sz == 5120) + { + dltdata->test_counter_function[8]++; + } + + /* Segmentcount */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t scount; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + scount=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + + /* Test packet segment count 5 */ + if(scount == 5) + { + dltdata->test_counter_function[8]++; + } + + /* Segment length */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t slen; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + slen=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + /* Default segment size 1024 */ + if(slen == 1024) + { + dltdata->test_counter_function[8]++; + } + } + } + } + } + } + } + } + /* Data segment */ + else if (message->extendedheader->noar==4) + { + /* verbose mode */ + type_info=0; + type_info_tmp=0; + length=0,length_tmp=0; /* the macro can set this variable to -1 */ + + ptr = message->databuffer; + datalength = message->datasize; + + /* NWCH */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_STRG) + { + char chdr[10]; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + DLT_MSG_READ_STRING(chdr, ptr, datalength, length); + if(strcmp((char *)chdr, "NWCH")==0) + { + dltdata->test_counter_function[8]++; + } + + /* handle */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t handle; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + if(handle > 0) + { + dltdata->test_counter_function[8]++; + } + + /* Sequence */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t seq; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + dltdata->test_counter_function[8]++; + + /* Data */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_RAWD) + { + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + + // Segment size by default, 1024 + if(length == 1024) + { + dltdata->test_counter_function[8]++; + } + } + } + } + } + } + /* End segment */ + else if (message->extendedheader->noar==2) + { + /* verbose mode */ + type_info=0; + type_info_tmp=0; + length=0,length_tmp=0; /* the macro can set this variable to -1 */ + + ptr = message->databuffer; + datalength = message->datasize; + + /* NWEN */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_STRG) + { + char chdr[10]; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + DLT_MSG_READ_STRING(chdr, ptr, datalength, length); + if(strcmp((char *)chdr, "NWEN")==0) + { + dltdata->test_counter_function[8]++; + } + + /* handle */ + DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t); + type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp); + if(type_info & DLT_TYPE_INFO_UINT) + { + uint16_t handle; + DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t); + handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp); + if(handle > 0) + { + dltdata->test_counter_function[8]++; + } + } + } + } + } + } + } if (strcmp(text,"Tests finished")==0) { printf("Tests finished\n"); diff --git a/src/tests/dlt-test-user.c b/src/tests/dlt-test-user.c index be4e654..67cd6e8 100755 --- a/src/tests/dlt-test-user.c +++ b/src/tests/dlt-test-user.c @@ -1,30 +1,30 @@ -/** - * @licence app begin@ - * Copyright (C) 2012 BMW AG - * - * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps. - * - * Contributions are licensed to the GENIVI Alliance under one or more - * Contribution License Agreements. - * - * \copyright - * This Source Code Form is subject to the terms of the - * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with - * this file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * - * \author Alexander Wenzel BMW 2011-2012 - * - * \file dlt-test-user.c - * For further information see http://www.genivi.org/. - * @licence end@ - */ - - -/******************************************************************************* -** ** -** SRC-MODULE: dlt-test-user.c ** -** ** +/** + * @licence app begin@ + * Copyright (C) 2012 BMW AG + * + * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps. + * + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Alexander Wenzel BMW 2011-2012 + * + * \file dlt-test-user.c + * For further information see http://www.genivi.org/. + * @licence end@ + */ + + +/******************************************************************************* +** ** +** SRC-MODULE: dlt-test-user.c ** +** ** ** TARGET : linux ** ** ** ** PROJECT : DLT ** @@ -50,19 +50,19 @@ ** -------- ------------------------- ---------------------------------- ** ** aw Alexander Wenzel BMW ** ** mk Markus Klein Fraunhofer ESK ** -*******************************************************************************/ - -/******************************************************************************* -** Revision Control History ** -*******************************************************************************/ - -/* - * $LastChangedRevision: 1670 $ - * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $ - * $LastChangedBy$ - Initials Date Comment - aw 13.01.2010 initial - */ +*******************************************************************************/ + +/******************************************************************************* +** Revision Control History ** +*******************************************************************************/ + +/* + * $LastChangedRevision: 1670 $ + * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $ + * $LastChangedBy$ + Initials Date Comment + aw 13.01.2010 initial + */ #include /* for printf() and fprintf() */ #include @@ -72,7 +72,7 @@ #include "dlt.h" -#define DLT_TEST_NUM_CONTEXT 7 +#define DLT_TEST_NUM_CONTEXT 9 /* Test functions... */ @@ -84,6 +84,8 @@ int test4m(void); int test5m(void); int test6m(void); int test7m(void); +int test8m(void); +int test9m(void); /* for function interface */ int test1f(void); @@ -93,6 +95,8 @@ int test4f(void); int test5f(void); int test6f(void); int test7f(void); +int test8f(void); +int test9f(void); /* Declaration of callback functions */ int test_injection_macro_callback(uint32_t service_id, void *data, uint32_t length); @@ -106,28 +110,28 @@ DLT_DECLARE_CONTEXT(context_macro_callback); DLT_DECLARE_CONTEXT(context_macro_test[DLT_TEST_NUM_CONTEXT]); /* for function interface */ -DltContext context_function_callback; +DltContext context_function_callback; DltContext context_function_test[DLT_TEST_NUM_CONTEXT]; -DltContextData context_data; - -/** - * Print usage information of tool. - */ -void usage() -{ - char version[255]; - - dlt_get_version(version); - - printf("Usage: dlt-test-user [options]\n"); - printf("Test user application providing several Tests.\n"); - printf("%s \n", version); - printf("Options:\n"); - printf(" -v Verbose mode\n"); - printf(" -f filename Use local log file instead of sending to daemon\n"); - printf(" -n count Repeats of tests (Default: 1)\n"); - printf("Tests:\n"); +DltContextData context_data; + +/** + * Print usage information of tool. + */ +void usage() +{ + char version[255]; + + dlt_get_version(version); + + printf("Usage: dlt-test-user [options]\n"); + printf("Test user application providing several Tests.\n"); + printf("%s \n", version); + printf("Options:\n"); + printf(" -v Verbose mode\n"); + printf(" -f filename Use local log file instead of sending to daemon\n"); + printf(" -n count Repeats of tests (Default: 1)\n"); + printf("Tests:\n"); printf(" 1m: (Macro IF) Test all log levels\n"); printf(" 2m: (Macro IF) Test all variable types (verbose) \n"); printf(" 3m: (Macro IF) Test all variable types (non-verbose) \n"); @@ -135,91 +139,95 @@ void usage() printf(" 5m: (Macro IF) Test high-level API\n"); printf(" 6m: (Macro IF) Test local printing\n"); printf(" 7m: (Macro IF) Test network trace\n"); + printf(" 8m: (Macro IF) Test truncated network trace\n"); + printf(" 9m: (Macro IF) Test segmented network trace\n"); printf(" 1f: (Function IF) Test all log levels\n"); printf(" 2f: (Function IF) Test all variable types (verbose) \n"); printf(" 3f: (Function IF) Test all variable types (non-verbose) \n"); printf(" 4f: (Function IF) Test different message sizes\n"); printf(" 5f: (Function IF) Test high-level API\n"); printf(" 6f: (Function IF) Test local printing\n"); - printf(" 7f: (Function IF) Test network trace\n"); -} - -/** - * Main function of tool. - */ -int main(int argc, char* argv[]) -{ - //int vflag = 0; - char *fvalue = 0; + printf(" 7f: (Function IF) Test network trace\n"); + printf(" 8f: (Function IF) Test truncated network trace\n"); + printf(" 9f: (Function IF) Test segmented network trace\n"); +} + +/** + * Main function of tool. + */ +int main(int argc, char* argv[]) +{ + //int vflag = 0; + char *fvalue = 0; char *nvalue = 0; - + int c; int i; char ctid[4], ctdesc[255]; - int num,maxnum; - - opterr = 0; - + int num,maxnum; + + opterr = 0; + while ((c = getopt (argc, argv, "vf:n:")) != -1) - { - switch (c) - { + { + switch (c) + { case 'v': - { - //vflag = 1; - break; + { + //vflag = 1; + break; } - case 'f': + case 'f': { - fvalue = optarg; - break; + fvalue = optarg; + break; } - case 'n': + case 'n': { - nvalue = optarg; - break; + nvalue = optarg; + break; } case '?': - { - if (optopt == 'd' || optopt == 'f' || optopt == 'n') + { + if (optopt == 'd' || optopt == 'f' || optopt == 'n') { - fprintf (stderr, "Option -%c requires an argument.\n", optopt); + fprintf (stderr, "Option -%c requires an argument.\n", optopt); } - else if (isprint (optopt)) + else if (isprint (optopt)) { - fprintf (stderr, "Unknown option `-%c'.\n", optopt); + fprintf (stderr, "Unknown option `-%c'.\n", optopt); } - else + else { - fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt); + fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt); } - /* unknown or wrong option used, show usage information and terminate */ - usage(); - return -1; + /* unknown or wrong option used, show usage information and terminate */ + usage(); + return -1; } - default: + default: { - abort (); + abort (); } } - } - - if (fvalue) - { - /* DLT is intialised automatically, except another output target will be used */ + } + + if (fvalue) + { + /* DLT is intialised automatically, except another output target will be used */ if (dlt_init_file(fvalue)<0) /* log to file */ - { + { return -1; - } + } } - + if (nvalue) - { - maxnum = atoi(nvalue); + { + maxnum = atoi(nvalue); } - else + else { maxnum = 1; } @@ -227,7 +235,7 @@ int main(int argc, char* argv[]) /* Register APP */ DLT_REGISTER_APP("DIFT","DLT Interface Test"); - /* Register CONTEXTS... */ + /* Register CONTEXTS... */ DLT_REGISTER_CONTEXT(context_info,"INFO","Information context"); /* used for macro interface tests */ @@ -255,52 +263,56 @@ int main(int argc, char* argv[]) DLT_REGISTER_INJECTION_CALLBACK(context_macro_callback, 0xFFF, test_injection_macro_callback); /* with function interface */ - if (dlt_user_log_write_start(&context_function_callback,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Register callback (Function Interface) for Injection ID: 0xFFF"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_function_callback,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Register callback (Function Interface) for Injection ID: 0xFFF"); + dlt_user_log_write_finish(&context_data); } dlt_register_injection_callback(&context_function_callback, 0xFFF, test_injection_function_callback); - - /* Tests starting */ - printf("Tests starting\n"); - DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Tests starting")); - - /* wait 3 seconds before starting */ - sleep(3); - - for (num=0;num0) - { - dlt_user_log_write_string(&context_data,"Test1: (Function IF) Test all log levels"); - dlt_user_log_write_finish(&context_data); - } - - if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_FATAL)>0) - { - dlt_user_log_write_string(&context_data,"fatal"); - dlt_user_log_write_finish(&context_data); - } - if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_ERROR)>0) - { - dlt_user_log_write_string(&context_data,"error"); - dlt_user_log_write_finish(&context_data); - } - if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_WARN)>0) - { - dlt_user_log_write_string(&context_data,"warn"); - dlt_user_log_write_finish(&context_data); - } - if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"info"); - dlt_user_log_write_finish(&context_data); - } - if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_DEBUG)>0) - { - dlt_user_log_write_string(&context_data,"debug"); - dlt_user_log_write_finish(&context_data); - } - if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_VERBOSE)>0) - { - dlt_user_log_write_string(&context_data,"verbose"); - dlt_user_log_write_finish(&context_data); - } - - /* wait 2 second before next test */ + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test1: (Function IF) Test all log levels"); + dlt_user_log_write_finish(&context_data); + } + + if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_FATAL)>0) + { + dlt_user_log_write_string(&context_data,"fatal"); + dlt_user_log_write_finish(&context_data); + } + if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_ERROR)>0) + { + dlt_user_log_write_string(&context_data,"error"); + dlt_user_log_write_finish(&context_data); + } + if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_WARN)>0) + { + dlt_user_log_write_string(&context_data,"warn"); + dlt_user_log_write_finish(&context_data); + } + if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"info"); + dlt_user_log_write_finish(&context_data); + } + if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_DEBUG)>0) + { + dlt_user_log_write_string(&context_data,"debug"); + dlt_user_log_write_finish(&context_data); + } + if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_VERBOSE)>0) + { + dlt_user_log_write_string(&context_data,"verbose"); + dlt_user_log_write_finish(&context_data); + } + + /* wait 2 second before next test */ sleep(2); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test1: (Function IF) finished"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test1: (Function IF) finished"); + dlt_user_log_write_finish(&context_data); } return 0; @@ -603,116 +681,116 @@ int test2f(void) char buffer[10]; int num2; - /* Test 2: (Function IF) Test all variable types (verbose) */ + /* Test 2: (Function IF) Test all variable types (verbose) */ printf("Test2f: (Function IF) Test all variable types (verbose)\n"); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test2: (Function IF) Test all variable types (verbose)"); - dlt_user_log_write_finish(&context_data); - } - - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test2: (Function IF) Test all variable types (verbose)"); + dlt_user_log_write_finish(&context_data); + } + + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"bool"); - dlt_user_log_write_bool(&context_data,1); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_bool(&context_data,1); + dlt_user_log_write_finish(&context_data); } - - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"int"); - dlt_user_log_write_int(&context_data,INT32_MIN); /* (-2147483647-1) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_int(&context_data,INT32_MIN); /* (-2147483647-1) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"int8"); - dlt_user_log_write_int8(&context_data,INT8_MIN); /* (-128) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_int8(&context_data,INT8_MIN); /* (-128) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"int16"); - dlt_user_log_write_int16(&context_data,INT16_MIN); /* (-32767-1) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_int16(&context_data,INT16_MIN); /* (-32767-1) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"int32"); - dlt_user_log_write_int32(&context_data,INT32_MIN); /* (-2147483647-1) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_int32(&context_data,INT32_MIN); /* (-2147483647-1) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"int64"); - dlt_user_log_write_int64(&context_data,INT64_MIN); /* (-__INT64_C(9223372036854775807)-1) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_int64(&context_data,INT64_MIN); /* (-__INT64_C(9223372036854775807)-1) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"uint"); - dlt_user_log_write_uint(&context_data,UINT32_MAX); /* (4294967295U) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_uint(&context_data,UINT32_MAX); /* (4294967295U) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"uint8"); - dlt_user_log_write_uint8(&context_data,UINT8_MAX); /* (255) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_uint8(&context_data,UINT8_MAX); /* (255) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"uint16"); - dlt_user_log_write_uint16(&context_data,UINT16_MAX); /* (65535) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_uint16(&context_data,UINT16_MAX); /* (65535) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"uint32"); - dlt_user_log_write_uint32(&context_data,UINT32_MAX); /* (4294967295U) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_uint32(&context_data,UINT32_MAX); /* (4294967295U) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"uint64"); - dlt_user_log_write_uint64(&context_data,UINT64_MAX); /* (__UINT64_C(18446744073709551615)) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_uint64(&context_data,UINT64_MAX); /* (__UINT64_C(18446744073709551615)) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"float32"); dlt_user_log_write_float32(&context_data,FLT_MIN); - dlt_user_log_write_float32(&context_data,FLT_MAX); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_float32(&context_data,FLT_MAX); + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"float64"); dlt_user_log_write_float64(&context_data,DBL_MIN); - dlt_user_log_write_float64(&context_data,DBL_MAX); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_float64(&context_data,DBL_MAX); + dlt_user_log_write_finish(&context_data); } for(num2=0;num2<10;num2++) - { + { buffer[num2] = num2; } - if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"raw"); - dlt_user_log_write_raw(&context_data,buffer,10); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_raw(&context_data,buffer,10); + dlt_user_log_write_finish(&context_data); } - /* wait 2 second before next test */ + /* wait 2 second before next test */ sleep(2); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test2: (Function IF) finished"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test2: (Function IF) finished"); + dlt_user_log_write_finish(&context_data); } return 0; @@ -723,120 +801,120 @@ int test3f(void) char buffer[10]; int num2; - /* Test 3: (Function IF) Test all variable types (non-verbose) */ + /* Test 3: (Function IF) Test all variable types (non-verbose) */ printf("Test3f: (Function IF) Test all variable types (non-verbose)\n"); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test3: (Function IF) Test all variable types (non-verbose)"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test3: (Function IF) Test all variable types (non-verbose)"); + dlt_user_log_write_finish(&context_data); } - dlt_nonverbose_mode(); + dlt_nonverbose_mode(); - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,1)>0) // bug mb: we have to compare against >0. in case of error -1 is returned! - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,1)>0) // bug mb: we have to compare against >0. in case of error -1 is returned! + { dlt_user_log_write_string(&context_data,"bool"); - dlt_user_log_write_bool(&context_data,1); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_bool(&context_data,1); + dlt_user_log_write_finish(&context_data); } - - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,2)>0) - { + + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,2)>0) + { dlt_user_log_write_string(&context_data,"int"); - dlt_user_log_write_int(&context_data,INT32_MIN); /* (-2147483647-1) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_int(&context_data,INT32_MIN); /* (-2147483647-1) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,3)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,3)>0) + { dlt_user_log_write_string(&context_data,"int8"); - dlt_user_log_write_int8(&context_data,INT8_MIN); /* (-128) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_int8(&context_data,INT8_MIN); /* (-128) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,4)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,4)>0) + { dlt_user_log_write_string(&context_data,"int16"); - dlt_user_log_write_int16(&context_data,INT16_MIN); /* (-32767-1) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_int16(&context_data,INT16_MIN); /* (-32767-1) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,5)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,5)>0) + { dlt_user_log_write_string(&context_data,"int32"); - dlt_user_log_write_int32(&context_data,INT32_MIN); /* (-2147483647-1) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_int32(&context_data,INT32_MIN); /* (-2147483647-1) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,6)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,6)>0) + { dlt_user_log_write_string(&context_data,"int64"); - dlt_user_log_write_int64(&context_data,INT64_MIN); /* (-__INT64_C(9223372036854775807)-1) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_int64(&context_data,INT64_MIN); /* (-__INT64_C(9223372036854775807)-1) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,7)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,7)>0) + { dlt_user_log_write_string(&context_data,"uint"); - dlt_user_log_write_uint(&context_data,UINT32_MAX); /* (4294967295U) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_uint(&context_data,UINT32_MAX); /* (4294967295U) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,8)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,8)>0) + { dlt_user_log_write_string(&context_data,"uint8"); - dlt_user_log_write_uint8(&context_data,UINT8_MAX); /* (255) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_uint8(&context_data,UINT8_MAX); /* (255) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,9)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,9)>0) + { dlt_user_log_write_string(&context_data,"uint16"); - dlt_user_log_write_uint16(&context_data,UINT16_MAX); /* (65535) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_uint16(&context_data,UINT16_MAX); /* (65535) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,10)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,10)>0) + { dlt_user_log_write_string(&context_data,"uint32"); - dlt_user_log_write_uint32(&context_data,UINT32_MAX); /* (4294967295U) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_uint32(&context_data,UINT32_MAX); /* (4294967295U) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,11)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,11)>0) + { dlt_user_log_write_string(&context_data,"uint64"); - dlt_user_log_write_uint64(&context_data,UINT64_MAX); /* (__UINT64_C(18446744073709551615)) */ - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_uint64(&context_data,UINT64_MAX); /* (__UINT64_C(18446744073709551615)) */ + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,12)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,12)>0) + { dlt_user_log_write_string(&context_data,"float32"); dlt_user_log_write_float32(&context_data,FLT_MIN); - dlt_user_log_write_float32(&context_data,FLT_MAX); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_float32(&context_data,FLT_MAX); + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,13)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,13)>0) + { dlt_user_log_write_string(&context_data,"float64"); dlt_user_log_write_float64(&context_data,DBL_MIN); - dlt_user_log_write_float64(&context_data,DBL_MAX); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_float64(&context_data,DBL_MAX); + dlt_user_log_write_finish(&context_data); } - + for(num2=0;num2<10;num2++) - { + { buffer[num2] = num2; } - if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,14)>0) - { + if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,14)>0) + { dlt_user_log_write_string(&context_data,"raw"); - dlt_user_log_write_raw(&context_data,buffer,10); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_raw(&context_data,buffer,10); + dlt_user_log_write_finish(&context_data); } dlt_verbose_mode(); - /* wait 2 second before next test */ + /* wait 2 second before next test */ sleep(2); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test3: (Function IF) finished"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test3: (Function IF) finished"); + dlt_user_log_write_finish(&context_data); } return 0; @@ -844,53 +922,53 @@ int test3f(void) int test4f(void) { - char buffer[1024]; + char buffer[1024]; int num; - + for(num=0;num<1024;num++) - { + { buffer[num] = num; } - /* Test 4: (Function IF) Message size test */ + /* Test 4: (Function IF) Message size test */ printf("Test4f: (Function IF) Test different message sizes\n"); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test4: (Function IF) Test different message sizes"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test4: (Function IF) Test different message sizes"); + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"1"); - dlt_user_log_write_raw(&context_data,buffer,1); - dlt_user_log_write_finish(&context_data); - } - if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0) - { + dlt_user_log_write_raw(&context_data,buffer,1); + dlt_user_log_write_finish(&context_data); + } + if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"16"); - dlt_user_log_write_raw(&context_data,buffer,16); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_raw(&context_data,buffer,16); + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"256"); - dlt_user_log_write_raw(&context_data,buffer,256); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_raw(&context_data,buffer,256); + dlt_user_log_write_finish(&context_data); } - if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0) - { + if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0) + { dlt_user_log_write_string(&context_data,"1024"); - dlt_user_log_write_raw(&context_data,buffer,1024); - dlt_user_log_write_finish(&context_data); + dlt_user_log_write_raw(&context_data,buffer,1024); + dlt_user_log_write_finish(&context_data); } - /* wait 2 second before next test */ + /* wait 2 second before next test */ sleep(2); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test4: (Function IF) finished"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test4: (Function IF) finished"); + dlt_user_log_write_finish(&context_data); } return 0; @@ -898,15 +976,15 @@ int test4f(void) int test5f(void) { - char buffer[32]; - int num; + char buffer[32]; + int num; for(num=0;num<32;num++) - { + { buffer[num] = num; } - /* Test 5: (Function IF) Test high-level API */ + /* Test 5: (Function IF) Test high-level API */ printf("Test5f: (Function IF) Test high-level API\n"); dlt_log_string(&context_info,DLT_LOG_INFO,"Test5: (Function IF) Test high-level API"); @@ -928,7 +1006,7 @@ int test5f(void) dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_string_uint()"); dlt_log_string_uint(&(context_function_test[4]), DLT_LOG_INFO,"String output: ", 42); - /* wait 2 second before next test */ + /* wait 2 second before next test */ sleep(2); dlt_log_string(&context_info,DLT_LOG_INFO,"Test5: (Function IF) finished"); @@ -939,32 +1017,32 @@ int test6f(void) { /* Test 6: (Function IF) Test local printing */ printf("Test6f: (Function IF) Test local printing\n"); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test 6: (Function IF) Test local printing"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test 6: (Function IF) Test local printing"); + dlt_user_log_write_finish(&context_data); } dlt_enable_local_print(); - if (dlt_user_log_write_start(&(context_function_test[5]),&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Message (visible: locally printed)"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&(context_function_test[5]),&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Message (visible: locally printed)"); + dlt_user_log_write_finish(&context_data); } dlt_disable_local_print(); - if (dlt_user_log_write_start(&(context_function_test[5]),&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Message (invisible: not locally printed)"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&(context_function_test[5]),&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Message (invisible: not locally printed)"); + dlt_user_log_write_finish(&context_data); } - /* wait 2 second before next test */ + /* wait 2 second before next test */ sleep(2); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test6: (Function IF) finished"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test6: (Function IF) finished"); + dlt_user_log_write_finish(&context_data); } return 0; @@ -972,11 +1050,11 @@ int test6f(void) int test7f(void) { - char buffer[32]; + char buffer[32]; int num; - + for(num=0;num<32;num++) - { + { buffer[num] = num; } @@ -985,10 +1063,10 @@ int test7f(void) /* Test 7: (Function IF) Test network trace */ printf("Test7f: (Function IF) Test network trace\n"); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test 7: (Function IF) Test network trace"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test 7: (Function IF) Test network trace"); + dlt_user_log_write_finish(&context_data); } /* Dummy message: 16 byte header, 32 byte payload */ @@ -997,54 +1075,136 @@ int test7f(void) dlt_user_trace_network(&(context_function_test[6]), DLT_NW_TRACE_FLEXRAY, 16, buffer, 32, buffer); dlt_user_trace_network(&(context_function_test[6]), DLT_NW_TRACE_MOST, 16, buffer, 32, buffer); - /* wait 2 second before next test */ + /* wait 2 second before next test */ + sleep(2); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test7: (Function IF) finished"); + dlt_user_log_write_finish(&context_data); + } + + dlt_set_application_ll_ts_limit(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT); + sleep(2); + + return 0; +} + +int test8f(void) +{ + char buffer[1024*5]; + int num; + + for(num=0;num<1024*5;num++) + { + buffer[num] = num; + } + + /* Show all log messages and traces */ + dlt_set_application_ll_ts_limit(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON); + + /* Test 8: (Function IF) Test truncated network trace */ + printf("Test8f: (Function IF) Test truncated network trace\n"); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test 8: (Function IF) Test truncated network trace"); + dlt_user_log_write_finish(&context_data); + } + + /* Dummy message: 16 byte header, 32 byte payload */ + dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_IPC, 16, buffer, 1024*5, buffer, 1); + dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_CAN, 16, buffer, 1024*5, buffer, 1); + dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024*5, buffer, 1); + dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_MOST, 16, buffer, 1024*5, buffer, 1); + + /* wait 2 second before next test */ + sleep(2); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test8: (Function IF) finished"); + dlt_user_log_write_finish(&context_data); + } + + dlt_set_application_ll_ts_limit(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT); + sleep(2); + + return 0; +} + +int test9f(void) +{ + char buffer[1024*5]; + int num; + + for(num=0;num<1024*5;num++) + { + buffer[num] = num; + } + + /* Show all log messages and traces */ + dlt_set_application_ll_ts_limit(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON); + + /* Test 9: (Function IF) Test segmented network trace */ + printf("Test9f: (Function IF) Test segmented network trace\n"); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test 9: (Function IF) Test segmented network trace"); + dlt_user_log_write_finish(&context_data); + } + + /* Dummy message: 16 byte header, 5k payload */ + dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_IPC, 16, buffer, 1024*5, buffer); + dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_CAN, 16, buffer, 1024*5, buffer); + dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024*5, buffer); + dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_MOST, 16, buffer, 1024*5, buffer); + + /* wait 2 second before next test */ sleep(2); - if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) - { - dlt_user_log_write_string(&context_data,"Test7: (Function IF) finished"); - dlt_user_log_write_finish(&context_data); + if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0) + { + dlt_user_log_write_string(&context_data,"Test9: (Function IF) finished"); + dlt_user_log_write_finish(&context_data); } dlt_set_application_ll_ts_limit(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT); - sleep(2); + sleep(2); return 0; } -int test_injection_macro_callback(uint32_t service_id, void *data, uint32_t length) -{ +int test_injection_macro_callback(uint32_t service_id, void *data, uint32_t length) +{ char text[1024]; - memset(text,0,1024); + memset(text,0,1024); snprintf(text,1024,"Injection received (macro IF). ID: 0x%.4x, Length: %d",service_id,length); printf("%s \n", text); DLT_LOG(context_macro_callback, DLT_LOG_INFO, DLT_STRING("Injection received (macro IF). ID: "), DLT_UINT32(service_id),DLT_STRING("Data:"),DLT_STRING(text)); memset(text,0,1024); - - if (length>0) - { - dlt_print_mixed_string(text,1024,data,length,0); - printf("%s \n", text); - } - - return 0; + + if (length>0) + { + dlt_print_mixed_string(text,1024,data,length,0); + printf("%s \n", text); + } + + return 0; } int test_injection_function_callback(uint32_t service_id, void *data, uint32_t length) { char text[1024]; - memset(text,0,1024); - + memset(text,0,1024); + snprintf(text,1024,"Injection received (function IF). ID: 0x%.4x, Length: %d",service_id,length); printf("%s \n", text); DLT_LOG(context_function_callback, DLT_LOG_INFO, DLT_STRING("Injection received (function IF). ID: "), DLT_UINT32(service_id),DLT_STRING("Data:"),DLT_STRING(text)); memset(text,0,1024); - - if (length>0) - { - dlt_print_mixed_string(text,1024,data,length,0); - printf("%s \n", text); + + if (length>0) + { + dlt_print_mixed_string(text,1024,data,length,0); + printf("%s \n", text); } return 0; -- cgit v1.2.1