All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] Create a function tst_resm_hexd() to print a buffer in hex
@ 2013-05-22 10:10 Alexey Kodanev
  2013-05-22 12:56 ` chrubis
  0 siblings, 1 reply; 10+ messages in thread
From: Alexey Kodanev @ 2013-05-22 10:10 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko, Alexey Kodanev

This new function behaves like the tst_resm() function. The difference is,
it in addition takes a buffer, its size and prints the buffer in hexadecimal
format in the end of the message.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 doc/man3/tst_res.3 |   17 ++++++++++++++---
 include/test.h     |    2 ++
 lib/tst_res.c      |   42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/doc/man3/tst_res.3 b/doc/man3/tst_res.3
index 0c1fe6c..0754daf 100644
--- a/doc/man3/tst_res.3
+++ b/doc/man3/tst_res.3
@@ -37,6 +37,8 @@ tst_res \- Print result message, including file contents
 .sp
 tst_resm \- Print result message
 .sp
+tst_resm_hexd \- Print result message, including specified buffer in hexadecimal format
+.sp
 tst_brk \- Print result message, including file contents, and break remaining test cases
 .sp
 tst_brkm \- Print result message and break remaining test cases
@@ -54,6 +56,9 @@ tst_environ \- Keep results coming to original stdout
 .P
 \fBvoid tst_resm(int \fIttype\fB, char *\fItmesg, [arg ...]\fR)
 .P
+\fBvoid tst_resm_hexd(int \fIttype\fB, const void *\fIbuf\fB, size_t \fIsize\fB,
+char *\fItmesg, [arg ...]\fR)
+.P
 \fBvoid tst_brk(int \fIttype\fB, char *\fIfname\fB, void (*\fIfunc\fB)(),
 char *\fItmesg, [arg ...]\fR)
 .P
@@ -121,6 +126,12 @@ expanded message.  The maximum size allowed for an expanded message is
 pointer to a function which performs either the cleanup necessary prior to
 exiting the test or some function executed at the end of each iteration of a
 loop.
+.TP 10
+.I buf
+pointer to a buffer whose contents will be printed in hexadecimal format.
+.TP 10
+.I size
+size of the buffer.
 .RE
 .SS Result Types
 The possible test result types defined in \fBtest.h\fR are as follows:
@@ -153,9 +164,9 @@ An informative message about the execution of the test that does not
 correspond to a test case result and does not indicate a problem.
 .RE
 .SS Function Descriptions
-\fBtst_res()\fR and \fBtst_resm()\fR are the basic result reporting
-functions.  They report 1 or more test case results of the specified
-\fIttype\fR.  All result types are valid for these functions.  The
+\fBtst_res()\fR, \fBtst_resm()\fR and \fBtst_resm_hexd()\fR are the basic
+result reporting functions. They report 1 or more test case results of the
+specified \fIttype\fR.  All result types are valid for these functions.  The
 \fBtst_range\fR global variable indicates the number of results that will be
 reported for each call to one of these functions.  It is initialized by the
 library to 1, but may be set to a value > 1 by the test.  Each call to one of
diff --git a/include/test.h b/include/test.h
index e36ca38..c922230 100644
--- a/include/test.h
+++ b/include/test.h
@@ -191,6 +191,8 @@ void tst_res(int ttype, char *fname, char *arg_fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
 void tst_resm(int ttype, char *arg_fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
+void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
+	__attribute__ ((format (printf, 4, 5)));
 void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...)
 	__attribute__ ((format (printf, 4, 5)));
 void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...)
diff --git a/lib/tst_res.c b/lib/tst_res.c
index ffac6d7..316c05c 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -40,6 +40,7 @@
  *    FUNCTION NAME     :
  *      tst_res() -       Print result message (include file contents)
  *      tst_resm() -      Print result message
+ *      tst_resm_hexd() - Print result message (add buffer contents in hex)
  *      tst_brk() -       Print result message (include file contents)
  *                        and break remaining test cases
  *      tst_brkm() -      Print result message and break remaining test
@@ -675,6 +676,47 @@ void tst_resm(int ttype, char *arg_fmt, ...)
 }
 
 /*
+ * tst_resm_hexd() - Interface to tst_res(), with no filename.
+ * Also, dump specified buffer in hex.
+ */
+void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
+{
+	char tmesg[USERMESG];
+
+#if DEBUG
+	printf("IN tst_resm_hexd\n");
+	fflush(stdout);
+#endif
+
+	EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
+
+	static const size_t symb_num	= 2; /* xx */
+	static const size_t size_max	= 16;
+	size_t offset = strlen(tmesg);
+	char *pmesg = tmesg;
+
+	if (size > size_max || size == 0 ||
+		(offset + size * (symb_num + 1)) >= USERMESG)
+		tst_res(ttype, NULL, "%s", tmesg);
+	else
+		pmesg += offset;
+
+	size_t i;
+	for (i = 0; i < size; ++i) {
+		/* add space before byte except first one */
+		if (pmesg != tmesg)
+			strcpy(pmesg++, " ");
+
+		sprintf(pmesg, "%02x", ((unsigned char *)buf)[i]);
+		pmesg += symb_num;
+		if ((i + 1) % size_max == 0 || i + 1 == size) {
+			tst_res(ttype, NULL, "%s", tmesg);
+			pmesg = tmesg;
+		}
+	}
+}
+
+/*
  * tst_brkm() - Interface to tst_brk(), with no filename.
  */
 void tst_brkm(int ttype, void (*func) (void), char *arg_fmt, ...)
-- 
1.7.1


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH] Create a function tst_resm_hexd() to print a buffer in hex
  2013-05-22 10:10 [LTP] [PATCH] Create a function tst_resm_hexd() to print a buffer in hex Alexey Kodanev
@ 2013-05-22 12:56 ` chrubis
  0 siblings, 0 replies; 10+ messages in thread
