* Jiri Olsa (jolsa(a)redhat.com) wrote:
On Sat, May 14, 2011 at 12:23:07AM +0100, David Gilbert wrote:
> Hi,
> I enabled the tests for arm in configure.ac, copied the
> test/sysdeps/i686 to arm and tried it
> (I ran test/test.sh from the top level - is that the intended way?)
yep, thats what I do :)
OK.
<snip>
> Is there a reason that you didn't use isprint() - perhaps
worried
> about the difference between locales?
nope, just my ignorance ;) feel free to make the change
> I'm also getting result mismatches on test_char_6 (getting
0x0e
> instead of the expected 0x6e).
> I haven't worked through the math of teh code in test_char_6, but with
> all those divides and stuff I
> wouldn't be surprised if this is also a signedness issue.
now I wonder that math inside the shared lib functions is really necessary,
we could probably return single value to ease the debug
OK, so below is a patch that:
a) Switches to using isprint() when deciding whether to print the character
b) Sets the LC_ALL to C in the test script to make sure isprint always does
the same thing
c) Switches to using bash for test.sh
d) Changes the char tests to only use + and - in the tests and fixes up
the expected result.
> /bin/sh I have seems to be dash
> which doesn't have functions.
ok
>
> Another suggestion is not to separate test_long into CPU specific
> sysdeps; there are only a few
> combinations and they'll be shared among lots of CPUs - i686 and ARM
> are the same for those tests.
we could make one global being run for i686/arm and separate x86_64
or something like that
So I haven't changed this (or for that reason enabled the ARM test) in this
patch because I thought I'd leave this one for you. My suggestion is to
make a sysdeps/long32.c and sysdeps/long64.c (it's probably slightly more subtle
than that, but I think that will do) and then choose which one to use.
Dave
commit 4b866e787d2dfcdb53f8494f6c50b55101c742b4
Author: Dr. David Alan Gilbert <david.gilbert(a)linaro.org>
Date: Tue May 17 11:34:58 2011 +0000
Change character tests to be insensitive to sign, force test.sh to use bash
diff --git a/src/args.c b/src/args.c
index db1e2b9..7c6def8 100644
--- a/src/args.c
+++ b/src/args.c
@@ -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..32c621e 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 a;
}
char test_char_2(char a, char b)
{
- return a - b;
+ return a + b;
}
char test_char_3(char a, char b, char c)
{
- return a * b - c;
+ return a + b - c;
}
char test_char_4(char a, char b, char c, char d)
{
- return a + b - c * d;
+ return a - b + c - d;
}
char test_char_5(char a, char b, char c, char d, char e)
{
- return a + b * c / d * e;
+ return a + b - c + d - e;
}
char test_char_6(char a, char b, char c, char d, char e, char f)
{
- return a / b * c / d * e - f;
+ return a - b + c - d + e - f;
}
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 a + b - c + d - e + f - g;
}
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 a - b + c - d + e - f + g - h;
}
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 a + b - c + d - e + f - g + h - i;
}
short test_short_1(short a)
diff --git a/test/test-args.c b/test/test-args.c
index a29c86c..b898e89 100644
--- a/test/test-args.c
+++ b/test/test-args.c
@@ -9,47 +9,47 @@ static int test_char(struct lt_config_shared *sh)
struct re_test_data data1[] = {
{ RE_TEST_TYPE_STR, 0, 21, "test_char_1\\(a = 0x0a\\)" },
{ RE_TEST_TYPE_STR, 22, -1, "\\[.*lib-test-args.so\\] \\{" },
- { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_1 = 0x64 'd'" },
+ { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_1 = 0x0a" },
};
struct re_test_data data2[] = {
{ RE_TEST_TYPE_STR, 0, 31, "test_char_2\\(a = 0x0a, b = 0x14\\)" },
{ RE_TEST_TYPE_STR, 32, -1, "\\[.*lib-test-args.so\\] \\{" },
- { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_2 = 0xf6" },
+ { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_2 = 0x1e" },
};
struct re_test_data data3[] = {
{ RE_TEST_TYPE_STR, 0, 41, "test_char_3\\(a = 0x01, b = 0xfe, c = 0x07\\)"
},
{ RE_TEST_TYPE_STR, 42, -1, "\\[.*lib-test-args.so\\] \\{" },
- { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_3 = 0xf7" },
+ { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_3 = 0xf8" },
};
struct re_test_data data4[] = {
{ RE_TEST_TYPE_STR, 0, 59, "test_char_4\\(a = 0x64 'd', b = 0x02, c =
0x63 'c', d = 0xff\\)" },
{ RE_TEST_TYPE_STR, 60, -1, "\\[.*lib-test-args.so\\] \\{" },
- { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_4 = 0xc9" },
+ { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_4 = 0xc6" },
};
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 = 0xae" },
};
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\\)" },
{ RE_TEST_TYPE_STR, 76, -1, "\\[.*lib-test-args.so\\] \\{" },
- { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_6 = 0x63 'c'" },
+ { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_6 = 0x3a ':'" },
};
struct re_test_data data7[] = {
{ RE_TEST_TYPE_STR, 0, 81, "test_char_7\\(a = 0x01, b = 0x02, c = 0x03, d = 0x04,
e = 0x05, f = 0x06, g = 0x07\\)" },
{ RE_TEST_TYPE_STR, 82, -1, "\\[.*lib-test-args.so\\] \\{" },
- { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_7 = 0x19" },
+ { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_7 = 0xfe" },
};
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 = 0xd4" },
};
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\\)"
},
{ RE_TEST_TYPE_STR, 110, -1, "\\[.*lib-test-args.so\\] \\{" },
- { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_9 = 0xd0" },
+ { RE_TEST_TYPE_STR, -1, -1, "\\} test_char_9 = 0xef" },
};
#define DATA_CNT(num) (sizeof(data ## num)/sizeof(struct re_test_data))
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]"