summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-06-01 10:09:54 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-06-01 16:00:33 +0200
commit181ae787f8a65beb6ba1fc29178acd18676772f1 (patch)
tree34791f6d132356b0331c32a0981030bb0d56877e /tests
parent2ec2d70980a5a200c234a16d305cb4c34e5a09ea (diff)
downloadgnutls-181ae787f8a65beb6ba1fc29178acd18676772f1.tar.gz
tests: utils: added c_print()
Diffstat (limited to 'tests')
-rw-r--r--tests/utils.c15
-rw-r--r--tests/utils.h1
2 files changed, 15 insertions, 1 deletions
diff --git a/tests/utils.c b/tests/utils.c
index 2a0b944e07..83ec426de8 100644
--- a/tests/utils.c
+++ b/tests/utils.c
@@ -152,7 +152,7 @@ void escapeprint(const char *str, size_t len)
{
size_t i;
- printf(" (length %d bytes):\n\t", (int)len);
+ printf(" (length %d bytes):\n\t'", (int)len);
for (i = 0; i < len; i++) {
if (((str[i] & 0xFF) >= 'A' && (str[i] & 0xFF) <= 'Z') ||
((str[i] & 0xFF) >= 'a' && (str[i] & 0xFF) <= 'z') ||
@@ -167,6 +167,19 @@ void escapeprint(const char *str, size_t len)
printf("\n");
}
+void c_print(const unsigned char *str, size_t len)
+{
+ size_t i;
+
+ printf(" (length %d bytes):\n\t\"", (int)len);
+ for (i = 0; i < len; i++) {
+ printf("\\x%02X", (str[i] & 0xFF));
+ if ((i + 1) % 16 == 0 && (i + 1) < len)
+ printf("\"\n\t\"");
+ }
+ printf("\"\n");
+}
+
void hexprint(const void *_str, size_t len)
{
size_t i;
diff --git a/tests/utils.h b/tests/utils.h
index dd576e4363..3978ee87f6 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -63,6 +63,7 @@ extern void fail_ignore(const char *format, ...)
extern void success(const char *format, ...)
__attribute__ ((format(printf, 1, 2)));
+extern void c_print(const unsigned char *str, size_t len);
extern void escapeprint(const char *str, size_t len);
extern void hexprint(const void *str, size_t len);
extern void binprint(const void *str, size_t len);