From: chrubis @ 2013-05-22 12:56 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: vasily.isaenko, ltp-list

Hi!
> This new function behaves like the tst_resm() function. The difference is,
> it in addition takes a buffer, its size and prints the buffer in hexadecimal
> format in the end of the message.
> 
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
>  doc/man3/tst_res.3 |   17 ++++++++++++++---
>  include/test.h     |    2 ++
>  lib/tst_res.c      |   42 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 58 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/man3/tst_res.3 b/doc/man3/tst_res.3
> index 0c1fe6c..0754daf 100644
> --- a/doc/man3/tst_res.3
> +++ b/doc/man3/tst_res.3
> @@ -37,6 +37,8 @@ tst_res \- Print result message, including file contents
>  .sp
>  tst_resm \- Print result message
>  .sp
> +tst_resm_hexd \- Print result message, including specified buffer in hexadecimal format
> +.sp
>  tst_brk \- Print result message, including file contents, and break remaining test cases
>  .sp
>  tst_brkm \- Print result message and break remaining test cases
> @@ -54,6 +56,9 @@ tst_environ \- Keep results coming to original stdout
>  .P
>  \fBvoid tst_resm(int \fIttype\fB, char *\fItmesg, [arg ...]\fR)
>  .P
> +\fBvoid tst_resm_hexd(int \fIttype\fB, const void *\fIbuf\fB, size_t \fIsize\fB,
> +char *\fItmesg, [arg ...]\fR)
> +.P
>  \fBvoid tst_brk(int \fIttype\fB, char *\fIfname\fB, void (*\fIfunc\fB)(),
>  char *\fItmesg, [arg ...]\fR)
>  .P
> @@ -121,6 +126,12 @@ expanded message.  The maximum size allowed for an expanded message is
>  pointer to a function which performs either the cleanup necessary prior to
>  exiting the test or some function executed at the end of each iteration of a
>  loop.
> +.TP 10
> +.I buf
> +pointer to a buffer whose contents will be printed in hexadecimal format.
> +.TP 10
> +.I size
> +size of the buffer.
>  .RE
>  .SS Result Types
>  The possible test result types defined in \fBtest.h\fR are as follows:
> @@ -153,9 +164,9 @@ An informative message about the execution of the test that does not
>  correspond to a test case result and does not indicate a problem.
>  .RE
>  .SS Function Descriptions
> -\fBtst_res()\fR and \fBtst_resm()\fR are the basic result reporting
> -functions.  They report 1 or more test case results of the specified
> -\fIttype\fR.  All result types are valid for these functions.  The
> +\fBtst_res()\fR, \fBtst_resm()\fR and \fBtst_resm_hexd()\fR are the basic
> +result reporting functions. They report 1 or more test case results of the
> +specified \fIttype\fR.  All result types are valid for these functions.  The
>  \fBtst_range\fR global variable indicates the number of results that will be
>  reported for each call to one of these functions.  It is initialized by the
>  library to 1, but may be set to a value > 1 by the test.  Each call to one of
> diff --git a/include/test.h b/include/test.h
> index e36ca38..c922230 100644
> --- a/include/test.h
> +++ b/include/test.h
> @@ -191,6 +191,8 @@ void tst_res(int ttype, char *fname, char *arg_fmt, ...)
>  	__attribute__ ((format (printf, 3, 4)));
>  void tst_resm(int ttype, char *arg_fmt, ...)
>  	__attribute__ ((format (printf, 2, 3)));
> +void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
> +	__attribute__ ((format (printf, 4, 5)));
>  void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...)
>  	__attribute__ ((format (printf, 4, 5)));
>  void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...)
> diff --git a/lib/tst_res.c b/lib/tst_res.c
> index ffac6d7..316c05c 100644
> --- a/lib/tst_res.c
> +++ b/lib/tst_res.c
> @@ -40,6 +40,7 @@
>   *    FUNCTION NAME     :
>   *      tst_res() -       Print result message (include file contents)
>   *      tst_resm() -      Print result message
> + *      tst_resm_hexd() - Print result message (add buffer contents in hex)
>   *      tst_brk() -       Print result message (include file contents)
>   *                        and break remaining test cases
>   *      tst_brkm() -      Print result message and break remaining test
> @@ -675,6 +676,47 @@ void tst_resm(int ttype, char *arg_fmt, ...)
>  }
>  
>  /*
> + * tst_resm_hexd() - Interface to tst_res(), with no filename.
> + * Also, dump specified buffer in hex.
> + */
> +void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
> +{
> +	char tmesg[USERMESG];
> +
> +#if DEBUG
> +	printf("IN tst_resm_hexd\n");
> +	fflush(stdout);
> +#endif
> +
> +	EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
> +
> +	static const size_t symb_num	= 2; /* xx */
> +	static const size_t size_max	= 16;
> +	size_t offset = strlen(tmesg);
> +	char *pmesg = tmesg;
> +
> +	if (size > size_max || size == 0 ||
> +		(offset + size * (symb_num + 1)) >= USERMESG)
> +		tst_res(ttype, NULL, "%s", tmesg);
> +	else
> +		pmesg += offset;
> +
> +	size_t i;
> +	for (i = 0; i < size; ++i) {
> +		/* add space before byte except first one */
> +		if (pmesg != tmesg)
> +			strcpy(pmesg++, " ");

                        *(pmesg++) = ' ';

> +		sprintf(pmesg, "%02x", ((unsigned char *)buf)[i]);
> +		pmesg += symb_num;
> +		if ((i + 1) % size_max == 0 || i + 1 == size) {
> +			tst_res(ttype, NULL, "%s", tmesg);
> +			pmesg = tmesg;
> +		}
> +	}
> +}
> +

