diff options
author | Yuri Pankov <yuri.pankov@nexenta.com> | 2018-04-29 21:28:12 +0300 |
---|---|---|
committer | Hans Rosenfeld <hans.rosenfeld@joyent.com> | 2018-05-16 12:03:43 +0200 |
commit | 804635d7bfa86d5f677fada06cb30420313f1159 (patch) | |
tree | 06785df23dd5e2ac2febed8901c51a4403067b85 /usr/src/test/libc-tests | |
parent | 4540c8e2f029ecd3f040b27b7489b1c9f2d920c0 (diff) | |
download | illumos-joyent-804635d7bfa86d5f677fada06cb30420313f1159.tar.gz |
9511 printf family isn't aware of multibyte decimal point characters
Reviewed by: Dan McDonald <danmcd@joyent.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Diffstat (limited to 'usr/src/test/libc-tests')
-rw-r--r-- | usr/src/test/libc-tests/doc/README | 10 | ||||
-rw-r--r-- | usr/src/test/libc-tests/runfiles/default.run | 2 | ||||
-rw-r--r-- | usr/src/test/libc-tests/tests/Makefile | 1 | ||||
-rw-r--r-- | usr/src/test/libc-tests/tests/printf-9511.c | 70 |
4 files changed, 78 insertions, 5 deletions
diff --git a/usr/src/test/libc-tests/doc/README b/usr/src/test/libc-tests/doc/README index f5640c58dd..e74f398ec1 100644 --- a/usr/src/test/libc-tests/doc/README +++ b/usr/src/test/libc-tests/doc/README @@ -49,16 +49,16 @@ install the Utils Unit Test Suite. Note, the framework will be installed automatically, as this test suite depends on it. -Additionally some text locales are required, specifically, en_US.UTF-8, -de_DE.UTF-8, ja_JP.UTF-8, and ru_RU.UTF-8. Again, these are listed as -dependencies and will be automatically installed. +Additionally some text locales are required, specifically, ar_AE.UTF-8, +de_DE.UTF-8, en_US.UTF-8, ja_JP.UTF-8, and ru_RU.UTF-8. Again, these are +listed as dependencies and will be automatically installed. 3. Running this Unit Test Suite The pre-requisites for running the this Unit Test Suite are: - Any user may perform these tests. - - The en_US.UTF-8, en_GB.ISO8859-15, ja_JP.UTF-8, de_DE.UTF-8, and - ru_RU.UTF-8 locales must be installed. + - The ar_AE.UTF-8, de_DE.UTF-8, en_US.UTF-8, en_GB.ISO8859-15, + ja_JP.UTF-8, and ru_RU.UTF-8 locales must be installed. Once the pre-requisites are satisfied, simply run the libctest script: diff --git a/usr/src/test/libc-tests/runfiles/default.run b/usr/src/test/libc-tests/runfiles/default.run index a58c46d6c8..15e3d60d69 100644 --- a/usr/src/test/libc-tests/runfiles/default.run +++ b/usr/src/test/libc-tests/runfiles/default.run @@ -80,6 +80,8 @@ timeout = 600 [/opt/libc-tests/tests/quick_exit] [/opt/libc-tests/tests/psignal] [/opt/libc-tests/tests/printf-6961.64] +[/opt/libc-tests/tests/printf-9511.32] +[/opt/libc-tests/tests/printf-9511.64] [/opt/libc-tests/tests/priv_gettext] [/opt/libc-tests/tests/strerror] [/opt/libc-tests/tests/timespec_get.32] diff --git a/usr/src/test/libc-tests/tests/Makefile b/usr/src/test/libc-tests/tests/Makefile index f9b80255f0..68bd817ed4 100644 --- a/usr/src/test/libc-tests/tests/Makefile +++ b/usr/src/test/libc-tests/tests/Makefile @@ -38,6 +38,7 @@ PROGS = \ endian \ env-7076 \ fnmatch \ + printf-9511 \ psignal-5097 \ quick_exit_order \ quick_exit_status \ diff --git a/usr/src/test/libc-tests/tests/printf-9511.c b/usr/src/test/libc-tests/tests/printf-9511.c new file mode 100644 index 0000000000..98823f0d10 --- /dev/null +++ b/usr/src/test/libc-tests/tests/printf-9511.c @@ -0,0 +1,70 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2018 Nexenta Systems, Inc. + */ + +/* + * Note that this file is easiest edited with a UTF-8 capable editor, + * as there are embedded UTF-8 symbols in some of the strings. + */ + +#include <err.h> +#include <locale.h> +#include <stdio.h> +#include <string.h> + +struct { + const char *locale; + const char *convspec; + const float fp; + const char *expected; +} fpconv[] = { + "C", "%a", 3.2, "0x1.99999a0000000p+1", + "C", "%e", 3.2, "3.200000e+00", + "C", "%f", 3.2, "3.200000", + "C", "%g", 3.2, "3.2", + "ar_AE.UTF-8", "%a", 3.2, "0x1٫99999a0000000p+1", + "ar_AE.UTF-8", "%e", 3.2, "3٫200000e+00", + "ar_AE.UTF-8", "%f", 3.2, "3٫200000", + "ar_AE.UTF-8", "%g", 3.2, "3٫2", + "en_US.UTF-8", "%a", 3.2, "0x1.99999a0000000p+1", + "en_US.UTF-8", "%e", 3.2, "3.200000e+00", + "en_US.UTF-8", "%f", 3.2, "3.200000", + "en_US.UTF-8", "%g", 3.2, "3.2", + "ru_RU.UTF-8", "%a", 3.2, "0x1,99999a0000000p+1", + "ru_RU.UTF-8", "%e", 3.2, "3,200000e+00", + "ru_RU.UTF-8", "%f", 3.2, "3,200000", + "ru_RU.UTF-8", "%g", 3.2, "3,2", + NULL, NULL, 0, NULL +}; + +int +main(void) +{ + char buf[100]; + int i; + + for (i = 0; fpconv[i].locale != NULL; i++) { + if (setlocale(LC_ALL, fpconv[i].locale) == NULL) + err(1, "failed to set locale to %s", fpconv[i].locale); + + (void) sprintf(buf, fpconv[i].convspec, fpconv[i].fp); + if (strcmp(fpconv[i].expected, buf) != 0) { + errx(1, "locale=%s, convspec=%s, expected=%s, got=%s", + fpconv[i].locale, fpconv[i].convspec, + fpconv[i].expected, buf); + } + } + + return (0); +} |