From: Florian Krohm Date: Fri, 3 Aug 2012 20:28:21 +0000 (+0000) Subject: Fix testcase. Iterating over an array of invalid insns to test them all X-Git-Tag: svn/VALGRIND_3_8_0~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0b36ade5bd3a60aaa6d64b50cd5918ed75e1ae4;p=thirdparty%2Fvalgrind.git Fix testcase. Iterating over an array of invalid insns to test them all does not work, as conversion will stop at the first invalid character. So... need to loop over them. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12822 --- diff --git a/none/tests/s390x/cu42.c b/none/tests/s390x/cu42.c index 015700fb2a..2b41d76b30 100644 --- a/none/tests/s390x/cu42.c +++ b/none/tests/s390x/cu42.c @@ -35,7 +35,7 @@ uint32_t pattern4[] = { uint32_t invalid[] = { 0x0000d800, 0x0000dbff, /* corner cases */ 0x00110000, 0xffffffff, /* corner cases */ - 0x0000daad, 0x0000d901, 0x0000dddd, /* misc */ + 0x0000daad, 0x0000d901, 0x0000d8ff, /* misc */ 0x00110011, 0x01000000, 0x10000000, 0xdeadbeef /* misc */ }; @@ -116,6 +116,8 @@ run_test(uint16_t *dst, uint64_t dst_len, uint32_t *src, uint64_t src_len) int main() { + int i; + /* Length == 0, no memory should be read or written */ printf("\n------------- test1 ----------------\n"); run_test(NULL, 0, NULL, 0); @@ -168,8 +170,15 @@ int main() run_test(buff, 4, pattern2, 8); /* Input contains invalid characters */ + + // As conversion stops upon encountering an invalid character, we + // need to test each invalid character separately, to make sure it + // is recognized as invalid. + printf("\n------------- test5 ----------------\n"); - run_test(buff, sizeof buff, invalid, sizeof invalid); + for (i = 0; i < sizeof invalid / 4; ++i) { + run_test(buff, sizeof buff, invalid + i, 4); + } run_test(buff, 0, invalid, sizeof invalid); // cc = 2 run_test(buff, 100, invalid, sizeof invalid); diff --git a/none/tests/s390x/cu42.stdout.exp b/none/tests/s390x/cu42.stdout.exp index e6269918a6..8bb3e24289 100644 --- a/none/tests/s390x/cu42.stdout.exp +++ b/none/tests/s390x/cu42.stdout.exp @@ -101,7 +101,47 @@ UTF16: 0000 d7ff UTF16: cc = 2 dst address difference: 0 dst len: 2000 - src address difference: 0 src len: 44 + src address difference: 0 src len: 4 +UTF16: + cc = 2 + dst address difference: 0 dst len: 2000 + src address difference: 0 src len: 4 +UTF16: + cc = 2 + dst address difference: 0 dst len: 2000 + src address difference: 0 src len: 4 +UTF16: + cc = 2 + dst address difference: 0 dst len: 2000 + src address difference: 0 src len: 4 +UTF16: + cc = 2 + dst address difference: 0 dst len: 2000 + src address difference: 0 src len: 4 +UTF16: + cc = 2 + dst address difference: 0 dst len: 2000 + src address difference: 0 src len: 4 +UTF16: + cc = 2 + dst address difference: 0 dst len: 2000 + src address difference: 0 src len: 4 +UTF16: + cc = 2 + dst address difference: 0 dst len: 2000 + src address difference: 0 src len: 4 +UTF16: + cc = 2 + dst address difference: 0 dst len: 2000 + src address difference: 0 src len: 4 +UTF16: + cc = 2 + dst address difference: 0 dst len: 2000 + src address difference: 0 src len: 4 +UTF16: + cc = 2 + dst address difference: 0 dst len: 2000 + src address difference: 0 src len: 4 UTF16: cc = 2 dst address difference: 0 dst len: 0