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