The rest looks fine.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH] Create a function tst_resm_hexd() to print a buffer in hex
  2013-05-23  7:03 Alexey Kodanev
@ 2013-05-23 13:08 ` chrubis
  0 siblings, 0 replies; 10+ messages in thread
From: chrubis @ 2013-05-23 13:08 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: vasily.isaenko, ltp-list

Hi!
> This new function behaves like the tst_resm() function. The difference is,
> it in addition takes a buffer, its size and prints the buffer in hexadecimal
> format in the end of the message.

Commited, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH] Create a function tst_resm_hexd() to print a buffer in hex
@ 2013-05-23  7:03 Alexey Kodanev
  2013-05-23 13:08 ` chrubis
  0 siblings, 1 reply; 10+ messages in thread
From: Alexey Kodanev @ 2013-05-23  7:03 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko, Alexey Kodanev

This new function behaves like the tst_resm() function. The difference is,
it in addition takes a buffer, its size and prints the buffer in hexadecimal
format in the end of the message.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 doc/man3/tst_res.3 |   17 ++++++++++++++---
 include/test.h     |    2 ++
 lib/tst_res.c      |   42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/doc/man3/tst_res.3 b/doc/man3/tst_res.3
index 0c1fe6c..0754daf 100644
--- a/doc/man3/tst_res.3
+++ b/doc/man3/tst_res.3
@@ -37,6 +37,8 @@ tst_res \- Print result message, including file contents
 .sp
 tst_resm \- Print result message
 .sp
+tst_resm_hexd \- Print result message, including specified buffer in hexadecimal format
+.sp
 tst_brk \- Print result message, including file contents, and break remaining test cases
 .sp
 tst_brkm \- Print result message and break remaining test cases
@@ -54,6 +56,9 @@ tst_environ \- Keep results coming to original stdout
 .P
 \fBvoid tst_resm(int \fIttype\fB, char *\fItmesg, [arg ...]\fR)
 .P
+\fBvoid tst_resm_hexd(int \fIttype\fB, const void *\fIbuf\fB, size_t \fIsize\fB,
+char *\fItmesg, [arg ...]\fR)
+.P
 \fBvoid tst_brk(int \fIttype\fB, char *\fIfname\fB, void (*\fIfunc\fB)(),
 char *\fItmesg, [arg ...]\fR)
 .P
@@ -121,6 +126,12 @@ expanded message.  The maximum size allowed for an expanded message is
 pointer to a function which performs either the cleanup necessary prior to
 exiting the test or some function executed at the end of each iteration of a
 loop.
+.TP 10
+.I buf
+pointer to a buffer whose contents will be printed in hexadecimal format.
+.TP 10
+.I size
+size of the buffer.
 .RE
 .SS Result Types
 The possible test result types defined in \fBtest.h\fR are as follows:
@@ -153,9 +164,9 @@ An informative message about the execution of the test that does not
 correspond to a test case result and does not indicate a problem.
 .RE
 .SS Function Descriptions
-\fBtst_res()\fR and \fBtst_resm()\fR are the basic result reporting
-functions.  They report 1 or more test case results of the specified
-\fIttype\fR.  All result types are valid for these functions.  The
+\fBtst_res()\fR, \fBtst_resm()\fR and \fBtst_resm_hexd()\fR are the basic
+result reporting functions. They report 1 or more test case results of the
+specified \fIttype\fR.  All result types are valid for these functions.  The
 \fBtst_range\fR global variable indicates the number of results that will be
 reported for each call to one of these functions.  It is initialized by the
 library to 1, but may be set to a value > 1 by the test.  Each call to one of
