On Wed, Feb 18, 2015 at 6:54 AM, Martin Pitt <martin.p...@ubuntu.com> wrote:
> 219 shows a test failure in test-utf8 on big-endian machines (on
> Debian: powerpc, s390, mips):
>
> Assertion 'streq(a, utf8)' failed at src/test/test-utf8.c:103, function 
> test_utf16_to_utf8(). Aborting.
>
> gdb shows that indeed the converted string is utter bogus. a is the
> converted string, utf8 the expected outcome:
>
> | Program received signal SIGABRT, Aborted.
> | 0x20319c48 in raise () from /lib/powerpc-linux-gnu/libc.so.6
> | (gdb) f 3
> | #3  0x204befbc in test_utf16_to_utf8 () at src/test/test-utf8.c:103
> | 103             assert_se(streq(a, utf8));
> | (gdb) p a
> | $1 = 0x204eb068 
> "\346\204\200\303\230\346\210\200\303\234\346\214\200\307\230\343\237\234"
> | (gdb) p utf8
> | $2 = "abc\360\220\220\267"
>
> Patch against master attached, tested on both little-endian (unchanged
> behaviour/code) and big-endian machine.
>
> CC'ing Tom for reviewing, as that was introduced in
> http://cgit.freedesktop.org/systemd/systemd/commit/?id=04166cb7d and
> he might still have the UTF-16 stuff in his head :-)

I think we want to assume that we only get UTF-16LE, so it looks like
it is the test that is buggy. That's what we agreed, right Lennart?

How about the attached patch?

Cheers,

Tom
From 20979aaab29e4cc021fa937df8f92ea1694a7d0a Mon Sep 17 00:00:00 2001
From: Tom Gundersen <t...@jklm.no>
Date: Wed, 18 Feb 2015 14:33:50 +0100
Subject: [PATCH] test: utf8 - fix utf16 tests on BE machines

---
 src/test/test-utf8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c
index befa385..346f852 100644
--- a/src/test/test-utf8.c
+++ b/src/test/test-utf8.c
@@ -95,7 +95,7 @@ static void test_utf8_escaping_printable(void) {
 
 static void test_utf16_to_utf8(void) {
         char *a = NULL;
-        const uint16_t utf16[] = { 'a', 0xd800, 'b', 0xdc00, 'c', 0xd801, 0xdc37 };
+        const uint16_t utf16[] = { htole16('a'), htole16(0xd800), htole16('b'), htole16(0xdc00), htole16('c'), htole16(0xd801), htole16(0xdc37) };
         const char utf8[] = { 'a', 'b', 'c', 0xf0, 0x90, 0x90, 0xb7, 0 };
 
         a = utf16_to_utf8(utf16, 14);
-- 
2.3.0

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to