summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorChristian Muck <christian.muck@bmw.de>2012-03-22 08:33:17 +0100
committerChristian Muck <christian.muck@bmw.de>2012-03-22 08:33:17 +0100
commitaa9865f9781a58e09c28b9e48ca6332f207e15f5 (patch)
tree9bafb5bdef33467bf2fe79d19c5aef3d34207d91 /src/examples
parent76002524fc3d0e5ef12e8e2dfdc27868193c0609 (diff)
downloadDLT-daemon-aa9865f9781a58e09c28b9e48ca6332f207e15f5.tar.gz
Modified library for new test cases to corrupt data - related to the bug fix for testing signed and unsigned integer
Signed-off-by: Christian Muck <christian.muck@bmw.de>
Diffstat (limited to 'src/examples')
-rwxr-xr-xsrc/examples/dlt-example-user.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c
index bdca2d5..a1a4b1e 100755
--- a/src/examples/dlt-example-user.c
+++ b/src/examples/dlt-example-user.c
@@ -112,6 +112,11 @@ void usage()
printf(" -g Switch to non-verbose mode (Default: verbose mode)\n");
printf(" -a Enable local printing of DLT messages (Default: disabled)\n");
printf(" -m mode Set log mode 0=off,1=external,2=internal,3=both\n");
+#ifdef DLT_TEST_ENABLE
+ printf(" -c Corrupt user header\n");
+ printf(" -s size Corrupt message size\n");
+ printf(" -z size Size of message\n");
+#endif /* DLT_TEST_ENABLE */
}
/**
@@ -122,6 +127,11 @@ int main(int argc, char* argv[])
int vflag = 0;
int gflag = 0;
int aflag = 0;
+#ifdef DLT_TEST_ENABLE
+ int cflag = 0;
+ char *svalue = 0;
+ char *zvalue = 0;
+#endif /* DLT_TEST_ENABLE */
char *dvalue = 0;
char *fvalue = 0;
char *nvalue = 0;
@@ -138,8 +148,11 @@ int main(int argc, char* argv[])
int state=-1,newstate;
opterr = 0;
-
+#ifdef DLT_TEST_ENABLE
+ while ((c = getopt (argc, argv, "vgacd:f:n:m:z:s:")) != -1)
+#else
while ((c = getopt (argc, argv, "vgad:f:n:m:")) != -1)
+#endif /* DLT_TEST_ENABLE */
{
switch (c)
{
@@ -158,6 +171,23 @@ int main(int argc, char* argv[])
aflag = 1;
break;
}
+#ifdef DLT_TEST_ENABLE
+ case 'c':
+ {
+ cflag = 1;
+ break;
+ }
+ case 's':
+ {
+ svalue = optarg;
+ break;
+ }
+ case 'z':
+ {
+ zvalue = optarg;
+ break;
+ }
+#endif /* DLT_TEST_ENABLE */
case 'd':
{
dvalue = optarg;
@@ -278,6 +308,23 @@ int main(int argc, char* argv[])
DLT_LOG_ID(mycontext,DLT_LOG_INFO,14,DLT_STRING("DEAD BEEF"));
}
+#ifdef DLT_TEST_ENABLE
+ if (cflag)
+ {
+ dlt_user_test_corrupt_user_header(1);
+ }
+ if (svalue)
+ {
+ dlt_user_test_corrupt_message_size(1,atoi(svalue));
+ }
+ if (zvalue)
+ {
+ char* buffer = malloc(atoi(zvalue));
+ DLT_LOG(mycontext,DLT_LOG_WARN,DLT_STRING(text),DLT_RAW(buffer,atoi(zvalue)));
+ free(buffer);
+ }
+#endif /* DLT_TEST_ENABLE */
+
for (num=0;num<maxnum;num++)
{
printf("Send %d %s\n",num,text);