tests: Adapt utf8locale to muslmaster
commit098504eef2fe08c512a893a7cd5bf6cd7d76964e
authorPetr Písař <petr.pisar@atlas.cz>
Sun, 12 May 2024 11:17:27 +0000 (12 13:17 +0200)
committerPetr Písař <petr.pisar@atlas.cz>
Sun, 12 May 2024 12:19:20 +0000 (12 14:19 +0200)
tree983b34bb24a3b31d234e5be66a38c66a14443c45
parentbb749f6b02fb68002205c0412698adbf93356ffd
tests: Adapt utf8locale to musl

utf8locale test failed in musl:

    Testing unit: utf8locale
    NULL input: passed
    Empty string: passed
    ASCII text: passed
    non-ASCII text in UTF-8 locale: passed
    OTP message in UTF-8 locale: passed
    non-ASCII text in ISO-8859-2 locale: failed
    reason: output differs: expected=`��len� �lu�ou�k�' is=`Šíleně žluťoučký'
    non-ASCII text in C locale: failed
    reason: correct is NULL, output is not NULL and should be
    Test results: unit = utf8locale, passed = 5, failed = 2, skipped = 0

The cause of "ISO-8859-2 locale" failure was that musl does not yet
fully support locales and handles any character set identifier in
a locale specifier as an alias for UTF-8. This patch fixes the test by
validing a code set the exampled locale actually sets.

"non-ASCII text in C locale" failed because musl performs a lossy
conversion (replaces unrepresantable chacracters with stars) in constrat
to strict conversion done by glibc. POSIX recommends "an
implementation-defined conversion" in that case. Because
_isds_utf82locale is only used for presenting messages, a lossy output
is not a big deal (libisds simply omitts an incovertible part of
a message on glibc). This patch relaxes the test to accept any output.
We keep the test here to cover all code paths.

https://www.openwall.com/lists/musl/2024/05/11/6
https://bugs.gentoo.org/show_bug.cgi?id=928107
test/offline/utf82locale.c