[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: more workarounds against glibc C locale bug
From: |
Bruno Haible |
Subject: |
Re: more workarounds against glibc C locale bug |
Date: |
Fri, 31 Mar 2023 04:48:18 +0200 |
Some of the new tests fail on Android:
FAIL: test-btowc3.sh
====================
../../gltests/test-btowc.c:76: assertion 'wc == c || wc == 0xDF00 + c' failed
Aborted
FAIL test-btowc3.sh (exit status: 1)
FAIL: test-mbsnrtowcs5.sh
=========================
../../gltests/test-mbsnrtowcs.c:327: assertion 'ret == 1' failed
Aborted
FAIL test-mbsnrtowcs5.sh (exit status: 1)
FAIL: test-mbsrtowcs5.sh
========================
../../gltests/test-mbsrtowcs.c:327: assertion 'ret == 1' failed
Aborted
FAIL test-mbsrtowcs5.sh (exit status: 1)
FAIL: test-mbstowcs5.sh
=======================
../../gltests/test-mbstowcs.c:226: assertion 'ret == 1' failed
Aborted
FAIL test-mbstowcs5.sh (exit status: 1)
Fixed like this.
2023-03-30 Bruno Haible <bruno@clisp.org>
Avoid test failures on Android.
* tests/test-btowc.c (main): Treat C locale like in
tests/test-mbrtowc.c.
* tests/test-mbsrtowcs.c (main): Likewise.
* tests/test-mbsnrtowcs.c (main): Likewise.
* tests/test-mbstowcs.c (main): Likewise.
diff --git a/tests/test-btowc.c b/tests/test-btowc.c
index e5918c36e9..8a803e5335 100644
--- a/tests/test-btowc.c
+++ b/tests/test-btowc.c
@@ -39,6 +39,15 @@ main (int argc, char *argv[])
ASSERT (btowc (EOF) == WEOF);
+#ifdef __ANDROID__
+ /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the
+ "C" locale. Furthermore, when you attempt to set the "C" or "POSIX"
+ locale via setlocale(), what you get is a "C" locale with UTF-8 encoding,
+ that is, effectively the "C.UTF-8" locale. */
+ if (argc > 1 && strcmp (argv[1], "3") == 0 && MB_CUR_MAX > 1)
+ argv[1] = "2";
+#endif
+
if (argc > 1)
switch (argv[1][0])
{
diff --git a/tests/test-mbsnrtowcs.c b/tests/test-mbsnrtowcs.c
index 2d0e6a7521..9831fd1843 100644
--- a/tests/test-mbsnrtowcs.c
+++ b/tests/test-mbsnrtowcs.c
@@ -72,6 +72,15 @@ main (int argc, char *argv[])
ASSERT (mbsinit (&state));
}
+#ifdef __ANDROID__
+ /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the
+ "C" locale. Furthermore, when you attempt to set the "C" or "POSIX"
+ locale via setlocale(), what you get is a "C" locale with UTF-8 encoding,
+ that is, effectively the "C.UTF-8" locale. */
+ if (argc > 1 && strcmp (argv[1], "5") == 0 && MB_CUR_MAX > 1)
+ argv[1] = "2";
+#endif
+
if (argc > 1)
{
int unlimited;
diff --git a/tests/test-mbsrtowcs.c b/tests/test-mbsrtowcs.c
index 7e8cc4a1ea..3c351f2346 100644
--- a/tests/test-mbsrtowcs.c
+++ b/tests/test-mbsrtowcs.c
@@ -72,6 +72,15 @@ main (int argc, char *argv[])
ASSERT (mbsinit (&state));
}
+#ifdef __ANDROID__
+ /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the
+ "C" locale. Furthermore, when you attempt to set the "C" or "POSIX"
+ locale via setlocale(), what you get is a "C" locale with UTF-8 encoding,
+ that is, effectively the "C.UTF-8" locale. */
+ if (argc > 1 && strcmp (argv[1], "5") == 0 && MB_CUR_MAX > 1)
+ argv[1] = "2";
+#endif
+
if (argc > 1)
{
int unlimited;
diff --git a/tests/test-mbstowcs.c b/tests/test-mbstowcs.c
index a33511a07d..21ee0c95dd 100644
--- a/tests/test-mbstowcs.c
+++ b/tests/test-mbstowcs.c
@@ -65,6 +65,15 @@ main (int argc, char *argv[])
ASSERT (wc == 0);
}
+#ifdef __ANDROID__
+ /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the
+ "C" locale. Furthermore, when you attempt to set the "C" or "POSIX"
+ locale via setlocale(), what you get is a "C" locale with UTF-8 encoding,
+ that is, effectively the "C.UTF-8" locale. */
+ if (argc > 1 && strcmp (argv[1], "5") == 0 && MB_CUR_MAX > 1)
+ argv[1] = "2";
+#endif
+
if (argc > 1)
{
int unlimited;