+2018-07-04 Carlos O'Donell <carlos@redhat.com>
+
+ [BZ #23164]
+ * localedata/tst-langinfo-setlocale.c: New file.
+ * localedata/tst-langinfo-setlocale-static.c: New file.
+ * localedata/tst-langinfo-newlocale.c: New file.
+ * localedata/tst-langinfo-newlocale-static.c: New file.
+ * localedata/Makefile (test-srcs): Remove tst-langinfo. Add
+ tst-langinfo-setlocale, tst-langinfo-setlocale-static,
+ tst-langinfo-newlocale, tst-langinfo-newlocale-static.
+ (tests-static): Remove tst-langinfo-static. Add
+ tst-langinfo-newlocale-static, tst-langinfo-setlocale-static.
+ (tests-special): Remove $(objpfx)tst-langinfo.out,
+ $(objpfx)tst-langinfo-static.out. Add
+ $(objpfx)tst-langinfo-setlocale.out,
+ $(objpfx)tst-langinfo-newlocale.out,
+ $(objpfx)tst-langinfo-setlocale-static.out,
+ $(objpfx)tst-langinfo-newlocale-static.out.
+ ($(objpfx)tst-langinfo.out): Remove.
+ ($(objpfx)tst-langinfo-static.out): Remove.
+ ($(objpfx)tst-langinfo-newlocale.out): New target.
+ ($(objpfx)tst-langinfo-newlocale-static.out): New target.
+ (test-xfail-tst-langinfo-newlocale-static): Add.
+ ($(objpfx)tst-langinfo-setlocale.out): New target.
+ ($(objpfx)tst-langinfo-setlocale-static.out): New target.
+ * localedata/tst-langinfo.c: Call test_locale.
+ * localedata/tst-langinfo.sh: Add LC_MONETARY CURRENCY_SYMBOL test
+ data.
+
2018-07-04 Florian Weimer <fweimer@redhat.com>
testrun.sh: Implement --tool=strace, --tool=valgrind
test-srcs := collate-test xfrm-test tst-fmon tst-rpmatch tst-trans \
- tst-ctype tst-langinfo tst-langinfo-static tst-numeric
+ tst-ctype tst-langinfo-newlocale tst-langinfo-setlocale \
+ tst-langinfo-newlocale-static tst-langinfo-setlocale-static \
+ tst-numeric
# List of test input files (list sorted alphabetically):
test-input := \
am_ET.UTF-8 \
tests: $(objdir)/iconvdata/gconv-modules
-tests-static += tst-langinfo-static
+tests-static += tst-langinfo-newlocale-static tst-langinfo-setlocale-static
ifeq ($(run-built-tests),yes)
tests-special += $(objpfx)sort-test.out $(objpfx)tst-fmon.out \
$(objpfx)tst-locale.out $(objpfx)tst-rpmatch.out \
$(objpfx)tst-trans.out $(objpfx)tst-ctype.out \
- $(objpfx)tst-langinfo.out $(objpfx)tst-langinfo-static.out \
+ $(objpfx)tst-langinfo-newlocale.out \
+ $(objpfx)tst-langinfo-setlocale.out \
+ $(objpfx)tst-langinfo-newlocale-static.out \
+ $(objpfx)tst-langinfo-setlocale-static.out \
$(objpfx)tst-numeric.out
# We have to generate locales (list sorted alphabetically)
LOCALES := \
$(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
'$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
$(evaluate-test)
-$(objpfx)tst-langinfo.out: tst-langinfo.sh $(objpfx)tst-langinfo \
+$(objpfx)tst-langinfo-newlocale.out: tst-langinfo.sh \
+ $(objpfx)tst-langinfo-newlocale \
$(objpfx)sort-test.out \
$(addprefix $(objpfx),$(CTYPE_FILES))
$(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
'$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
$(evaluate-test)
-$(objpfx)tst-langinfo-static.out: tst-langinfo.sh $(objpfx)tst-langinfo-static \
+$(objpfx)tst-langinfo-newlocale-static.out: tst-langinfo.sh \
+ $(objpfx)tst-langinfo-newlocale-static \
$(objpfx)sort-test.out \
$(addprefix $(objpfx),$(CTYPE_FILES))
$(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
'$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
$(evaluate-test)
+# Static use of newlocale is known not to work. See Bug 23164.
+test-xfail-tst-langinfo-newlocale-static = yes
+
+$(objpfx)tst-langinfo-setlocale.out: tst-langinfo.sh \
+ $(objpfx)tst-langinfo-setlocale \
+ $(objpfx)sort-test.out \
+ $(addprefix $(objpfx),$(CTYPE_FILES))
+ $(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
+ '$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
+ $(evaluate-test)
+$(objpfx)tst-langinfo-setlocale-static.out: tst-langinfo.sh \
+ $(objpfx)tst-langinfo-setlocale-static \
+ $(objpfx)sort-test.out \
+ $(addprefix $(objpfx),$(CTYPE_FILES))
+ $(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
+ '$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
+ $(evaluate-test)
+
$(objpfx)tst-digits.out: $(objpfx)tst-locale.out
$(objpfx)tst-mbswcs6.out: $(addprefix $(objpfx),$(CTYPE_FILES))
endif
--- /dev/null
+#include <tst-langinfo-newlocale.c>
--- /dev/null
+/* Test program for newlocale() + nl_langinfo_l() functions.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <langinfo.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Return 0 if the test passed, 1 for failed. */
+static int
+test_locale (char *locale, char *paramstr, int param, char *expected)
+{
+ char *actual;
+ locale_t loc;
+ int result = 0;
+
+ loc = newlocale (LC_ALL_MASK, locale, 0);
+ if (loc == NULL)
+ {
+ puts (": failed to create new locale");
+ return 1;
+ }
+
+ printf ("nl_langinfo_l(%s, %s [%p])", paramstr, locale, loc);
+ actual = nl_langinfo_l(param, loc);
+ printf (" = \"%s\", ", actual);
+
+ if (strcmp (actual, expected) == 0)
+ puts ("OK");
+ else
+ {
+ printf ("FAILED (expected: %s)\n", expected);
+ result = 1;
+ }
+
+ freelocale (loc);
+ return result;
+}
+
+#include <tst-langinfo.c>
--- /dev/null
+#include <tst-langinfo-setlocale.c>
--- /dev/null
+/* Test program for setlocale() + nl_langinfo() functions.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <langinfo.h>
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Return 0 if the test passed, 1 for failed. */
+static int
+test_locale (char *locale, char *paramstr, int param, char *expected)
+{
+ char *actual;
+
+ printf ("LC_ALL=%s nl_langinfo(%s)", locale, paramstr);
+
+ /* Set the locale and check whether it worked. */
+ setlocale (LC_ALL, locale);
+ if (strcmp (locale, setlocale (LC_ALL, NULL)) != 0)
+ {
+ puts (": failed to set locale");
+ return 1;
+ }
+
+ actual = nl_langinfo (param);
+ printf (" = \"%s\", ", actual);
+
+ if (strcmp (actual, expected) == 0)
+ puts ("OK");
+ else
+ {
+ printf ("FAILED (expected: %s)\n", expected);
+ return 1;
+ }
+
+ return 0;
+}
+
+#include <tst-langinfo.c>
-/* Test program for nl_langinfo() function.
+/* Test driver for nl_langinfo[_l] functions.
Copyright (C) 2000-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>.
char *locale;
char *paramstr;
char *expected;
- char *actual;
int param;
if (fgets (buf, sizeof (buf), stdin) == NULL)
continue;
}
- /* Set the locale and check whether it worked. */
- printf ("LC_ALL=%s nl_langinfo(%s)", locale, paramstr);
- setlocale (LC_ALL, locale);
- if (strcmp (locale, setlocale (LC_ALL, NULL)) != 0)
- {
- puts (": failed to set locale");
- result = 1;
- continue;
- }
-
- actual = nl_langinfo (param);
- printf (" = \"%s\", ", actual);
-
- if (strcmp (actual, expected) == 0)
- puts ("OK");
- else
- {
- printf ("FAILED (expected: %s)\n", expected);
- result = 1;
- }
+ result = test_locale (locale, paramstr, param, expected);
}
return result;
en_US.ISO-8859-1 THOUSEP ,
en_US.ISO-8859-1 YESEXPR ^[+1yY]
en_US.ISO-8859-1 NOEXPR ^[-0nN]
+en_US.UTF-8 CURRENCY_SYMBOL $
de_DE.ISO-8859-1 ABDAY_1 So
de_DE.ISO-8859-1 ABDAY_2 Mo
de_DE.ISO-8859-1 ABDAY_3 Di
de_DE.UTF-8 THOUSEP .
de_DE.UTF-8 YESEXPR ^[+1jJyY]
de_DE.UTF-8 NOEXPR ^[-0nN]
+de_DE.UTF-8 CURRENCY_SYMBOL €
fr_FR.ISO-8859-1 ABDAY_1 dim.
fr_FR.ISO-8859-1 ABDAY_2 lun.
fr_FR.ISO-8859-1 ABDAY_3 mar.
fr_FR.ISO-8859-1 THOUSEP " "
fr_FR.ISO-8859-1 YESEXPR ^[+1oOyY]
fr_FR.ISO-8859-1 NOEXPR ^[-0nN]
+fr_FR.UTF-8 CURRENCY_SYMBOL €
ja_JP.EUC-JP ABDAY_1 Æü
ja_JP.EUC-JP ABDAY_2 ·î
ja_JP.EUC-JP ABDAY_3 ²Ð
# Is CRNCYSTR supposed to be the national or international sign?
# ja_JP.EUC-JP CRNCYSTR JPY
ja_JP.EUC-JP CODESET EUC-JP
+ja_JP.UTF-8 CURRENCY_SYMBOL ¥
EOF
${tst_langinfo_before_env} \
${run_program_env} \