From: Bruno Haible Date: Sat, 20 Oct 2018 15:34:23 +0000 (+0200) Subject: Rename test gettext-6 to intl-thread-2 and support more platforms. X-Git-Tag: v0.20~317 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f90b433d5a2d012a7c25e879d6be0041d01d596;p=thirdparty%2Fgettext.git Rename test gettext-6 to intl-thread-2 and support more platforms. * gettext-tools/tests/intl-thread-2: Renamed from gettext-tools/tests/gettext-6. Don't limit to fixed set of platforms. * gettext-tools/tests/intl-thread-2-prg.c: Renamed from gettext-tools/tests/gettext-6-prg.c. Expect locale names as arguments. * gettext-tools/tests/intl-thread-2-1.po: Renamed from gettext-tools/tests/gettext-6-2.po. Convert to UTF-8. * gettext-tools/tests/intl-thread-2-2.po: Renamed from gettext-tools/tests/gettext-6-1.po. Convert to UTF-8. * gettext-tools/tests/Makefile.am: Update. --- diff --git a/.gitignore b/.gitignore index 9a6db83bf..82b740a0f 100644 --- a/.gitignore +++ b/.gitignore @@ -659,8 +659,6 @@ autom4te.cache/ /gettext-tools/tests/fc4.exe /gettext-tools/tests/fc5 /gettext-tools/tests/fc5.exe -/gettext-tools/tests/gettext-6-prg -/gettext-tools/tests/gettext-6-prg.exe /gettext-tools/tests/gettext-7-prg /gettext-tools/tests/gettext-7-prg.exe /gettext-tools/tests/gettext-8-prg @@ -679,6 +677,8 @@ autom4te.cache/ /gettext-tools/tests/intl-setlocale-2-prg.exe /gettext-tools/tests/intl-thread-1-prg /gettext-tools/tests/intl-thread-1-prg.exe +/gettext-tools/tests/intl-thread-2-prg +/gettext-tools/tests/intl-thread-2-prg.exe /gettext-tools/tests/sentence-1-prg /gettext-tools/tests/sentence-1-prg.exe /gettext-tools/tests/testlocale diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 5312b6b5b..244b1c42e 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -23,8 +23,8 @@ MOSTLYCLEANFILES = core *.stackdump TESTS = gettext-1 gettext-2 \ intl-1 intl-2 intl-3 intl-4 \ intl-setlocale-1 intl-setlocale-2 \ - intl-thread-1 \ - gettext-6 gettext-7 gettext-8 \ + intl-thread-1 intl-thread-2 \ + gettext-7 gettext-8 \ msgattrib-1 msgattrib-2 msgattrib-3 msgattrib-4 msgattrib-5 \ msgattrib-6 msgattrib-7 msgattrib-8 msgattrib-9 msgattrib-10 \ msgattrib-11 msgattrib-12 msgattrib-13 msgattrib-14 msgattrib-15 \ @@ -166,8 +166,8 @@ EXTRA_DIST += init.sh init.cfg $(TESTS) \ qttest2_de.po qttest2_de.qm qttest2_de.ts \ intl-1.po intl-2-1.po intl-2-2.po intl-4.po \ intl-setlocale-1-1.po intl-setlocale-1-2.po intl-setlocale-2.po \ - intl-thread-1.po \ - gettext-6-1.po gettext-6-2.po gettext-7.po \ + intl-thread-1.po intl-thread-2-1.po intl-thread-2-2.po \ + gettext-7.po \ gettextpo-1.de.po \ xgettext-1 \ xgettext-c-1 xg-c-21.c \ @@ -224,7 +224,7 @@ DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ LDADD = $(LDADD_@USE_INCLUDED_LIBINTL@) @INTL_MACOSX_LIBS@ LDADD_yes = ../intl/libintl.la @LTLIBTHREAD@ LDADD_no = ../intl/libgnuintl.la @LTLIBTHREAD@ @LTLIBINTL@ -check_PROGRAMS = tstgettext tstngettext testlocale intl-1-prg intl-3-prg intl-4-prg intl-setlocale-1-prg intl-setlocale-2-prg intl-thread-1-prg gettext-6-prg gettext-7-prg gettext-8-prg cake fc3 fc4 fc5 gettextpo-1-prg sentence-1-prg +check_PROGRAMS = tstgettext tstngettext testlocale intl-1-prg intl-3-prg intl-4-prg intl-setlocale-1-prg intl-setlocale-2-prg intl-thread-1-prg intl-thread-2-prg gettext-7-prg gettext-8-prg cake fc3 fc4 fc5 gettextpo-1-prg sentence-1-prg tstgettext_SOURCES = tstgettext.c setlocale.c tstgettext_CFLAGS = -DINSTALLDIR=\".\" tstgettext_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD) @@ -247,11 +247,11 @@ intl_thread_1_prg_CFLAGS = $(intl_thread_1_prg_CFLAGS_@HAVE_NEWLOCALE@) intl_thread_1_prg_CFLAGS_1 = -DUSE_POSIX_THREADS intl_thread_1_prg_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD) $(intl_thread_1_prg_LDADD_@HAVE_NEWLOCALE@) intl_thread_1_prg_LDADD_1 = -lpthread -gettext_6_prg_SOURCES = gettext-6-prg.c -gettext_6_prg_CFLAGS = $(gettext_6_prg_CFLAGS_@HAVE_NEWLOCALE@) -gettext_6_prg_CFLAGS_1 = -DUSE_POSIX_THREADS -gettext_6_prg_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD) $(gettext_6_prg_LDADD_@HAVE_NEWLOCALE@) -gettext_6_prg_LDADD_1 = -lpthread +intl_thread_2_prg_SOURCES = intl-thread-2-prg.c +intl_thread_2_prg_CFLAGS = $(intl_thread_2_prg_CFLAGS_@HAVE_NEWLOCALE@) +intl_thread_2_prg_CFLAGS_1 = -DUSE_POSIX_THREADS +intl_thread_2_prg_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD) $(intl_thread_2_prg_LDADD_@HAVE_NEWLOCALE@) +intl_thread_2_prg_LDADD_1 = -lpthread gettext_7_prg_SOURCES = gettext-7-prg.c gettext_7_prg_CFLAGS = $(gettext_7_prg_CFLAGS_@HAVE_NEWLOCALE@) gettext_7_prg_CFLAGS_1 = -DUSE_POSIX_THREADS diff --git a/gettext-tools/tests/gettext-6 b/gettext-tools/tests/gettext-6 deleted file mode 100755 index cadfbc8f0..000000000 --- a/gettext-tools/tests/gettext-6 +++ /dev/null @@ -1,61 +0,0 @@ -#! /bin/sh -. "${srcdir=.}/init.sh"; path_prepend_ . ../src - -# Test that on glibc systems, gettext() in multithreaded applications works -# correctly if different threads operate in different locales with the same -# encoding. - -# This test works only on glibc and MacOS X systems. -: ${host_os=unknown} -: ${GLIBC2=no} -{ case "$host_os" in - *-gnu*) test "$GLIBC2" = yes ;; - darwin*) true ;; - *) false ;; - esac -} || { - echo "Skipping test: not a glibc or Mac OS X system" - Exit 77 -} - -# This test works only on systems that have a de_DE and fr_FR locale installed. -missing_locale=`../gettext-6-prg 1` -if test -n "$missing_locale"; then - if test -f /usr/bin/localedef; then - echo "Skipping test: locale ${missing_locale} not installed" - else - echo "Skipping test: locale ${missing_locale} not supported" - fi - Exit 77 -fi - -test -d gt-6 || mkdir gt-6 -test -d gt-6/de_DE || mkdir gt-6/de_DE -test -d gt-6/de_DE/LC_MESSAGES || mkdir gt-6/de_DE/LC_MESSAGES -test -d gt-6/fr_FR || mkdir gt-6/fr_FR -test -d gt-6/fr_FR/LC_MESSAGES || mkdir gt-6/fr_FR/LC_MESSAGES - -: ${MSGFMT=msgfmt} -${MSGFMT} -o gt-6/de_DE/LC_MESSAGES/tstthread.mo "$abs_srcdir"/gettext-6-1.po -${MSGFMT} -o gt-6/fr_FR/LC_MESSAGES/tstthread.mo "$abs_srcdir"/gettext-6-2.po - -cat < gt-6.ok -Schönheit -beauté -Schönheit -beauté -EOF - -../gettext-6-prg > gt-6.out -case $? in - 0) ;; - 77) - echo "Skipping test: not a glibc >= 2.3 or MacOS X >= 10.5 system" - Exit 77 - ;; -esac - -: ${DIFF=diff} -${DIFF} gt-6.ok gt-6.out || Exit 1 - -Exit 0 diff --git a/gettext-tools/tests/intl-thread-2 b/gettext-tools/tests/intl-thread-2 new file mode 100755 index 000000000..2edebfe1e --- /dev/null +++ b/gettext-tools/tests/intl-thread-2 @@ -0,0 +1,56 @@ +#! /bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test that gettext() in multithreaded applications works correctly if +# different threads operate in different locales with the same encoding. + +# Let's use two UTF-8 locales that configure already checked for: +# French and Turkish. +# The second PO file is actually German, not Turkish, but that doesn't matter. + +test -d in-th-2 || mkdir in-th-2 +test -d in-th-2/fr_FR || mkdir in-th-2/fr_FR +test -d in-th-2/fr_FR/LC_MESSAGES || mkdir in-th-2/fr_FR/LC_MESSAGES +test -d in-th-2/tr_TR || mkdir in-th-2/tr_TR +test -d in-th-2/tr_TR/LC_MESSAGES || mkdir in-th-2/tr_TR/LC_MESSAGES + +: ${MSGFMT=msgfmt} +${MSGFMT} -o in-th-2/fr_FR/LC_MESSAGES/tstthread.mo "$abs_srcdir"/intl-thread-2-1.po +${MSGFMT} -o in-th-2/tr_TR/LC_MESSAGES/tstthread.mo "$abs_srcdir"/intl-thread-2-2.po + +: ${DIFF=diff} +cat < in-th-2.ok +beauté +Schönheit +beauté +Schönheit +EOF + +: ${LOCALE_FR_UTF8=fr_FR.UTF-8} +: ${LOCALE_TR_UTF8=tr_TR.UTF-8} +if test $LOCALE_FR_UTF8 != none && test $LOCALE_TR_UTF8 != none; then + prepare_locale_ fr $LOCALE_FR_UTF8 + prepare_locale_ tr $LOCALE_TR_UTF8 + ../intl-thread-2-prg $LOCALE_FR_UTF8 $LOCALE_TR_UTF8 > in-th-2.out + case $? in + 0) + ${DIFF} in-th-2.ok in-th-2.out || Exit 1 + ;; + 77) + echo "Skipping test: POSIX per-thread locales not supported" + Exit 77 + ;; + *) + Exit 1 + ;; + esac +else + if test -f /usr/bin/localedef; then + echo "Skipping test: no french and turkish locales are installed" + else + echo "Skipping test: no french and turkish locales are supported" + fi + Exit 77 +fi + +Exit 0 diff --git a/gettext-tools/tests/gettext-6-2.po b/gettext-tools/tests/intl-thread-2-1.po similarity index 59% rename from gettext-tools/tests/gettext-6-2.po rename to gettext-tools/tests/intl-thread-2-1.po index 8332c2d9f..5b7c03dd3 100644 --- a/gettext-tools/tests/gettext-6-2.po +++ b/gettext-tools/tests/intl-thread-2-1.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8-bit\n" msgid "beauty" -msgstr "beauté" +msgstr "beauté" diff --git a/gettext-tools/tests/gettext-6-1.po b/gettext-tools/tests/intl-thread-2-2.po similarity index 58% rename from gettext-tools/tests/gettext-6-1.po rename to gettext-tools/tests/intl-thread-2-2.po index 0a8d09939..eb748aa1a 100644 --- a/gettext-tools/tests/gettext-6-1.po +++ b/gettext-tools/tests/intl-thread-2-2.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8-bit\n" msgid "beauty" -msgstr "Schönheit" +msgstr "Schönheit" diff --git a/gettext-tools/tests/gettext-6-prg.c b/gettext-tools/tests/intl-thread-2-prg.c similarity index 68% rename from gettext-tools/tests/gettext-6-prg.c rename to gettext-tools/tests/intl-thread-2-prg.c index ee155b93a..49c3c20d8 100644 --- a/gettext-tools/tests/gettext-6-prg.c +++ b/gettext-tools/tests/intl-thread-2-prg.c @@ -1,5 +1,5 @@ -/* Test program, used by the gettext-6 test. - Copyright (C) 2005-2007, 2009-2010, 2015-2016 Free Software Foundation, Inc. +/* Test program, used by the intl-thread-2 test. + Copyright (C) 2005-2007, 2009-2010, 2015-2016, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ #include #include -#if USE_POSIX_THREADS && ((__GLIBC__ >= 2 && !defined __UCLIBC__) || (defined __APPLE__ && defined __MACH__)) && HAVE_USELOCALE +#if USE_POSIX_THREADS && HAVE_USELOCALE #include @@ -33,17 +33,10 @@ #undef _LIBINTL_H #include "libgnuintl.h" -/* Name of German and French locale in ISO-8859-1 or ISO-8859-15 encoding. */ -#if __GLIBC__ >= 2 -# define LOCALE_DE_ISO8859 "de_DE.ISO-8859-1" -# define LOCALE_FR_ISO8859 "fr_FR.ISO-8859-1" -#elif defined __APPLE__ && defined __MACH__ /* MacOS X */ -# define LOCALE_DE_ISO8859 "de_DE.ISO8859-1" -# define LOCALE_FR_ISO8859 "fr_FR.ISO8859-1" -#else -# define LOCALE_DE_ISO8859 "de_DE" -# define LOCALE_FR_ISO8859 "fr_FR" -#endif +/* Name of locale to use in thread1. */ +const char *locale_name_1; +/* Name of locale to use in thread2. */ +const char *locale_name_2; /* Set to 1 if the program is not behaving correctly. */ int result; @@ -84,13 +77,13 @@ thread1_execution (void *arg) char *s; waitfor (1); - uselocale (newlocale (LC_ALL_MASK, LOCALE_DE_ISO8859, NULL)); + uselocale (newlocale (LC_ALL_MASK, locale_name_1, NULL)); setto (2); waitfor (1); s = gettext ("beauty"); puts (s); - if (strcmp (s, "Sch\366nheit")) + if (strcmp (s, "beaut\303\251")) { fprintf (stderr, "thread 1 call 1 returned: %s\n", s); result = 1; @@ -100,7 +93,7 @@ thread1_execution (void *arg) waitfor (1); s = gettext ("beauty"); puts (s); - if (strcmp (s, "Sch\366nheit")) + if (strcmp (s, "beaut\303\251")) { fprintf (stderr, "thread 1 call 2 returned: %s\n", s); result = 1; @@ -116,13 +109,13 @@ thread2_execution (void *arg) char *s; waitfor (2); - uselocale (newlocale (LC_ALL_MASK, LOCALE_FR_ISO8859, NULL)); + uselocale (newlocale (LC_ALL_MASK, locale_name_2, NULL)); setto (1); waitfor (2); s = gettext ("beauty"); puts (s); - if (strcmp (s, "beaut\351")) + if (strcmp (s, "Sch\303\266nheit")) { fprintf (stderr, "thread 2 call 1 returned: %s\n", s); result = 1; @@ -132,7 +125,7 @@ thread2_execution (void *arg) waitfor (2); s = gettext ("beauty"); puts (s); - if (strcmp (s, "beaut\351")) + if (strcmp (s, "Sch\303\266nheit")) { fprintf (stderr, "thread 2 call 2 returned: %s\n", s); result = 1; @@ -142,40 +135,19 @@ thread2_execution (void *arg) return NULL; } -static void -check_locale_exists (const char *name) -{ - if (newlocale (LC_ALL_MASK, name, NULL) == NULL) - { - printf ("%s\n", name); - exit (1); - } -} - int main (int argc, char *argv[]) { - int arg; pthread_t thread1; pthread_t thread2; - arg = (argc > 1 ? atoi (argv[1]) : 0); - switch (arg) - { - case 1: - /* Check for the existence of the first locale. */ - check_locale_exists (LOCALE_DE_ISO8859); - /* Check for the existence of the second locale. */ - check_locale_exists (LOCALE_FR_ISO8859); - return 0; - default: - break; - } + locale_name_1 = argv[1]; + locale_name_2 = argv[2]; unsetenv ("LANGUAGE"); unsetenv ("OUTPUT_CHARSET"); textdomain ("tstthread"); - bindtextdomain ("tstthread", "gt-6"); + bindtextdomain ("tstthread", "in-th-2"); result = 0; flipflop = 1;