diff options
author | Dr. David Alan Gilbert <david.gilbert@linaro.org> | 2011-05-24 23:39:47 +0200 |
---|---|---|
committer | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2011-05-25 12:45:30 +0200 |
commit | 56798f25922db3299e11418e9114329006a498ab (patch) | |
tree | 8f7831281dcae9abfd8db953a922cd98a272a1e3 | |
parent | d0d232d7b97ea8962f64fc2126d764009048a090 (diff) | |
download | latrace-56798f25922db3299e11418e9114329006a498ab.tar.gz latrace-56798f25922db3299e11418e9114329006a498ab.tar.xz latrace-56798f25922db3299e11418e9114329006a498ab.zip |
args - use isprint to decide whether to print the character
+ force test.sh to use bash
+ fix test_char tests
contributed by Dr. David Alan Gilbert <david.gilbert@linaro.org>
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/args.c | 3 | ||||
-rw-r--r-- | test/lib-test-args.c | 18 | ||||
-rw-r--r-- | test/test-args.c | 8 | ||||
-rwxr-xr-x | test/test.sh | 5 |
5 files changed, 25 insertions, 15 deletions
@@ -1,3 +1,9 @@ +2011-05-24 Jiri Olsa <olsajiri@gmail.com> + * args - use isprint to decide whether to print the character, + force test.sh to use bash + (contributed by Dr. David Alan Gilbert <david.gilbert@linaro.org>) + * fix test_char tests + 2011-05-13 Jiri Olsa <olsajiri@gmail.com> * build fix for ARM (contributed by Dr. David Alan Gilbert <david.gilbert@linaro.org>) @@ -19,6 +19,7 @@ */ +#include <ctype.h> #include <stdlib.h> #include <string.h> #include <search.h> @@ -850,7 +851,7 @@ do { \ len = snprintf(argbuf, alen, "NULL"); } else { - if (*((char*) pval) <= ' ') + if (!isprint(*((char*) pval))) len = snprintf(argbuf, alen, "0x%02x", *((unsigned char*) pval)); else diff --git a/test/lib-test-args.c b/test/lib-test-args.c index 84b5c29..865d675 100644 --- a/test/lib-test-args.c +++ b/test/lib-test-args.c @@ -1,47 +1,47 @@ char test_char_1(char a) { - return a*a; + return 'd'; } char test_char_2(char a, char b) { - return a - b; + return 0xf6; } char test_char_3(char a, char b, char c) { - return a * b - c; + return 0xf7; } char test_char_4(char a, char b, char c, char d) { - return a + b - c * d; + return 0xc9; } char test_char_5(char a, char b, char c, char d, char e) { - return a + b * c / d * e; + return 0x2; } char test_char_6(char a, char b, char c, char d, char e, char f) { - return a / b * c / d * e - f; + return 'c'; } char test_char_7(char a, char b, char c, char d, char e, char f, char g) { - return a / b + c - d * e + f * g; + return 0x19; } char test_char_8(char a, char b, char c, char d, char e, char f, char g, char h) { - return a + b + c - d + e - f + g / h; + return '9'; } char test_char_9(char a, char b, char c, char d, char e, char f, char g, char h, char i) { - return a - b + c - d * e - f / g - h - i; + return 0xd0; } short test_short_1(short a) diff --git a/test/test-args.c b/test/test-args.c index a29c86c..80497c8 100644 --- a/test/test-args.c +++ b/test/test-args.c @@ -27,9 +27,9 @@ static int test_char(struct lt_config_shared *sh) { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_4 = 0xc9" }, }; struct re_test_data data5[] = { - { RE_TEST_TYPE_STR, 0, 65, "test_char_5\\(a = 0xff, b = 0x15, c = 0x0d, d = 0x20, e = 0x79 'y'\\)" }, - { RE_TEST_TYPE_STR, 66, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_5 = 0xc7" }, + { RE_TEST_TYPE_STR, 0, 69, "test_char_5\\(a = 0xff, b = 0x15, c = 0x0d, d = 0x20 ' ', e = 0x79 'y'\\)" }, + { RE_TEST_TYPE_STR, 70, -1, "\\[.*lib-test-args.so\\] \\{" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_5 = 0x02" }, }; struct re_test_data data6[] = { { RE_TEST_TYPE_STR, 0, 75, "test_char_6\\(a = 0x64 'd', b = 0xc8, c = 0xd5, d = 0x0c, e = 0xc7, f = 0xf2\\)" }, @@ -44,7 +44,7 @@ static int test_char(struct lt_config_shared *sh) struct re_test_data data8[] = { { RE_TEST_TYPE_STR, 0, 95, "test_char_8\\(a = 0xf5, b = 0x15, c = 0x1e, d = 0xfc, e = 0x17, f = 0x85, g = 0x46 'F', h = 0x06\\)" }, { RE_TEST_TYPE_STR, 96, -1, "\\[.*lib-test-args.so\\] \\{" }, - { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_8 = 0xc9" }, + { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_8 = 0x39 '9'" }, }; struct re_test_data data9[] = { { RE_TEST_TYPE_STR, 0, 109, "test_char_9\\(a = 0xf6, b = 0x01, c = 0x03, d = 0x04, e = 0x09, f = 0x63 'c', g = 0x4e 'N', h = 0xf7, i = 0x0c\\)" }, diff --git a/test/test.sh b/test/test.sh index efcd545..769adf4 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,4 +1,7 @@ -#!/bin/sh +#!/bin/bash + +# Force locale to ensure we always get the same output +export LC_ALL=C # common tests echo "[APP test-common]" |