diff --git a/include/test.h b/include/test.h
index e36ca38..c922230 100644
--- a/include/test.h
+++ b/include/test.h
@@ -191,6 +191,8 @@ void tst_res(int ttype, char *fname, char *arg_fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
 void tst_resm(int ttype, char *arg_fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
+void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
+	__attribute__ ((format (printf, 4, 5)));
 void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...)
 	__attribute__ ((format (printf, 4, 5)));
 void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...)
diff --git a/lib/tst_res.c b/lib/tst_res.c
index ffac6d7..16f54f0 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -40,6 +40,7 @@
  *    FUNCTION NAME     :
  *      tst_res() -       Print result message (include file contents)
  *      tst_resm() -      Print result message
+ *      tst_resm_hexd() - Print result message (add buffer contents in hex)
  *      tst_brk() -       Print result message (include file contents)
  *                        and break remaining test cases
  *      tst_brkm() -      Print result message and break remaining test
@@ -675,6 +676,47 @@ void tst_resm(int ttype, char *arg_fmt, ...)
 }
 
 /*
+ * tst_resm_hexd() - Interface to tst_res(), with no filename.
+ * Also, dump specified buffer in hex.
+ */
+void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
+{
+	char tmesg[USERMESG];
+
+#if DEBUG
+	printf("IN tst_resm_hexd\n");
+	fflush(stdout);
+#endif
+
+	EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
+
+	static const size_t symb_num	= 2; /* xx */
+	static const size_t size_max	= 16;
+	size_t offset = strlen(tmesg);
+	char *pmesg = tmesg;
+
+	if (size > size_max || size == 0 ||
+		(offset + size * (symb_num + 1)) >= USERMESG)
+		tst_res(ttype, NULL, "%s", tmesg);
+	else
+		pmesg += offset;
+
+	size_t i;
+	for (i = 0; i < size; ++i) {
+		/* add space before byte except first one */
+		if (pmesg != tmesg)
+			*(pmesg++) = ' ';
+
+		sprintf(pmesg, "%02x", ((unsigned char *)buf)[i]);
+		pmesg += symb_num;
+		if ((i + 1) % size_max == 0 || i + 1 == size) {
+			tst_res(ttype, NULL, "%s", tmesg);
+			pmesg = tmesg;
+		}
+	}
+}
+
+/*
  * tst_brkm() - Interface to tst_brk(), with no filename.
  */
 void tst_brkm(int ttype, void (*func) (void), char *arg_fmt, ...)
-- 
1.7.1


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH] Create a function tst_resm_hexd to print a buffer in hex
       [not found]       ` <519B9B8D.6050004@oracle.com>
@ 2013-05-21 16:32         ` chrubis
  0 siblings, 0 replies; 10+ messages in thread
From: chrubis @ 2013-05-21 16:32 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: vasily.isaenko, ltp-list

Hi!
> > Okay what about priting the content of the buffer on several lines
> > unsing several tst_res() calls if the size of the message overflows some
> > size (possibly 80 chars)?
> >
> > test_name   0 TINFO: 'message passed to the tst res'
> > test_name   0 TINFO: 57 41 52 4e 49 4e 47 20 2a 20 57 41 52 4e 49 4e
> > test_name   0 TINFO: 57 41 52 4e 49 4e 47 20 2a 20 57 41 52 4e 49 4e
> > ...
> > (till the end of the buffer)
> >
> I agree, moreover, can we do it by default? At least bytes will be 
> aligned correctly.

