Bug 84 - Adding utf8 support to dlt-daemon, dlt-viewer. Modified patch, originally...
[profile/ivi/dlt-daemon.git] / src / tests / dlt-test-user.c
1 /**
2  * @licence app begin@
3  * Copyright (C) 2012  BMW AG
4  *
5  * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
6  *
7  * Contributions are licensed to the GENIVI Alliance under one or more
8  * Contribution License Agreements.
9  *
10  * \copyright
11  * This Source Code Form is subject to the terms of the
12  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
13  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
14  *
15  *
16  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de> BMW 2011-2012
17  *
18  * \file dlt-test-user.c
19  * For further information see http://www.genivi.org/.
20  * @licence end@
21  */
22
23
24 /*******************************************************************************
25 **                                                                            **
26 **  SRC-MODULE: dlt-test-user.c                                               **
27 **                                                                            **
28 **  TARGET    : linux                                                         **
29 **                                                                            **
30 **  PROJECT   : DLT                                                           **
31 **                                                                            **
32 **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
33 **              Markus Klein                                                  **
34 **                                                                            **
35 **  PURPOSE   :                                                               **
36 **                                                                            **
37 **  REMARKS   :                                                               **
38 **                                                                            **
39 **  PLATFORM DEPENDANT [yes/no]: yes                                          **
40 **                                                                            **
41 **  TO BE CHANGED BY USER [yes/no]: no                                        **
42 **                                                                            **
43 *******************************************************************************/
44
45 /*******************************************************************************
46 **                      Author Identity                                       **
47 ********************************************************************************
48 **                                                                            **
49 ** Initials     Name                       Company                            **
50 ** --------     -------------------------  ---------------------------------- **
51 **  aw          Alexander Wenzel           BMW                                **
52 **  mk          Markus Klein               Fraunhofer ESK                     **
53 *******************************************************************************/
54
55 /*******************************************************************************
56 **                      Revision Control History                              **
57 *******************************************************************************/
58
59 /*
60  * $LastChangedRevision: 1670 $
61  * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
62  * $LastChangedBy$
63  Initials    Date         Comment
64  aw          13.01.2010   initial
65  */
66
67 #include <stdio.h>      /* for printf() and fprintf() */
68 #include <float.h>
69 #include <stdlib.h>     /* for atoi(), abort() */
70 #include <string.h>     /* for memset() */
71 #include <ctype.h>      /* for isprint() */
72
73 #include "dlt.h"
74
75 #define DLT_TEST_NUM_CONTEXT 9
76
77 /* Test functions... */
78
79 /* for macro interface */
80 int test1m(void);
81 int test2m(void);
82 int test3m(void);
83 int test4m(void);
84 int test5m(void);
85 int test6m(void);
86 int test7m(void);
87 int test8m(void);
88 int test9m(void);
89
90 /* for function interface */
91 int test1f(void);
92 int test2f(void);
93 int test3f(void);
94 int test4f(void);
95 int test5f(void);
96 int test6f(void);
97 int test7f(void);
98 int test8f(void);
99 int test9f(void);
100
101 /* Declaration of callback functions */
102 int test_injection_macro_callback(uint32_t service_id, void *data, uint32_t length);
103 int test_injection_function_callback(uint32_t service_id, void *data, uint32_t length);
104
105 /* Context declaration.. */
106 DLT_DECLARE_CONTEXT(context_info);
107
108 /* for macro interface */
109 DLT_DECLARE_CONTEXT(context_macro_callback);
110 DLT_DECLARE_CONTEXT(context_macro_test[DLT_TEST_NUM_CONTEXT]);
111
112 /* for function interface */
113 DltContext context_function_callback;
114 DltContext context_function_test[DLT_TEST_NUM_CONTEXT];
115
116 DltContextData context_data;
117
118 /**
119  * Print usage information of tool.
120  */
121 void usage()
122 {
123         char version[255];
124
125         dlt_get_version(version);
126
127         printf("Usage: dlt-test-user [options]\n");
128         printf("Test user application providing several Tests.\n");
129         printf("%s \n", version);
130         printf("Options:\n");
131         printf("  -v            Verbose mode\n");
132         printf("  -f filename   Use local log file instead of sending to daemon\n");
133         printf("  -n count      Repeats of tests (Default: 1)\n");
134         printf("Tests:\n");
135         printf("  1m: (Macro IF)    Test all log levels\n");
136         printf("  2m: (Macro IF)    Test all variable types (verbose) \n");
137         printf("  3m: (Macro IF)    Test all variable types (non-verbose) \n");
138         printf("  4m: (Macro IF)    Test different message sizes\n");
139         printf("  5m: (Macro IF)    Test high-level API\n");
140         printf("  6m: (Macro IF)    Test local printing\n");
141         printf("  7m: (Macro IF)    Test network trace\n");
142         printf("  8m: (Macro IF)    Test truncated network trace\n");
143         printf("  9m: (Macro IF)    Test segmented network trace\n");
144         printf("  1f: (Function IF) Test all log levels\n");
145         printf("  2f: (Function IF) Test all variable types (verbose) \n");
146         printf("  3f: (Function IF) Test all variable types (non-verbose) \n");
147         printf("  4f: (Function IF) Test different message sizes\n");
148         printf("  5f: (Function IF) Test high-level API\n");
149         printf("  6f: (Function IF) Test local printing\n");
150         printf("  7f: (Function IF) Test network trace\n");
151         printf("  8f: (Function IF) Test truncated network trace\n");
152         printf("  9f: (Function IF) Test segmented network trace\n");
153 }
154
155 /**
156  * Main function of tool.
157  */
158 int main(int argc, char* argv[])
159 {
160     //int vflag = 0;
161     char *fvalue = 0;
162     char *nvalue = 0;
163
164     int c;
165
166         int i;
167         char ctid[4], ctdesc[255];
168
169         int num,maxnum;
170
171     opterr = 0;
172
173     while ((c = getopt (argc, argv, "vf:n:")) != -1)
174         {
175         switch (c)
176         {
177         case 'v':
178         {
179             //vflag = 1;
180             break;
181         }
182         case 'f':
183         {
184             fvalue = optarg;
185             break;
186         }
187         case 'n':
188         {
189             nvalue = optarg;
190             break;
191         }
192         case '?':
193         {
194             if (optopt == 'd' || optopt == 'f' || optopt == 'n')
195             {
196                 fprintf (stderr, "Option -%c requires an argument.\n", optopt);
197             }
198             else if (isprint (optopt))
199             {
200                 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
201             }
202             else
203             {
204                 fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
205             }
206             /* unknown or wrong option used, show usage information and terminate */
207             usage();
208             return -1;
209         }
210         default:
211         {
212             abort ();
213             return -1;//for parasoft
214         }
215         }
216         }
217
218     if (fvalue)
219     {
220         /* DLT is intialised automatically, except another output target will be used */
221         if (dlt_init_file(fvalue)<0) /* log to file */
222         {
223             return -1;
224         }
225     }
226
227     if (nvalue)
228     {
229         maxnum = atoi(nvalue);
230     }
231     else
232     {
233         maxnum = 1;
234     }
235
236         /* Register APP */
237         DLT_REGISTER_APP("DIFT","DLT Interface Test");
238
239         /* Register CONTEXTS... */
240         DLT_REGISTER_CONTEXT(context_info,"INFO","Information context");
241
242         /* used for macro interface tests */
243         DLT_REGISTER_CONTEXT(context_macro_callback,"CBM","Callback Test context for macro interface");
244         for (i=0;i<DLT_TEST_NUM_CONTEXT;i++)
245         {
246                 snprintf(ctid,4,"TM%d",i+1);
247                 snprintf(ctdesc,255,"Test %d context for macro interface",i+1);
248                 DLT_REGISTER_CONTEXT(context_macro_test[i],ctid,ctdesc);
249         }
250
251         /* used for function interface tests */
252         dlt_register_context(&context_function_callback,"CBF","Callback Test context for function interface");
253         for (i=0;i<DLT_TEST_NUM_CONTEXT;i++)
254         {
255                 snprintf(ctid,4,"TF%d",i+1);
256                 snprintf(ctdesc,255,"Test %d context for function interface",i+1);
257                 dlt_register_context(&(context_function_test[i]),ctid,ctdesc);
258         }
259
260         /* Register callbacks... */
261
262         /* with macro interface */
263         DLT_LOG(context_macro_callback,DLT_LOG_INFO,DLT_STRING("Register callback (Macro Interface) for Injection ID: 0xFFF"));
264         DLT_REGISTER_INJECTION_CALLBACK(context_macro_callback, 0xFFF, test_injection_macro_callback);
265
266         /* with function interface */
267         if (dlt_user_log_write_start(&context_function_callback,&context_data,DLT_LOG_INFO)>0)
268         {
269                 dlt_user_log_write_string(&context_data,"Register callback (Function Interface) for Injection ID: 0xFFF");
270                 dlt_user_log_write_finish(&context_data);
271     }
272         dlt_register_injection_callback(&context_function_callback, 0xFFF, test_injection_function_callback);
273
274     /* Tests starting */
275     printf("Tests starting\n");
276     DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Tests starting"));
277
278     /* wait 3 seconds before starting */
279     sleep(3);
280
281     for (num=0;num<maxnum;num++)
282     {
283                 /* Execute tests... */
284
285                 /* with macro interface */
286                 test1m();
287                 test2m();
288                 test3m();
289                 test4m();
290                 test5m();
291                 test6m();
292                 test7m();
293                 test8m();
294                 test9m();
295
296                 /* with function interface */
297                 test1f();
298                 test2f();
299                 test3f();
300                 test4f();
301                 test5f();
302                 test6f();
303                 test7f();
304                 test8f();
305                 test9f();
306
307                 /* wait 1 second before next repeat of tests */
308         sleep(1);
309     }
310
311     /* Tests finished */
312     printf("Tests finished\n");
313     DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Tests finished"));
314
315     /* wait 3 seconds before terminating application */
316     sleep(3);
317
318         /* Unregister CONTEXTS... */
319         DLT_UNREGISTER_CONTEXT(context_info);
320
321         /* used for macro interface tests */
322         for (i=0;i<DLT_TEST_NUM_CONTEXT;i++)
323         {
324                 DLT_UNREGISTER_CONTEXT(context_macro_test[i]);
325         }
326         DLT_UNREGISTER_CONTEXT(context_macro_callback);
327
328         /* used for function interface tests */
329         for (i=0;i<DLT_TEST_NUM_CONTEXT;i++)
330         {
331                 dlt_unregister_context(&(context_function_test[i]));
332         }
333         dlt_unregister_context(&context_function_callback);
334
335         /* Unregister APP */
336     DLT_UNREGISTER_APP();
337
338     dlt_free();
339
340     return 0;
341 }
342
343 /******************/
344 /* The test cases */
345 /******************/
346
347 int test1m(void)
348 {
349         /* Test 1: (Macro IF) Test all log levels */
350     printf("Test1m: (Macro IF) Test all log levels\n");
351     DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test1: (Macro IF) Test all log levels"));
352
353     DLT_LOG(context_macro_test[0],DLT_LOG_FATAL,DLT_STRING("fatal"));
354     DLT_LOG(context_macro_test[0],DLT_LOG_ERROR,DLT_STRING("error"));
355     DLT_LOG(context_macro_test[0],DLT_LOG_WARN,DLT_STRING("warn"));
356     DLT_LOG(context_macro_test[0],DLT_LOG_INFO,DLT_STRING("info"));
357     DLT_LOG(context_macro_test[0],DLT_LOG_DEBUG,DLT_STRING("debug"));
358     DLT_LOG(context_macro_test[0],DLT_LOG_VERBOSE,DLT_STRING("verbose"));
359
360         /* wait 2 second before next test */
361     sleep(2);
362     DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test1: (Macro IF) finished"));
363
364         return 0;
365 }
366
367 int test2m(void)
368 {
369         char buffer[10];
370     int num2;
371
372         /* Test 2: (Macro IF) Test all variable types (verbose) */
373     printf("Test2m: (Macro IF) Test all variable types (verbose)\n");
374     DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test2: (Macro IF) Test all variable types (verbose)"));
375
376     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("string"),DLT_STRING("Hello world"));
377     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("utf8"),DLT_UTF8("Hello world"));
378     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("bool"),DLT_BOOL(1));
379     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("int"),DLT_INT(INT32_MIN));         /* (-2147483647-1) */
380     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("int8"),DLT_INT8(INT8_MIN));        /*          (-128) */
381     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("int16"),DLT_INT16(INT16_MIN));     /*      (-32767-1) */
382     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("int32"),DLT_INT32(INT32_MIN));     /* (-2147483647-1) */
383     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("int64"),DLT_INT64(INT64_MIN));     /* (-__INT64_C(9223372036854775807)-1) */
384     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("uint"),DLT_UINT(UINT32_MAX));      /*   (4294967295U) */
385     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("uint8"),DLT_UINT8(UINT8_MAX));     /*           (255) */
386     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("uint16"),DLT_UINT16(UINT16_MAX));  /*         (65535) */
387     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("uint32"),DLT_UINT32(UINT32_MAX));  /*   (4294967295U) */
388     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("uint64"),DLT_UINT64(UINT64_MAX));  /* (__UINT64_C(18446744073709551615)) */
389     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("float32"),DLT_FLOAT32(FLT_MIN),DLT_FLOAT32(FLT_MAX));
390     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("float64"),DLT_FLOAT64(DBL_MIN),DLT_FLOAT64(DBL_MAX));
391
392     for(num2=0;num2<10;num2++)
393     {
394         buffer[num2] = num2;
395     }
396
397     DLT_LOG(context_macro_test[1],DLT_LOG_INFO,DLT_STRING("raw"),DLT_RAW(buffer,10));
398
399         /* wait 2 second before next test */
400     sleep(2);
401         DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test2: (Macro IF) finished"));
402
403         return 0;
404 }
405
406 int test3m(void)
407 {
408         char buffer[10];
409     int num2;
410
411         /* Test 3: (Macro IF) Test all variable types (non-verbose) */
412     printf("Test3m: (Macro IF) Test all variable types (non-verbose)\n");
413     DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test3: (Macro IF) Test all variable types (non-verbose)"));
414
415         DLT_NONVERBOSE_MODE();
416
417     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,1,DLT_STRING("string"),DLT_STRING("Hello world"));
418     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,2,DLT_STRING("utf8"),DLT_UTF8("Hello world"));
419     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,3,DLT_STRING("bool"),DLT_BOOL(1));
420     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,4,DLT_STRING("int"),DLT_INT(INT32_MIN));         /* (-2147483647-1) */
421     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,5,DLT_STRING("int8"),DLT_INT8(INT8_MIN));        /*          (-128) */
422     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,6,DLT_STRING("int16"),DLT_INT16(INT16_MIN));     /*      (-32767-1) */
423     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,7,DLT_STRING("int32"),DLT_INT32(INT32_MIN));     /* (-2147483647-1) */
424     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,8,DLT_STRING("int64"),DLT_INT64(INT64_MIN));     /* (-__INT64_C(9223372036854775807)-1) */
425     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,9,DLT_STRING("uint"),DLT_UINT(UINT32_MAX));      /*   (4294967295U) */
426     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,10,DLT_STRING("uint8"),DLT_UINT8(UINT8_MAX));     /*           (255) */
427     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,11,DLT_STRING("uint16"),DLT_UINT16(UINT16_MAX));  /*         (65535) */
428     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,12,DLT_STRING("uint32"),DLT_UINT32(UINT32_MAX));  /*   (4294967295U) */
429     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,13,DLT_STRING("uint64"),DLT_UINT64(UINT64_MAX));  /* (__UINT64_C(18446744073709551615)) */
430     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,14,DLT_STRING("float32"),DLT_FLOAT32(FLT_MIN),DLT_FLOAT32(FLT_MAX));
431     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,15,DLT_STRING("float64"),DLT_FLOAT64(DBL_MIN),DLT_FLOAT64(DBL_MAX));
432
433
434     for(num2=0;num2<10;num2++)
435     {
436         buffer[num2] = num2;
437     }
438     DLT_LOG_ID(context_macro_test[2],DLT_LOG_INFO,14,DLT_STRING("raw"),DLT_RAW(buffer,10));
439
440         DLT_VERBOSE_MODE();
441
442         /* wait 2 second before next test */
443     sleep(2);
444         DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test3: (Macro IF) finished"));
445
446         return 0;
447 }
448
449 int test4m(void)
450 {
451         char buffer[1024];
452     int num;
453
454     for(num=0;num<1024;num++)
455     {
456         buffer[num] = num;
457     }
458
459         /* Test 4: (Macro IF) Message size test */
460     printf("Test4m: (Macro IF) Test different message sizes\n");
461     DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test4: (Macro IF) Test different message sizes"));
462
463     DLT_LOG(context_macro_test[3],DLT_LOG_INFO,DLT_STRING("1"),DLT_RAW(buffer,1));
464     DLT_LOG(context_macro_test[3],DLT_LOG_INFO,DLT_STRING("16"),DLT_RAW(buffer,16));
465     DLT_LOG(context_macro_test[3],DLT_LOG_INFO,DLT_STRING("256"),DLT_RAW(buffer,256));
466     DLT_LOG(context_macro_test[3],DLT_LOG_INFO,DLT_STRING("1024"),DLT_RAW(buffer,1024));
467
468         /* wait 2 second before next test */
469     sleep(2);
470         DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test4: (Macro IF) finished"));
471
472         return 0;
473 }
474
475 int test5m(void)
476 {
477         char buffer[32];
478     int num;
479
480     for(num=0;num<32;num++)
481     {
482         buffer[num] = num;
483     }
484
485         /* Test 5: (Macro IF) Test high-level API */
486     printf("Test5m: (Macro IF) Test high-level API\n");
487     DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test5: (Macro IF) Test high-level API"));
488
489         DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_INT"));
490         DLT_LOG_INT(context_macro_test[4], DLT_LOG_INFO, -42);
491
492         DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_UINT"));
493         DLT_LOG_UINT(context_macro_test[4], DLT_LOG_INFO, 42);
494
495         DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_STRING"));
496         DLT_LOG_STRING(context_macro_test[4], DLT_LOG_INFO, "String output");
497
498         DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_RAW"));
499         DLT_LOG_RAW(context_macro_test[4],DLT_LOG_INFO, buffer,16);
500
501         DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_STRING_INT"));
502         DLT_LOG_STRING_INT(context_macro_test[4], DLT_LOG_INFO, "String output: ", -42);
503
504         DLT_LOG(context_macro_test[4],DLT_LOG_INFO,DLT_STRING("Next line: DLT_LOG_STRING_UINT"));
505         DLT_LOG_STRING_UINT(context_macro_test[4], DLT_LOG_INFO,"String output: ", 42);
506
507         /* wait 2 second before next test */
508     sleep(2);
509         DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test5: (Macro IF) finished"));
510
511         return 0;
512 }
513
514 int test6m(void)
515 {
516         /* Test 6: (Macro IF) Test local printing */
517         printf("Test6m: (Macro IF) Test local printing\n");
518     DLT_LOG_STRING(context_info, DLT_LOG_INFO, "Test 6: (Macro IF) Test local printing");
519
520         DLT_ENABLE_LOCAL_PRINT();
521         DLT_LOG_STRING(context_macro_test[5], DLT_LOG_INFO, "Message (visible: locally printed)");
522
523         DLT_DISABLE_LOCAL_PRINT();
524         DLT_LOG_STRING(context_macro_test[5], DLT_LOG_INFO, "Message (invisible: not locally printed)");
525
526          /* wait 2 second before next test */
527     sleep(2);
528         DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test6: (Macro IF) finished"));
529
530         return 0;
531 }
532
533 int test7m(void)
534 {
535         char buffer[32];
536     int num;
537
538     for(num=0;num<32;num++)
539     {
540         buffer[num] = num;
541     }
542
543         /* Show all log messages and traces */
544         DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
545
546         /* Test 7: (Macro IF) Test network trace */
547         printf("Test7m: (Macro IF) Test network trace\n");
548     DLT_LOG_STRING(context_info, DLT_LOG_INFO, "Test 7: (Macro IF) Test network trace");
549
550         /* Dummy messages: 16 byte header, 32 byte payload */
551         DLT_TRACE_NETWORK(context_macro_test[6], DLT_NW_TRACE_IPC, 16, buffer, 32, buffer);
552         DLT_TRACE_NETWORK(context_macro_test[6], DLT_NW_TRACE_CAN, 16, buffer, 32, buffer);
553         DLT_TRACE_NETWORK(context_macro_test[6], DLT_NW_TRACE_FLEXRAY, 16, buffer, 32, buffer);
554         DLT_TRACE_NETWORK(context_macro_test[6], DLT_NW_TRACE_MOST, 16, buffer, 32, buffer);
555
556         /* wait 2 second before next test */
557     sleep(2);
558         DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test7: (Macro IF) finished"));
559
560         DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT);
561         sleep(2);
562
563         return 0;
564 }
565
566 int test8m(void)
567 {
568         char buffer[1024*5];
569     int num;
570
571     for(num=0;num<1024*5;num++)
572     {
573         buffer[num] = num;
574     }
575
576         /* Show all log messages and traces */
577         DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
578
579         /* Test 8: (Macro IF) Test truncated network trace*/
580         printf("Test8m: (Macro IF) Test truncated network trace\n");
581     DLT_LOG_STRING(context_info, DLT_LOG_INFO, "Test 8: (Macro IF) Test truncated network trace");
582
583         /* Dummy messages: 16 byte header, 5k payload */
584         DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_IPC, 16, buffer, 1024*5, buffer);
585         DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_CAN, 16, buffer, 1024*5, buffer);
586         DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024*5, buffer);
587         DLT_TRACE_NETWORK_TRUNCATED(context_macro_test[7], DLT_NW_TRACE_MOST, 16, buffer, 1024*5, buffer);
588
589         /* wait 2 second before next test */
590     sleep(2);
591         DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test8: (Macro IF) finished"));
592
593         DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT);
594         sleep(2);
595
596         return 0;
597 }
598
599 int test9m(void)
600 {
601         char buffer[1024*5];
602     int num;
603
604     for(num=0;num<1024*5;num++)
605     {
606         buffer[num] = num;
607     }
608
609         /* Show all log messages and traces */
610         DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
611
612         /* Test 9: (Macro IF) Test segmented network trace*/
613         printf("Test9m: (Macro IF) Test segmented  network trace\n");
614     DLT_LOG_STRING(context_info, DLT_LOG_INFO, "Test 9: (Macro IF) Test segmented network trace");
615
616         /* Dummy messages: 16 byte header, 5k payload */
617         DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_IPC, 16, buffer, 1024*5, buffer);
618         DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_CAN, 16, buffer, 1024*5, buffer);
619         DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024*5, buffer);
620         DLT_TRACE_NETWORK_SEGMENTED(context_macro_test[8], DLT_NW_TRACE_MOST, 16, buffer, 1024*5, buffer);
621
622         /* wait 2 second before next test */
623     sleep(2);
624         DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test9: (Macro IF) finished"));
625
626         DLT_SET_APPLICATION_LL_TS_LIMIT(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT);
627         sleep(2);
628
629         return 0;
630 }
631
632 int test1f(void)
633 {
634         /* Test 1: (Function IF) Test all log levels */
635     printf("Test1f: (Function IF) Test all log levels\n");
636         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
637         {
638                 dlt_user_log_write_string(&context_data,"Test1: (Function IF) Test all log levels");
639                 dlt_user_log_write_finish(&context_data);
640     }
641
642         if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_FATAL)>0)
643         {
644                 dlt_user_log_write_string(&context_data,"fatal");
645                 dlt_user_log_write_finish(&context_data);
646     }
647         if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_ERROR)>0)
648         {
649                 dlt_user_log_write_string(&context_data,"error");
650                 dlt_user_log_write_finish(&context_data);
651     }
652         if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_WARN)>0)
653         {
654                 dlt_user_log_write_string(&context_data,"warn");
655                 dlt_user_log_write_finish(&context_data);
656     }
657         if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_INFO)>0)
658         {
659                 dlt_user_log_write_string(&context_data,"info");
660                 dlt_user_log_write_finish(&context_data);
661     }
662         if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_DEBUG)>0)
663         {
664                 dlt_user_log_write_string(&context_data,"debug");
665                 dlt_user_log_write_finish(&context_data);
666     }
667         if (dlt_user_log_write_start(&(context_function_test[0]),&context_data,DLT_LOG_VERBOSE)>0)
668         {
669                 dlt_user_log_write_string(&context_data,"verbose");
670                 dlt_user_log_write_finish(&context_data);
671     }
672
673         /* wait 2 second before next test */
674     sleep(2);
675         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
676         {
677                 dlt_user_log_write_string(&context_data,"Test1: (Function IF) finished");
678                 dlt_user_log_write_finish(&context_data);
679     }
680
681         return 0;
682 }
683
684 int test2f(void)
685 {
686         char buffer[10];
687     int num2;
688
689         /* Test 2: (Function IF) Test all variable types (verbose) */
690     printf("Test2f: (Function IF) Test all variable types (verbose)\n");
691         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
692         {
693                 dlt_user_log_write_string(&context_data,"Test2: (Function IF) Test all variable types (verbose)");
694                 dlt_user_log_write_finish(&context_data);
695     }
696
697         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
698         {
699                 dlt_user_log_write_string(&context_data,"bool");
700                 dlt_user_log_write_bool(&context_data,1);
701                 dlt_user_log_write_finish(&context_data);
702     }
703
704         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
705         {
706                 dlt_user_log_write_string(&context_data,"int");
707                 dlt_user_log_write_int(&context_data,INT32_MIN);        /* (-2147483647-1) */
708                 dlt_user_log_write_finish(&context_data);
709     }
710         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
711         {
712                 dlt_user_log_write_string(&context_data,"int8");
713                 dlt_user_log_write_int8(&context_data,INT8_MIN);        /*          (-128) */
714                 dlt_user_log_write_finish(&context_data);
715     }
716         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
717         {
718                 dlt_user_log_write_string(&context_data,"int16");
719                 dlt_user_log_write_int16(&context_data,INT16_MIN);     /*      (-32767-1) */
720                 dlt_user_log_write_finish(&context_data);
721     }
722         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
723         {
724                 dlt_user_log_write_string(&context_data,"int32");
725                 dlt_user_log_write_int32(&context_data,INT32_MIN);     /* (-2147483647-1) */
726                 dlt_user_log_write_finish(&context_data);
727     }
728         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
729         {
730                 dlt_user_log_write_string(&context_data,"int64");
731                 dlt_user_log_write_int64(&context_data,INT64_MIN);     /* (-__INT64_C(9223372036854775807)-1) */
732                 dlt_user_log_write_finish(&context_data);
733     }
734
735         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
736         {
737                 dlt_user_log_write_string(&context_data,"uint");
738                 dlt_user_log_write_uint(&context_data,UINT32_MAX);     /*   (4294967295U) */
739                 dlt_user_log_write_finish(&context_data);
740     }
741         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
742         {
743                 dlt_user_log_write_string(&context_data,"uint8");
744                 dlt_user_log_write_uint8(&context_data,UINT8_MAX);     /*           (255) */
745                 dlt_user_log_write_finish(&context_data);
746     }
747         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
748         {
749                 dlt_user_log_write_string(&context_data,"uint16");
750                 dlt_user_log_write_uint16(&context_data,UINT16_MAX);   /*         (65535) */
751                 dlt_user_log_write_finish(&context_data);
752     }
753         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
754         {
755                 dlt_user_log_write_string(&context_data,"uint32");
756                 dlt_user_log_write_uint32(&context_data,UINT32_MAX);   /*   (4294967295U) */
757                 dlt_user_log_write_finish(&context_data);
758     }
759         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
760         {
761                 dlt_user_log_write_string(&context_data,"uint64");
762                 dlt_user_log_write_uint64(&context_data,UINT64_MAX);   /* (__UINT64_C(18446744073709551615)) */
763                 dlt_user_log_write_finish(&context_data);
764     }
765
766         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
767         {
768                 dlt_user_log_write_string(&context_data,"float32");
769                 dlt_user_log_write_float32(&context_data,FLT_MIN);
770                 dlt_user_log_write_float32(&context_data,FLT_MAX);
771                 dlt_user_log_write_finish(&context_data);
772     }
773         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
774         {
775                 dlt_user_log_write_string(&context_data,"float64");
776                 dlt_user_log_write_float64(&context_data,DBL_MIN);
777                 dlt_user_log_write_float64(&context_data,DBL_MAX);
778                 dlt_user_log_write_finish(&context_data);
779     }
780
781     for(num2=0;num2<10;num2++)
782     {
783         buffer[num2] = num2;
784     }
785
786         if (dlt_user_log_write_start(&(context_function_test[1]),&context_data,DLT_LOG_INFO)>0)
787         {
788                 dlt_user_log_write_string(&context_data,"raw");
789                 dlt_user_log_write_raw(&context_data,buffer,10);
790                 dlt_user_log_write_finish(&context_data);
791     }
792
793         /* wait 2 second before next test */
794     sleep(2);
795         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
796         {
797                 dlt_user_log_write_string(&context_data,"Test2: (Function IF) finished");
798                 dlt_user_log_write_finish(&context_data);
799     }
800
801         return 0;
802 }
803
804 int test3f(void)
805 {
806         char buffer[10];
807     int num2;
808
809         /* Test 3: (Function IF) Test all variable types (non-verbose) */
810     printf("Test3f: (Function IF) Test all variable types (non-verbose)\n");
811         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
812         {
813                 dlt_user_log_write_string(&context_data,"Test3: (Function IF) Test all variable types (non-verbose)");
814                 dlt_user_log_write_finish(&context_data);
815     }
816
817         dlt_nonverbose_mode();
818
819         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!
820         {
821                 dlt_user_log_write_string(&context_data,"bool");
822                 dlt_user_log_write_bool(&context_data,1);
823                 dlt_user_log_write_finish(&context_data);
824     }
825
826         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,2)>0)
827         {
828                 dlt_user_log_write_string(&context_data,"int");
829                 dlt_user_log_write_int(&context_data,INT32_MIN);        /* (-2147483647-1) */
830                 dlt_user_log_write_finish(&context_data);
831     }
832         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,3)>0)
833         {
834                 dlt_user_log_write_string(&context_data,"int8");
835                 dlt_user_log_write_int8(&context_data,INT8_MIN);        /*          (-128) */
836                 dlt_user_log_write_finish(&context_data);
837     }
838         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,4)>0)
839         {
840                 dlt_user_log_write_string(&context_data,"int16");
841                 dlt_user_log_write_int16(&context_data,INT16_MIN);     /*      (-32767-1) */
842                 dlt_user_log_write_finish(&context_data);
843     }
844         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,5)>0)
845         {
846                 dlt_user_log_write_string(&context_data,"int32");
847                 dlt_user_log_write_int32(&context_data,INT32_MIN);     /* (-2147483647-1) */
848                 dlt_user_log_write_finish(&context_data);
849     }
850         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,6)>0)
851         {
852                 dlt_user_log_write_string(&context_data,"int64");
853                 dlt_user_log_write_int64(&context_data,INT64_MIN);     /* (-__INT64_C(9223372036854775807)-1) */
854                 dlt_user_log_write_finish(&context_data);
855     }
856
857         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,7)>0)
858         {
859                 dlt_user_log_write_string(&context_data,"uint");
860                 dlt_user_log_write_uint(&context_data,UINT32_MAX);     /*   (4294967295U) */
861                 dlt_user_log_write_finish(&context_data);
862     }
863         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,8)>0)
864         {
865                 dlt_user_log_write_string(&context_data,"uint8");
866                 dlt_user_log_write_uint8(&context_data,UINT8_MAX);     /*           (255) */
867                 dlt_user_log_write_finish(&context_data);
868     }
869         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,9)>0)
870         {
871                 dlt_user_log_write_string(&context_data,"uint16");
872                 dlt_user_log_write_uint16(&context_data,UINT16_MAX);   /*         (65535) */
873                 dlt_user_log_write_finish(&context_data);
874     }
875         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,10)>0)
876         {
877                 dlt_user_log_write_string(&context_data,"uint32");
878                 dlt_user_log_write_uint32(&context_data,UINT32_MAX);   /*   (4294967295U) */
879                 dlt_user_log_write_finish(&context_data);
880     }
881         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,11)>0)
882         {
883                 dlt_user_log_write_string(&context_data,"uint64");
884                 dlt_user_log_write_uint64(&context_data,UINT64_MAX);   /* (__UINT64_C(18446744073709551615)) */
885                 dlt_user_log_write_finish(&context_data);
886     }
887
888         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,12)>0)
889         {
890                 dlt_user_log_write_string(&context_data,"float32");
891                 dlt_user_log_write_float32(&context_data,FLT_MIN);
892                 dlt_user_log_write_float32(&context_data,FLT_MAX);
893                 dlt_user_log_write_finish(&context_data);
894     }
895         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,13)>0)
896         {
897                 dlt_user_log_write_string(&context_data,"float64");
898                 dlt_user_log_write_float64(&context_data,DBL_MIN);
899                 dlt_user_log_write_float64(&context_data,DBL_MAX);
900                 dlt_user_log_write_finish(&context_data);
901     }
902
903     for(num2=0;num2<10;num2++)
904     {
905         buffer[num2] = num2;
906         }
907
908         if (dlt_user_log_write_start_id(&(context_function_test[2]),&context_data,DLT_LOG_INFO,14)>0)
909         {
910                 dlt_user_log_write_string(&context_data,"raw");
911                 dlt_user_log_write_raw(&context_data,buffer,10);
912                 dlt_user_log_write_finish(&context_data);
913     }
914
915         dlt_verbose_mode();
916
917         /* wait 2 second before next test */
918     sleep(2);
919         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
920         {
921                 dlt_user_log_write_string(&context_data,"Test3: (Function IF) finished");
922                 dlt_user_log_write_finish(&context_data);
923     }
924
925         return 0;
926 }
927
928 int test4f(void)
929 {
930         char buffer[1024];
931     int num;
932
933     for(num=0;num<1024;num++)
934     {
935         buffer[num] = num;
936     }
937
938         /* Test 4: (Function IF) Message size test */
939     printf("Test4f: (Function IF) Test different message sizes\n");
940         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
941         {
942                 dlt_user_log_write_string(&context_data,"Test4: (Function IF) Test different message sizes");
943                 dlt_user_log_write_finish(&context_data);
944     }
945
946         if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0)
947         {
948                 dlt_user_log_write_string(&context_data,"1");
949                 dlt_user_log_write_raw(&context_data,buffer,1);
950                 dlt_user_log_write_finish(&context_data);
951     }
952         if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0)
953         {
954                 dlt_user_log_write_string(&context_data,"16");
955                 dlt_user_log_write_raw(&context_data,buffer,16);
956                 dlt_user_log_write_finish(&context_data);
957     }
958         if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0)
959         {
960                 dlt_user_log_write_string(&context_data,"256");
961                 dlt_user_log_write_raw(&context_data,buffer,256);
962                 dlt_user_log_write_finish(&context_data);
963     }
964         if (dlt_user_log_write_start(&(context_function_test[3]),&context_data,DLT_LOG_INFO)>0)
965         {
966                 dlt_user_log_write_string(&context_data,"1024");
967                 dlt_user_log_write_raw(&context_data,buffer,1024);
968                 dlt_user_log_write_finish(&context_data);
969     }
970
971         /* wait 2 second before next test */
972     sleep(2);
973         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
974         {
975                 dlt_user_log_write_string(&context_data,"Test4: (Function IF) finished");
976                 dlt_user_log_write_finish(&context_data);
977     }
978
979         return 0;
980 }
981
982 int test5f(void)
983 {
984         char buffer[32];
985     int num;
986
987     for(num=0;num<32;num++)
988     {
989         buffer[num] = num;
990     }
991
992         /* Test 5: (Function IF) Test high-level API */
993     printf("Test5f: (Function IF) Test high-level API\n");
994         dlt_log_string(&context_info,DLT_LOG_INFO,"Test5: (Function IF) Test high-level API");
995
996         dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_int()");
997         dlt_log_int(&(context_function_test[4]),DLT_LOG_INFO, -42);
998
999         dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_uint()");
1000         dlt_log_uint(&(context_function_test[4]),DLT_LOG_INFO, 42);
1001
1002         dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_string()");
1003         dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO, "String output");
1004
1005         dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_raw()");
1006         dlt_log_raw(&(context_function_test[4]),DLT_LOG_INFO, buffer,16);
1007
1008         dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_string_int()");
1009         dlt_log_string_int(&(context_function_test[4]), DLT_LOG_INFO, "String output: ", -42);
1010
1011         dlt_log_string(&(context_function_test[4]),DLT_LOG_INFO,"Next line: dlt_log_string_uint()");
1012         dlt_log_string_uint(&(context_function_test[4]), DLT_LOG_INFO,"String output: ", 42);
1013
1014         /* wait 2 second before next test */
1015     sleep(2);
1016         dlt_log_string(&context_info,DLT_LOG_INFO,"Test5: (Function IF) finished");
1017
1018         return 0;
1019 }
1020
1021 int test6f(void)
1022 {
1023         /* Test 6: (Function IF) Test local printing */
1024         printf("Test6f: (Function IF) Test local printing\n");
1025         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
1026         {
1027                 dlt_user_log_write_string(&context_data,"Test 6: (Function IF) Test local printing");
1028                 dlt_user_log_write_finish(&context_data);
1029     }
1030
1031         dlt_enable_local_print();
1032         if (dlt_user_log_write_start(&(context_function_test[5]),&context_data,DLT_LOG_INFO)>0)
1033         {
1034                 dlt_user_log_write_string(&context_data,"Message (visible: locally printed)");
1035                 dlt_user_log_write_finish(&context_data);
1036     }
1037
1038         dlt_disable_local_print();
1039         if (dlt_user_log_write_start(&(context_function_test[5]),&context_data,DLT_LOG_INFO)>0)
1040         {
1041                 dlt_user_log_write_string(&context_data,"Message (invisible: not locally printed)");
1042                 dlt_user_log_write_finish(&context_data);
1043     }
1044
1045          /* wait 2 second before next test */
1046     sleep(2);
1047         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
1048         {
1049                 dlt_user_log_write_string(&context_data,"Test6: (Function IF) finished");
1050                 dlt_user_log_write_finish(&context_data);
1051     }
1052
1053         return 0;
1054 }
1055
1056 int test7f(void)
1057 {
1058         char buffer[32];
1059     int num;
1060
1061     for(num=0;num<32;num++)
1062     {
1063         buffer[num] = num;
1064     }
1065
1066         /* Show all log messages and traces */
1067         dlt_set_application_ll_ts_limit(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
1068
1069         /* Test 7: (Function IF) Test network trace */
1070         printf("Test7f: (Function IF) Test network trace\n");
1071         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
1072         {
1073                 dlt_user_log_write_string(&context_data,"Test 7: (Function IF) Test network trace");
1074                 dlt_user_log_write_finish(&context_data);
1075     }
1076
1077         /* Dummy message: 16 byte header, 32 byte payload */
1078         dlt_user_trace_network(&(context_function_test[6]), DLT_NW_TRACE_IPC, 16, buffer, 32, buffer);
1079         dlt_user_trace_network(&(context_function_test[6]), DLT_NW_TRACE_CAN, 16, buffer, 32, buffer);
1080         dlt_user_trace_network(&(context_function_test[6]), DLT_NW_TRACE_FLEXRAY, 16, buffer, 32, buffer);
1081         dlt_user_trace_network(&(context_function_test[6]), DLT_NW_TRACE_MOST, 16, buffer, 32, buffer);
1082
1083         /* wait 2 second before next test */
1084     sleep(2);
1085         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
1086         {
1087                 dlt_user_log_write_string(&context_data,"Test7: (Function IF) finished");
1088                 dlt_user_log_write_finish(&context_data);
1089     }
1090
1091         dlt_set_application_ll_ts_limit(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT);
1092         sleep(2);
1093
1094         return 0;
1095 }
1096
1097 int test8f(void)
1098 {
1099         char buffer[1024*5];
1100     int num;
1101
1102     for(num=0;num<1024*5;num++)
1103     {
1104         buffer[num] = num;
1105     }
1106
1107         /* Show all log messages and traces */
1108         dlt_set_application_ll_ts_limit(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
1109
1110         /* Test 8: (Function IF) Test truncated network trace */
1111         printf("Test8f: (Function IF) Test truncated network trace\n");
1112         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
1113         {
1114                 dlt_user_log_write_string(&context_data,"Test 8: (Function IF) Test truncated network trace");
1115                 dlt_user_log_write_finish(&context_data);
1116     }
1117
1118         /* Dummy message: 16 byte header, 32 byte payload */
1119         dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_IPC, 16, buffer, 1024*5, buffer, 1);
1120         dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_CAN, 16, buffer, 1024*5, buffer, 1);
1121         dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024*5, buffer, 1);
1122         dlt_user_trace_network_truncated(&(context_function_test[7]), DLT_NW_TRACE_MOST, 16, buffer, 1024*5, buffer, 1);
1123
1124         /* wait 2 second before next test */
1125     sleep(2);
1126         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
1127         {
1128                 dlt_user_log_write_string(&context_data,"Test8: (Function IF) finished");
1129                 dlt_user_log_write_finish(&context_data);
1130     }
1131
1132         dlt_set_application_ll_ts_limit(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT);
1133         sleep(2);
1134
1135         return 0;
1136 }
1137
1138 int test9f(void)
1139 {
1140         char buffer[1024*5];
1141     int num;
1142
1143     for(num=0;num<1024*5;num++)
1144     {
1145         buffer[num] = num;
1146     }
1147
1148         /* Show all log messages and traces */
1149         dlt_set_application_ll_ts_limit(DLT_LOG_VERBOSE, DLT_TRACE_STATUS_ON);
1150
1151         /* Test 9: (Function IF) Test segmented network trace */
1152         printf("Test9f: (Function IF) Test segmented network trace\n");
1153         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
1154         {
1155                 dlt_user_log_write_string(&context_data,"Test 9: (Function IF) Test segmented network trace");
1156                 dlt_user_log_write_finish(&context_data);
1157     }
1158
1159         /* Dummy message: 16 byte header, 5k payload */
1160         dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_IPC, 16, buffer, 1024*5, buffer);
1161         dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_CAN, 16, buffer, 1024*5, buffer);
1162         dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_FLEXRAY, 16, buffer, 1024*5, buffer);
1163         dlt_user_trace_network_segmented(&(context_function_test[8]), DLT_NW_TRACE_MOST, 16, buffer, 1024*5, buffer);
1164
1165         /* wait 2 second before next test */
1166     sleep(2);
1167         if (dlt_user_log_write_start(&context_info,&context_data,DLT_LOG_INFO)>0)
1168         {
1169                 dlt_user_log_write_string(&context_data,"Test9: (Function IF) finished");
1170                 dlt_user_log_write_finish(&context_data);
1171     }
1172
1173         dlt_set_application_ll_ts_limit(DLT_LOG_DEFAULT, DLT_TRACE_STATUS_DEFAULT);
1174         sleep(2);
1175
1176         return 0;
1177 }
1178
1179 int test_injection_macro_callback(uint32_t service_id, void *data, uint32_t length)
1180 {
1181         char text[1024];
1182
1183         memset(text,0,1024);
1184         snprintf(text,1024,"Injection received (macro IF). ID: 0x%.4x, Length: %d",service_id,length);
1185         printf("%s \n", text);
1186         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));
1187         memset(text,0,1024);
1188
1189         if (length>0)
1190         {
1191                 dlt_print_mixed_string(text,1024,data,length,0);
1192                 printf("%s \n", text);
1193         }
1194
1195         return 0;
1196 }
1197
1198 int test_injection_function_callback(uint32_t service_id, void *data, uint32_t length)
1199 {
1200         char text[1024];
1201
1202         memset(text,0,1024);
1203
1204         snprintf(text,1024,"Injection received (function IF). ID: 0x%.4x, Length: %d",service_id,length);
1205         printf("%s \n", text);
1206         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));
1207         memset(text,0,1024);
1208
1209         if (length>0)
1210         {
1211                 dlt_print_mixed_string(text,1024,data,length,0);
1212                 printf("%s \n", text);
1213         }
1214
1215         return 0;
1216 }
1217
1218