casaroli opened a new pull request, #4013: URL: https://github.com/apache/nuttx-apps/pull/4013
depends-on: apache/nuttx/pull/21645 ## Summary No test in nuttx-apps covers setlocale(), newlocale() or the `<libintl.h>` functions. This PR adds `testing/libc/locale` (`locale_test`, `CONFIG_TESTING_LOCALE`), a plain program that covers the two fixes of the nuttx PR in the depends-on line: - setlocale(LC_ALL, name) and newlocale(LC_ALL_MASK, name, NULL) accept "C", "POSIX", "" (LANG and LC_* not set), "C.UTF-8" and "C.utf8", and give an error for the unknown name "xx_XX.UTF-8". The name that setlocale() returns must select the locale again. After setlocale(LC_CTYPE, "C.UTF-8"), nl_langinfo(CODESET) must be "UTF-8". - With `CONFIG_LIBC_LOCALE_GETTEXT`: errno stays EPERM over gettext(), dgettext(), dcgettext(), ngettext(), dngettext() and dcngettext() when there is no message catalog, and each function returns the untranslated text. The program prints one OK or ERROR line per case and `locale test: N errors`, and returns EXIT_FAILURE when a case fails. ## Impact Test only. New option `TESTING_LOCALE`, `depends on LIBC_LOCALE`, default n as the other programs in `testing/libc`: with default y, the test would go into the image of each of the 64 defconfigs that set `CONFIG_LIBC_LOCALE`. No defconfig sets it, so CI builds and runs nothing new. No documentation change. ## Testing Builds with `CONFIG_LIBC_LOCALE=y`, `CONFIG_LIBC_LOCALE_GETTEXT=y` and `CONFIG_TESTING_LOCALE=y`. | Configuration | nuttx master 80a052ff9cc | with the nuttx PR | |---|---|---| | qemu-armv8a:knsh (kernel build, arm64, HVF), make, `locale_test` from `/system/bin` | 11 errors: setlocale() and newlocale() refuse "C.UTF-8" and "C.utf8" (4), so the CODESET check fails (1); errno 2 instead of 1 after gettext(), dgettext(), dcgettext(), ngettext(), dngettext() and dcngettext() (6); ostest status 0 | 0 errors; ostest status 0 | | qemu-armv8a:nsh (flat build, arm64, HVF), make, builtin | the same 11 errors; ostest status 0 | 0 errors; ostest status 0 | | mps2-an500:knsh (protected build, Cortex-M7, QEMU), make, `EXTRAFLAGS=-Werror`, the program built as `hello` | the same 11 errors; 0 warnings | 0 errors; 0 warnings | | qemu-armv8a:nsh, CMake | - | 0 errors; 0 warnings | The same source on the host C library (a stub `nuttx/config.h` that sets `CONFIG_LIBC_LOCALE_GETTEXT` and `FAR`), LANG and LC_ALL not set: glibc 2.43 (Fedora 44, x86_64): 0 errors. macOS 27 (no `<libintl.h>`, so no gettext cases): 2 errors, because macOS refuses "C.utf8". `tools/checkpatch.sh -c -u -m -g` passes. Not run: sim, RISC-V, x86_64, clang. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