Ok.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH] Create a function tst_resm_hexd to print a buffer in hex
       [not found]   ` <519B8E4E.1010105@oracle.com>
@ 2013-05-21 15:46     ` chrubis
       [not found]       ` <519B9B8D.6050004@oracle.com>
  0 siblings, 1 reply; 10+ messages in thread
From: chrubis @ 2013-05-21 15:46 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: vasily.isaenko, ltp-list

Hi!
> >> +	tst_res(ttype, NULL, "%s", tmesg);
> >> +}
> 
> If tmesg is full it is never going to be printed. tst_res will add at 
> least new line character,
> header and then message will exceed its size, as a result test will 
> break with error.
> Is it ok or may be tst_res() function will be changed in the future somehow?

Ah I see, the tst_print() function composes the whole line into the
buffer before it is printed. I remeber that this needs to be done as
there are tests that calls the tst_res() from several threads and the
messages gets mixed if they are not printed atomically.

And it is not easy to compute the space that will be needed for the
whole message too. Bah.

Okay what about priting the content of the buffer on several lines
unsing several tst_res() calls if the size of the message overflows some
size (possibly 80 chars)?

test_name   0 TINFO: 'message passed to the tst res'
test_name   0 TINFO: 57 41 52 4e 49 4e 47 20 2a 20 57 41 52 4e 49 4e
test_name   0 TINFO: 57 41 52 4e 49 4e 47 20 2a 20 57 41 52 4e 49 4e
...
(till the end of the buffer)


And with short enough buffer:

test_name   0 TINFO: 'message passed to the tst res: 57 41 52 4e'

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH] Create a function tst_resm_hexd() to print a buffer in hex
@ 2013-05-21 14:42 Alexey Kodanev
  0 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2013-05-21 14:42 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko, Alexey Kodanev

This new function behaves like the tst_resm() function. The difference is,
it in addition takes a buffer, its size and prints the buffer in hexadecimal
format in the end of the message.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 doc/man3/tst_res.3 |   17 ++++++++++++++---
 include/test.h     |    2 ++
 lib/tst_res.c      |   41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/doc/man3/tst_res.3 b/doc/man3/tst_res.3
index 0c1fe6c..0754daf 100644
--- a/doc/man3/tst_res.3
+++ b/doc/man3/tst_res.3
@@ -37,6 +37,8 @@ tst_res \- Print result message, including file contents
 .sp
 tst_resm \- Print result message
 .sp
+tst_resm_hexd \- Print result message, including specified buffer in hexadecimal format
+.sp
 tst_brk \- Print result message, including file contents, and break remaining test cases
 .sp
 tst_brkm \- Print result message and break remaining test cases
@@ -54,6 +56,9 @@ tst_environ \- Keep results coming to original stdout
 .P
 \fBvoid tst_resm(int \fIttype\fB, char *\fItmesg, [arg ...]\fR)
 .P
+\fBvoid tst_resm_hexd(int \fIttype\fB, const void *\fIbuf\fB, size_t \fIsize\fB,
+char *\fItmesg, [arg ...]\fR)
+.P
 \fBvoid tst_brk(int \fIttype\fB, char *\fIfname\fB, void (*\fIfunc\fB)(),
 char *\fItmesg, [arg ...]\fR)
 .P
@@ -121,6 +126,12 @@ expanded message.  The maximum size allowed for an expanded message is
 pointer to a function which performs either the cleanup necessary prior to
 exiting the test or some function executed at the end of each iteration of a
 loop.
+.TP 10
+.I buf
+pointer to a buffer whose contents will be printed in hexadecimal format.
+.TP 10
+.I size
+size of the buffer.
 .RE
 .SS Result Types
 The possible test result types defined in \fBtest.h\fR are as follows:
@@ -153,9 +164,9 @@ An informative message about the execution of the test that does not
 correspond to a test case result and does not indicate a problem.
 .RE
 .SS Function Descriptions
-\fBtst_res()\fR and \fBtst_resm()\fR are the basic result reporting
-functions.  They report 1 or more test case results of the specified
-\fIttype\fR.  All result types are valid for these functions.  The
+\fBtst_res()\fR, \fBtst_resm()\fR and \fBtst_resm_hexd()\fR are the basic
+result reporting functions. They report 1 or more test case results of the
+specified \fIttype\fR.  All result types are valid for these functions.  The
 \fBtst_range\fR global variable indicates the number of results that will be
 reported for each call to one of these functions.  It is initialized by the
 library to 1, but may be set to a value > 1 by the test.  Each call to one of
diff --git a/include/test.h b/include/test.h
index e36ca38..c922230 100644
--- a/include/test.h
+++ b/include/test.h
@@ -191,6 +191,8 @@ void tst_res(int ttype, char *fname, char *arg_fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
 void tst_resm(int ttype, char *arg_fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
+void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
+	__attribute__ ((format (printf, 4, 5)));
 void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...)
 	__attribute__ ((format (printf, 4, 5)));
 void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...)
diff --git a/lib/tst_res.c b/lib/tst_res.c
index ffac6d7..a52c500 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -40,6 +40,7 @@
  *    FUNCTION NAME     :
  *      tst_res() -       Print result message (include file contents)
  *      tst_resm() -      Print result message
+ *      tst_resm_hexd() - Print result message (add buffer contents in hex)
  *      tst_brk() -       Print result message (include file contents)
  *                        and break remaining test cases
  *      tst_brkm() -      Print result message and break remaining test
@@ -675,6 +676,46 @@ void tst_resm(int ttype, char *arg_fmt, ...)
 }
 
 /*
+ * tst_resm_hexd() - Interface to tst_res(), with no filename.
+ * Also, dump specified buffer in hex.
+ */
+void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
+{
+	char tmesg[USERMESG];
+
+#if DEBUG
+	printf("IN tst_resm_hexd\n");
+	fflush(stdout);
+#endif
+
+	EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
+
+	static const char msg_end[] = " ...";
+	static const size_t symb_num = 3; /* space + xx */
+	size_t offset = strlen(tmesg);
+
+	int size_changed = 0;
+
+	if ((offset + symb_num * size + 1) >= USERMESG) {
+		size = (USERMESG - offset - sizeof(msg_end)) / symb_num;
+		size_changed = 1;
+	}
+
+	char *pmesg = tmesg + offset;
+
+	size_t i;
+	for (i = 0; i < size; ++i) {
+		sprintf(pmesg, " %02x", ((unsigned char *)buf)[i]);
+		pmesg += symb_num;
+	}
+
+	if (size_changed)
+		strcpy(pmesg, msg_end);
+
+	tst_res(ttype, NULL, "%s", tmesg);
+}
+
+/*
  * tst_brkm() - Interface to tst_brk(), with no filename.
  */
 void tst_brkm(int ttype, void (*func) (void), char *arg_fmt, ...)
-- 
1.7.1


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH] Create a function tst_resm_hexd() to print a buffer in hex
@ 2013-05-21 14:38 Alexey Kodanev
  0 siblings, 0 replies; 10+ messages in thread
From: Alexey Kodanev @ 2013-05-21 14:38 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko, Alexey Kodanev

This new function behave like the tst_resm() function. The difference is,
it in addition takes a buffer, its size and prints the buffer in hexadecimal
format in the end of the message.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 doc/man3/tst_res.3 |   17 ++++++++++++++---
 include/test.h     |    2 ++
 lib/tst_res.c      |   41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/doc/man3/tst_res.3 b/doc/man3/tst_res.3
index 0c1fe6c..0754daf 100644
--- a/doc/man3/tst_res.3
+++ b/doc/man3/tst_res.3
@@ -37,6 +37,8 @@ tst_res \- Print result message, including file contents
 .sp
 tst_resm \- Print result message
 .sp
+tst_resm_hexd \- Print result message, including specified buffer in hexadecimal format
+.sp
 tst_brk \- Print result message, including file contents, and break remaining test cases
 .sp
 tst_brkm \- Print result message and break remaining test cases
@@ -54,6 +56,9 @@ tst_environ \- Keep results coming to original stdout
 .P
 \fBvoid tst_resm(int \fIttype\fB, char *\fItmesg, [arg ...]\fR)
 .P
+\fBvoid tst_resm_hexd(int \fIttype\fB, const void *\fIbuf\fB, size_t \fIsize\fB,
+char *\fItmesg, [arg ...]\fR)
+.P
 \fBvoid tst_brk(int \fIttype\fB, char *\fIfname\fB, void (*\fIfunc\fB)(),
 char *\fItmesg, [arg ...]\fR)
 .P
@@ -121,6 +126,12 @@ expanded message.  The maximum size allowed for an expanded message is
 pointer to a function which performs either the cleanup necessary prior to
 exiting the test or some function executed at the end of each iteration of a
 loop.
+.TP 10
+.I buf
+pointer to a buffer whose contents will be printed in hexadecimal format.
+.TP 10
+.I size
+size of the buffer.
 .RE
 .SS Result Types
 The possible test result types defined in \fBtest.h\fR are as follows:
@@ -153,9 +164,9 @@ An informative message about the execution of the test that does not
 correspond to a test case result and does not indicate a problem.
 .RE
 .SS Function Descriptions
-\fBtst_res()\fR and \fBtst_resm()\fR are the basic result reporting
-functions.  They report 1 or more test case results of the specified
-\fIttype\fR.  All result types are valid for these functions.  The
+\fBtst_res()\fR, \fBtst_resm()\fR and \fBtst_resm_hexd()\fR are the basic
+result reporting functions. They report 1 or more test case results of the
+specified \fIttype\fR.  All result types are valid for these functions.  The
 \fBtst_range\fR global variable indicates the number of results that will be
 reported for each call to one of these functions.  It is initialized by the
 library to 1, but may be set to a value > 1 by the test.  Each call to one of
diff --git a/include/test.h b/include/test.h
index e36ca38..c922230 100644
--- a/include/test.h
+++ b/include/test.h
@@ -191,6 +191,8 @@ void tst_res(int ttype, char *fname, char *arg_fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
 void tst_resm(int ttype, char *arg_fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
+void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
+	__attribute__ ((format (printf, 4, 5)));
 void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...)
 	__attribute__ ((format (printf, 4, 5)));
 void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...)
diff --git a/lib/tst_res.c b/lib/tst_res.c
index ffac6d7..a52c500 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -40,6 +40,7 @@
  *    FUNCTION NAME     :
  *      tst_res() -       Print result message (include file contents)
  *      tst_resm() -      Print result message
+ *      tst_resm_hexd() - Print result message (add buffer contents in hex)
  *      tst_brk() -       Print result message (include file contents)
  *                        and break remaining test cases
  *      tst_brkm() -      Print result message and break remaining test
@@ -675,6 +676,46 @@ void tst_resm(int ttype, char *arg_fmt, ...)
 }
 
 /*
+ * tst_resm_hexd() - Interface to tst_res(), with no filename.
+ * Also, dump specified buffer in hex.
+ */
+void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
+{
+	char tmesg[USERMESG];
+
+#if DEBUG
+	printf("IN tst_resm_hexd\n");
+	fflush(stdout);
+#endif
+
+	EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
+
+	static const char msg_end[] = " ...";
+	static const size_t symb_num = 3; /* space + xx */
+	size_t offset = strlen(tmesg);
+
+	int size_changed = 0;
+
+	if ((offset + symb_num * size + 1) >= USERMESG) {
+		size = (USERMESG - offset - sizeof(msg_end)) / symb_num;
+		size_changed = 1;
+	}
+
+	char *pmesg = tmesg + offset;
+
+	size_t i;
+	for (i = 0; i < size; ++i) {
+		sprintf(pmesg, " %02x", ((unsigned char *)buf)[i]);
+		pmesg += symb_num;
+	}
+
+	if (size_changed)
+		strcpy(pmesg, msg_end);
+
+	tst_res(ttype, NULL, "%s", tmesg);
+}
+
+/*
  * tst_brkm() - Interface to tst_brk(), with no filename.
  */
 void tst_brkm(int ttype, void (*func) (void), char *arg_fmt, ...)
-- 
1.7.1


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH] Create a function tst_resm_hexd to print a buffer in hex
  2013-05-20 16:18 [LTP] [PATCH] Create a function tst_resm_hexd " Alexey Kodanev
@ 2013-05-21 12:49 ` chrubis
       [not found]   ` <519B8E4E.1010105@oracle.com>
  0 siblings, 1 reply; 10+ messages in thread
From: chrubis @ 2013-05-21 12:49 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: vasily.isaenko, ltp-list

A little more detailed description of the new function here please.

> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
> @@ -40,6 +40,7 @@
>   *    FUNCTION NAME     :
>   *      tst_res() -       Print result message (include file contents)
>   *      tst_resm() -      Print result message
> + *      tst_resm_hexd() - Print result message (add buffer contents in hex)
>   *      tst_brk() -       Print result message (include file contents)
>   *                        and break remaining test cases
>   *      tst_brkm() -      Print result message and break remaining test
> @@ -62,6 +63,12 @@
>   *      int  ttype;
>   *      char *tmesg;
>   *
> + *      void tst_resm_hexd(ttype, buf, size, tmesg [,arg]...)
> + *      int  ttype;
> + *      const void *buf;
> + *      size_t size;
> + *      char *tmesg;

This part of the comment is IMHO useless as nobody will read the C code
when looking for documentation and evenmore this does not add more
information than the prototype in header. (I made a note to clean these
up later).

>   *      void tst_brk(ttype, fname, cleanup, tmesg, [,argv]...)
>   *      int  ttype;
>   *      char *fname;
> @@ -675,6 +682,47 @@ void tst_resm(int ttype, char *arg_fmt, ...)
>  }
>  
>  /*
> + * tst_resm_hexd() - Interface to tst_res(), with no filename.
> + * Also, dump specified buffer in hex.
> + */
> +void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
> +{
> +	char tmesg[USERMESG];
> +
> +#if DEBUG
> +	printf("IN tst_resm_hexd\n");
> +	fflush(stdout);
> +#endif
> +
> +	EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
> +
> +	static const char msg_end[] = " ...";
> +	static const size_t symb_num = 3; /* space + xx */
> +	size_t end_num = strlen(msg_end);

I think that todays compilers can avoid the call to strlen() on static
string but I would either hardcode the size of the string below or even
better use sizeof() which returns strlen() + 1 in this case.

> +	size_t offset = strlen(tmesg);
> +	int size_changed = 0;
> +
> +	if ((offset + symb_num * size + 1) >= USERMESG) {
> +		size = (USERMESG - offset) / symb_num - end_num - 1;

(USERMESG - offset - sizeof(msg_end)) / symb_num ?

> +		size_changed = 1;
> +	}
> +
> +	char *pmesg = tmesg + offset;
> +
> +	size_t i;
> +	for (i = 0; i < size; ++i) {
> +		sprintf(pmesg, " %02x", ((unsigned char *)buf)[i]);
> +		pmesg += symb_num;
> +	}
> +
> +	if (size_changed)
> +		strcat(pmesg, msg_end);

Shouldn't strcpy() suffice here?

> +	tst_res(ttype, NULL, "%s", tmesg);
> +}

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH] Create a function tst_resm_hexd to print a buffer in hex
@ 2013-05-20 16:18 Alexey Kodanev
  2013-05-21 12:49 ` chrubis
  0 siblings, 1 reply; 10+ messages in thread
From: Alexey Kodanev @ 2013-05-20 16:18 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko, Alexey Kodanev

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 doc/man3/tst_res.3 |   17 ++++++++++++++---
 include/test.h     |    2 ++
 lib/tst_res.c      |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 3 deletions(-)

diff --git a/doc/man3/tst_res.3 b/doc/man3/tst_res.3
index 0c1fe6c..0754daf 100644
--- a/doc/man3/tst_res.3
+++ b/doc/man3/tst_res.3
@@ -37,6 +37,8 @@ tst_res \- Print result message, including file contents
 .sp
 tst_resm \- Print result message
 .sp
+tst_resm_hexd \- Print result message, including specified buffer in hexadecimal format
+.sp
 tst_brk \- Print result message, including file contents, and break remaining test cases
 .sp
 tst_brkm \- Print result message and break remaining test cases
@@ -54,6 +56,9 @@ tst_environ \- Keep results coming to original stdout
 .P
 \fBvoid tst_resm(int \fIttype\fB, char *\fItmesg, [arg ...]\fR)
 .P
+\fBvoid tst_resm_hexd(int \fIttype\fB, const void *\fIbuf\fB, size_t \fIsize\fB,
+char *\fItmesg, [arg ...]\fR)
+.P
 \fBvoid tst_brk(int \fIttype\fB, char *\fIfname\fB, void (*\fIfunc\fB)(),
 char *\fItmesg, [arg ...]\fR)
 .P
@@ -121,6 +126,12 @@ expanded message.  The maximum size allowed for an expanded message is
 pointer to a function which performs either the cleanup necessary prior to
 exiting the test or some function executed at the end of each iteration of a
 loop.
+.TP 10
+.I buf
+pointer to a buffer whose contents will be printed in hexadecimal format.
+.TP 10
+.I size
+size of the buffer.
 .RE
 .SS Result Types
 The possible test result types defined in \fBtest.h\fR are as follows:
@@ -153,9 +164,9 @@ An informative message about the execution of the test that does not
 correspond to a test case result and does not indicate a problem.
 .RE
 .SS Function Descriptions
-\fBtst_res()\fR and \fBtst_resm()\fR are the basic result reporting
-functions.  They report 1 or more test case results of the specified
-\fIttype\fR.  All result types are valid for these functions.  The
+\fBtst_res()\fR, \fBtst_resm()\fR and \fBtst_resm_hexd()\fR are the basic
+result reporting functions. They report 1 or more test case results of the
+specified \fIttype\fR.  All result types are valid for these functions.  The
 \fBtst_range\fR global variable indicates the number of results that will be
 reported for each call to one of these functions.  It is initialized by the
 library to 1, but may be set to a value > 1 by the test.  Each call to one of
diff --git a/include/test.h b/include/test.h
index e36ca38..c922230 100644
--- a/include/test.h
+++ b/include/test.h
@@ -191,6 +191,8 @@ void tst_res(int ttype, char *fname, char *arg_fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
 void tst_resm(int ttype, char *arg_fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
+void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
+	__attribute__ ((format (printf, 4, 5)));
 void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...)
 	__attribute__ ((format (printf, 4, 5)));
 void tst_brkm(int ttype, void (*func)(void), char *arg_fmt, ...)
diff --git a/lib/tst_res.c b/lib/tst_res.c
index ffac6d7..7e65117 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -40,6 +40,7 @@
  *    FUNCTION NAME     :
  *      tst_res() -       Print result message (include file contents)
  *      tst_resm() -      Print result message
+ *      tst_resm_hexd() - Print result message (add buffer contents in hex)
  *      tst_brk() -       Print result message (include file contents)
  *                        and break remaining test cases
  *      tst_brkm() -      Print result message and break remaining test
@@ -62,6 +63,12 @@
  *      int  ttype;
  *      char *tmesg;
  *
+ *      void tst_resm_hexd(ttype, buf, size, tmesg [,arg]...)
+ *      int  ttype;
+ *      const void *buf;
+ *      size_t size;
+ *      char *tmesg;
+ *
  *      void tst_brk(ttype, fname, cleanup, tmesg, [,argv]...)
  *      int  ttype;
  *      char *fname;
@@ -675,6 +682,47 @@ void tst_resm(int ttype, char *arg_fmt, ...)
 }
 
 /*
+ * tst_resm_hexd() - Interface to tst_res(), with no filename.
+ * Also, dump specified buffer in hex.
+ */
+void tst_resm_hexd(int ttype, const void *buf, size_t size, char *arg_fmt, ...)
+{
+	char tmesg[USERMESG];
+
+#if DEBUG
+	printf("IN tst_resm_hexd\n");
+	fflush(stdout);
+#endif
+
+	EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
+
+	static const char msg_end[] = " ...";
+	static const size_t symb_num = 3; /* space + xx */
+	size_t end_num = strlen(msg_end);
+	size_t offset = strlen(tmesg);
+
+	int size_changed = 0;
+
+	if ((offset + symb_num * size + 1) >= USERMESG) {
+		size = (USERMESG - offset) / symb_num - end_num - 1;
+		size_changed = 1;
+	}
+
+	char *pmesg = tmesg + offset;
+
+	size_t i;
+	for (i = 0; i < size; ++i) {
+		sprintf(pmesg, " %02x", ((unsigned char *)buf)[i]);
+		pmesg += symb_num;
+	}
+
+	if (size_changed)
+		strcat(pmesg, msg_end);
+
+	tst_res(ttype, NULL, "%s", tmesg);
+}
+
+/*
  * tst_brkm() - Interface to tst_brk(), with no filename.
  */
 void tst_brkm(int ttype, void (*func) (void), char *arg_fmt, ...)
-- 
1.7.1


------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-05-23 13:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-22 10:10 [LTP] [PATCH] Create a function tst_resm_hexd() to print a buffer in hex Alexey Kodanev
2013-05-22 12:56 ` chrubis
  -- strict thread matches above, loose matches on Subject: below --
2013-05-23  7:03 Alexey Kodanev
2013-05-23 13:08 ` chrubis
2013-05-21 14:42 Alexey Kodanev
2013-05-21 14:38 Alexey Kodanev
2013-05-20 16:18 [LTP] [PATCH] Create a function tst_resm_hexd " Alexey Kodanev
2013-05-21 12:49 ` chrubis
     [not found]   ` <519B8E4E.1010105@oracle.com>
2013-05-21 15:46     ` chrubis
     [not found]       ` <519B9B8D.6050004@oracle.com>
2013-05-21 16:32         ` chrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.