From: Bruno Haible Date: Sun, 21 Oct 2018 08:35:25 +0000 (+0200) Subject: New subdirectory system-tests. X-Git-Tag: v0.20~312 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f63a9cfa3299cd4d6ff70b950946458abf54b2db;p=thirdparty%2Fgettext.git New subdirectory system-tests. * gettext-tools/system-tests/Makefile.am: New file. * gettext-tools/system-tests/README: New file. * gettext-tools/system-tests/run-test: New file. * gettext-tools/system-tests/testlocale.c: New file. * gettext-tools/system-tests/intl-1-prg.c: New file. * gettext-tools/system-tests/intl-3-prg.c: New file. * gettext-tools/system-tests/intl-4-prg.c: New file. * gettext-tools/system-tests/intl-5-prg.c: New file. * gettext-tools/system-tests/intl-setlocale-1-prg.c: New file. * gettext-tools/system-tests/intl-setlocale-2-prg.c: New file. * gettext-tools/system-tests/intl-thread-1-prg.c: New file. * gettext-tools/system-tests/intl-thread-2-prg.c: New file. * gettext-tools/system-tests/intl-thread-3-prg.c: New file. * gettext-tools/system-tests/format-c-3-prg.c: New file. * gettext-tools/system-tests/format-c-4-prg.c: New file. * gettext-tools/system-tests/format-c-5-prg.c: New file. * gettext-tools/system-tests/plural-1-prg.c: New file. * gettext-tools/Makefile.am (SUBDIRS): Add system-tests. * gettext-tools/configure.ac (TEST_SYSTEM_LIBINTL): New conditional. (AC_CONFIG_FILES): Add system-tests/Makefile. * gettext-tools/tests/init.cfg: Include init-env from the tests/ directory. * gettext-tools/tests/intl-5-prg.c: When USE_SYSTEM_LIBINTL is defined, use the system's . * gettext-tools/tests/intl-setlocale-1-prg.c: Likewise. * gettext-tools/tests/intl-setlocale-2-prg.c: Likewise. * gettext-tools/tests/intl-thread-1-prg.c: Likewise. * gettext-tools/tests/intl-thread-2-prg.c: Likewise. * gettext-tools/tests/intl-thread-3-prg.c: Likewise. * gettext-tools/tests/intl-1-prg.c: When USE_SYSTEM_LIBINTL is defined, use the system's . * gettext-tools/tests/intl-3-prg.c: Likewise. * gettext-tools/tests/intl-4-prg.c: Likewise. * gettext-tools/tests/format-c-3-prg.c: Likewise. * gettext-tools/tests/format-c-4-prg.c: Likewise. * gettext-tools/tests/plural-1-prg.c: Likewise. * gettext-tools/tests/format-c-5-prg.c: When USE_SYSTEM_LIBINTL is defined, use the system's and setenv instead of xsetenv, and no fake setlocale. * gettext-tools/tests/format-c-3: When USE_SYSTEM_LIBINTL is defined, try $LOCALE_FR and $LOCALE_FR_UTF8. * gettext-tools/tests/format-c-4: Likewise. * gettext-tools/tests/plural-1: Likewise. * gettext-tools/tests/format-c-5: When USE_SYSTEM_LIBINTL is defined, try fa_IR and fa_IR.UTF-8. --- diff --git a/.gitignore b/.gitignore index 2c796d4e3..24772d8a2 100644 --- a/.gitignore +++ b/.gitignore @@ -351,6 +351,7 @@ /gettext-tools/projects/Makefile.in /gettext-tools/src/Makefile.in /gettext-tools/styles/Makefile.in +/gettext-tools/system-tests/Makefile.in /gettext-tools/tests/Makefile.in /gnulib-local/Makefile.in @@ -553,6 +554,7 @@ autom4te.cache/ /gettext-tools/src/Makefile /gettext-tools/src/user-email /gettext-tools/styles/Makefile +/gettext-tools/system-tests/Makefile /gettext-tools/tests/Makefile /gettext-tools/tests/init-env /gnulib-local/Makefile @@ -651,6 +653,34 @@ autom4te.cache/ /gettext-tools/src/gnu.gettext.DumpResource.exe /gettext-tools/src/gnu.gettext.GetURL /gettext-tools/src/gnu.gettext.GetURL.exe +/gettext-tools/system-tests/cake +/gettext-tools/system-tests/cake.exe +/gettext-tools/system-tests/fc3 +/gettext-tools/system-tests/fc3.exe +/gettext-tools/system-tests/fc4 +/gettext-tools/system-tests/fc4.exe +/gettext-tools/system-tests/fc5 +/gettext-tools/system-tests/fc5.exe +/gettext-tools/system-tests/intl-1-prg +/gettext-tools/system-tests/intl-1-prg.exe +/gettext-tools/system-tests/intl-3-prg +/gettext-tools/system-tests/intl-3-prg.exe +/gettext-tools/system-tests/intl-4-prg +/gettext-tools/system-tests/intl-4-prg.exe +/gettext-tools/system-tests/intl-5-prg +/gettext-tools/system-tests/intl-5-prg.exe +/gettext-tools/system-tests/intl-setlocale-1-prg +/gettext-tools/system-tests/intl-setlocale-1-prg.exe +/gettext-tools/system-tests/intl-setlocale-2-prg +/gettext-tools/system-tests/intl-setlocale-2-prg.exe +/gettext-tools/system-tests/intl-thread-1-prg +/gettext-tools/system-tests/intl-thread-1-prg.exe +/gettext-tools/system-tests/intl-thread-2-prg +/gettext-tools/system-tests/intl-thread-2-prg.exe +/gettext-tools/system-tests/intl-thread-3-prg +/gettext-tools/system-tests/intl-thread-3-prg.exe +/gettext-tools/system-tests/testlocale +/gettext-tools/system-tests/testlocale.exe /gettext-tools/tests/cake /gettext-tools/tests/cake.exe /gettext-tools/tests/fc3 @@ -706,6 +736,8 @@ core # Logs generated by Automake: /gettext-runtime/tests/*.log /gettext-runtime/tests/*.trs +/gettext-tools/system-tests/*.log +/gettext-tools/system-tests/*.trs /gettext-tools/tests/*.log /gettext-tools/tests/*.trs # Other. diff --git a/gettext-tools/Makefile.am b/gettext-tools/Makefile.am index 5dfa3362a..4f3e73f68 100644 --- a/gettext-tools/Makefile.am +++ b/gettext-tools/Makefile.am @@ -19,7 +19,7 @@ AUTOMAKE_OPTIONS = 1.5 gnu no-dependencies ACLOCAL_AMFLAGS = -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4 -SUBDIRS = doc intl gnulib-lib libgrep src libgettextpo po projects styles misc man m4 tests gnulib-tests examples its +SUBDIRS = doc intl gnulib-lib libgrep src libgettextpo po projects styles misc man m4 tests system-tests gnulib-tests examples its EXTRA_DIST = misc/DISCLAIM MOSTLYCLEANFILES = core *.stackdump diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac index 62a23dcff..b366f3dbf 100644 --- a/gettext-tools/configure.ac +++ b/gettext-tools/configure.ac @@ -488,6 +488,10 @@ if test "$CXX" = no; then fi AC_SUBST([TESTLIBASPRINTF]) +dnl Check whether to execute tests of the system (vendor-provided) libintl API. +dnl We execute these tests if and only if we don't install our own libintl. +AM_CONDITIONAL([TEST_SYSTEM_LIBINTL], [test $USE_INCLUDED_LIBINTL = no]) + dnl Generate the version information file in the intl/ directory. test -d intl || mkdir intl echo "GNU gettext library from gettext-$VERSION" > intl/VERSION @@ -538,9 +542,10 @@ AC_CONFIG_FILES([man/x-to-1]) AC_CONFIG_FILES([m4/Makefile]) AC_CONFIG_FILES([tests/Makefile]) - AC_CONFIG_FILES([tests/init-env]) +AC_CONFIG_FILES([system-tests/Makefile]) + AC_CONFIG_FILES([gnulib-tests/Makefile]) AC_OUTPUT diff --git a/gettext-tools/system-tests/Makefile.am b/gettext-tools/system-tests/Makefile.am new file mode 100644 index 000000000..4c15ec234 --- /dev/null +++ b/gettext-tools/system-tests/Makefile.am @@ -0,0 +1,105 @@ +## Makefile for the gettext-tools/system-tests subdirectory of GNU gettext +## Copyright (C) 1995-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 +## the Free Software Foundation; either version 3 of the License, or +## (at your option) any later version. +## +## This program 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 General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . + +## Process this file with automake to produce Makefile.in. + +AUTOMAKE_OPTIONS = 1.11 gnits no-dependencies color-tests +EXTRA_DIST = +MOSTLYCLEANFILES = core *.stackdump + +EXTRA_DIST += README run-test + +# For debugging memory leaks and memory allocation bugs. +# You should build with --disable-shared when using valgrind. +CHECKER = +#CHECKER = valgrind --tool=memcheck --num-callers=20 --leak-check=yes --leak-resolution=high --show-reachable=yes +#CHECKER = valgrind --tool=massif --format=html --depth=10 --stacks=no + +TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) \ + abs_srcdir=$(abs_srcdir) \ + abs_top_srcdir=$(abs_top_srcdir) \ + GETTEXT="$(CHECKER) tstgettext" \ + NGETTEXT="$(CHECKER) tstngettext" \ + XGETTEXT="$(CHECKER) xgettext" \ + MSGATTRIB="$(CHECKER) msgattrib" \ + MSGCAT="$(CHECKER) msgcat" \ + MSGCMP="$(CHECKER) msgcmp" \ + MSGCOMM="$(CHECKER) msgcomm" \ + MSGCONV="$(CHECKER) msgconv" \ + MSGEN="$(CHECKER) msgen" \ + MSGEXEC="$(CHECKER) msgexec" \ + MSGFILTER="$(CHECKER) msgfilter" \ + MSGFMT="$(CHECKER) msgfmt" \ + MSGGREP="$(CHECKER) msggrep" \ + MSGINIT="$(CHECKER) msginit" \ + MSGMERGE="$(CHECKER) msgmerge" \ + MSGUNFMT="$(CHECKER) msgunfmt" \ + MSGUNIQ="$(CHECKER) msguniq" \ + RECODE="$(CHECKER) recode" \ + CONFIG_SHELL='$(SHELL)' + +LOG_COMPILER = $(SHELL) $(srcdir)/run-test + +# It is important that the gnulib-generated *.h files are not visible here, +# except for config.h. +AM_CPPFLAGS = -I.. + +# The USE_SYSTEM_LIBINTL flag distinguishes a compilation in the system-tests/ +# directory from a compilation in the tests/ directory. +DEFS = -DUSE_SYSTEM_LIBINTL @DEFS@ + +if TEST_SYSTEM_LIBINTL + +TESTS = intl-1 intl-2 intl-3 intl-4 intl-5 \ + intl-setlocale-1 intl-setlocale-2 \ + intl-thread-1 intl-thread-2 intl-thread-3 \ + format-c-3 format-c-4 format-c-5 plural-1 +.PHONY: $(TESTS) + +# Auxiliary programs used by the tests. +check_PROGRAMS = testlocale intl-1-prg intl-3-prg intl-4-prg intl-5-prg intl-setlocale-1-prg intl-setlocale-2-prg intl-thread-1-prg intl-thread-2-prg intl-thread-3-prg cake fc3 fc4 fc5 +testlocale_SOURCES = testlocale.c +intl_1_prg_SOURCES = intl-1-prg.c +intl_3_prg_SOURCES = intl-3-prg.c +intl_4_prg_SOURCES = intl-4-prg.c +intl_5_prg_SOURCES = intl-5-prg.c +intl_setlocale_1_prg_SOURCES = intl-setlocale-1-prg.c +intl_setlocale_2_prg_SOURCES = intl-setlocale-2-prg.c +intl_thread_1_prg_SOURCES = intl-thread-1-prg.c +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 = $(LDADD) $(intl_thread_1_prg_LDADD_@HAVE_NEWLOCALE@) +intl_thread_1_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 = $(LDADD) $(intl_thread_2_prg_LDADD_@HAVE_NEWLOCALE@) +intl_thread_2_prg_LDADD_1 = -lpthread +intl_thread_3_prg_SOURCES = intl-thread-3-prg.c +intl_thread_3_prg_CFLAGS = $(intl_thread_3_prg_CFLAGS_@HAVE_NEWLOCALE@) +intl_thread_3_prg_CFLAGS_1 = -DUSE_POSIX_THREADS +intl_thread_3_prg_LDADD = $(LDADD) $(intl_thread_3_prg_LDADD_@HAVE_NEWLOCALE@) +intl_thread_3_prg_LDADD_1 = -lpthread +cake_SOURCES = plural-1-prg.c +fc3_SOURCES = format-c-3-prg.c +fc4_SOURCES = format-c-4-prg.c +fc5_SOURCES = format-c-5-prg.c + +endif + +# Clean up after Solaris cc. +clean-local: + rm -rf SunWS_cache diff --git a/gettext-tools/system-tests/README b/gettext-tools/system-tests/README new file mode 100644 index 000000000..c26faaa51 --- /dev/null +++ b/gettext-tools/system-tests/README @@ -0,0 +1,5 @@ +This directory contains tests of the system (vendor-provided) libintl +or libc. + +Whereas the gettext-runtime/intl/ directory is tested as part of +gettext-tools/tests/. diff --git a/gettext-tools/system-tests/format-c-3-prg.c b/gettext-tools/system-tests/format-c-3-prg.c new file mode 100644 index 000000000..681d73936 --- /dev/null +++ b/gettext-tools/system-tests/format-c-3-prg.c @@ -0,0 +1 @@ +#include "../tests/format-c-3-prg.c" diff --git a/gettext-tools/system-tests/format-c-4-prg.c b/gettext-tools/system-tests/format-c-4-prg.c new file mode 100644 index 000000000..b2e7d784d --- /dev/null +++ b/gettext-tools/system-tests/format-c-4-prg.c @@ -0,0 +1 @@ +#include "../tests/format-c-4-prg.c" diff --git a/gettext-tools/system-tests/format-c-5-prg.c b/gettext-tools/system-tests/format-c-5-prg.c new file mode 100644 index 000000000..e7c3ff3ee --- /dev/null +++ b/gettext-tools/system-tests/format-c-5-prg.c @@ -0,0 +1 @@ +#include "../tests/format-c-5-prg.c" diff --git a/gettext-tools/system-tests/intl-1-prg.c b/gettext-tools/system-tests/intl-1-prg.c new file mode 100644 index 000000000..4c599c441 --- /dev/null +++ b/gettext-tools/system-tests/intl-1-prg.c @@ -0,0 +1 @@ +#include "../tests/intl-1-prg.c" diff --git a/gettext-tools/system-tests/intl-3-prg.c b/gettext-tools/system-tests/intl-3-prg.c new file mode 100644 index 000000000..db8d7f809 --- /dev/null +++ b/gettext-tools/system-tests/intl-3-prg.c @@ -0,0 +1 @@ +#include "../tests/intl-3-prg.c" diff --git a/gettext-tools/system-tests/intl-4-prg.c b/gettext-tools/system-tests/intl-4-prg.c new file mode 100644 index 000000000..b2110a59d --- /dev/null +++ b/gettext-tools/system-tests/intl-4-prg.c @@ -0,0 +1 @@ +#include "../tests/intl-4-prg.c" diff --git a/gettext-tools/system-tests/intl-5-prg.c b/gettext-tools/system-tests/intl-5-prg.c new file mode 100644 index 000000000..545d62711 --- /dev/null +++ b/gettext-tools/system-tests/intl-5-prg.c @@ -0,0 +1 @@ +#include "../tests/intl-5-prg.c" diff --git a/gettext-tools/system-tests/intl-setlocale-1-prg.c b/gettext-tools/system-tests/intl-setlocale-1-prg.c new file mode 100644 index 000000000..43400e30d --- /dev/null +++ b/gettext-tools/system-tests/intl-setlocale-1-prg.c @@ -0,0 +1 @@ +#include "../tests/intl-setlocale-1-prg.c" diff --git a/gettext-tools/system-tests/intl-setlocale-2-prg.c b/gettext-tools/system-tests/intl-setlocale-2-prg.c new file mode 100644 index 000000000..e1250da73 --- /dev/null +++ b/gettext-tools/system-tests/intl-setlocale-2-prg.c @@ -0,0 +1 @@ +#include "../tests/intl-setlocale-2-prg.c" diff --git a/gettext-tools/system-tests/intl-thread-1-prg.c b/gettext-tools/system-tests/intl-thread-1-prg.c new file mode 100644 index 000000000..f44c7d796 --- /dev/null +++ b/gettext-tools/system-tests/intl-thread-1-prg.c @@ -0,0 +1 @@ +#include "../tests/intl-thread-1-prg.c" diff --git a/gettext-tools/system-tests/intl-thread-2-prg.c b/gettext-tools/system-tests/intl-thread-2-prg.c new file mode 100644 index 000000000..8b6e8ee14 --- /dev/null +++ b/gettext-tools/system-tests/intl-thread-2-prg.c @@ -0,0 +1 @@ +#include "../tests/intl-thread-2-prg.c" diff --git a/gettext-tools/system-tests/intl-thread-3-prg.c b/gettext-tools/system-tests/intl-thread-3-prg.c new file mode 100644 index 000000000..30eb56cce --- /dev/null +++ b/gettext-tools/system-tests/intl-thread-3-prg.c @@ -0,0 +1 @@ +#include "../tests/intl-thread-3-prg.c" diff --git a/gettext-tools/system-tests/plural-1-prg.c b/gettext-tools/system-tests/plural-1-prg.c new file mode 100644 index 000000000..8a8f2fcfd --- /dev/null +++ b/gettext-tools/system-tests/plural-1-prg.c @@ -0,0 +1 @@ +#include "../tests/plural-1-prg.c" diff --git a/gettext-tools/system-tests/run-test b/gettext-tools/system-tests/run-test new file mode 100755 index 000000000..1431271be --- /dev/null +++ b/gettext-tools/system-tests/run-test @@ -0,0 +1,12 @@ +#!/bin/sh +# Run a test whose source and data files are located in the ../tests/ directory. + +srcdir="$srcdir/../tests" +abs_srcdir="$abs_srcdir/../tests" +USE_SYSTEM_LIBINTL=yes +export srcdir abs_srcdir USE_SYSTEM_LIBINTL + +testname=`echo "$1" | sed 's,^.*/,,'` +shift + +exec /bin/sh "$srcdir/$testname" "$@" diff --git a/gettext-tools/system-tests/testlocale.c b/gettext-tools/system-tests/testlocale.c new file mode 100644 index 000000000..8446a9326 --- /dev/null +++ b/gettext-tools/system-tests/testlocale.c @@ -0,0 +1 @@ +#include "../tests/testlocale.c" diff --git a/gettext-tools/tests/format-c-3 b/gettext-tools/tests/format-c-3 index 0509e1fce..de59476ab 100755 --- a/gettext-tools/tests/format-c-3 +++ b/gettext-tools/tests/format-c-3 @@ -23,20 +23,47 @@ msgstr "Vater von % Kindern" EOF test -d fc3-dir || mkdir fc3-dir -test -d fc3-dir/de || mkdir fc3-dir/de -test -d fc3-dir/de/LC_MESSAGES || mkdir fc3-dir/de/LC_MESSAGES +test -d fc3-dir/fr || mkdir fc3-dir/fr +test -d fc3-dir/fr/LC_MESSAGES || mkdir fc3-dir/fr/LC_MESSAGES : ${MSGFMT=msgfmt} -${MSGFMT} -o fc3-dir/de/LC_MESSAGES/fc3.mo fc3-de.po +${MSGFMT} -o fc3-dir/fr/LC_MESSAGES/fc3.mo fc3-de.po : ${MSGUNFMT=msgunfmt} -${MSGUNFMT} -o fc3-de.po.tmp fc3-dir/de/LC_MESSAGES/fc3.mo || Exit 1 +${MSGUNFMT} -o fc3-de.po.tmp fc3-dir/fr/LC_MESSAGES/fc3.mo || Exit 1 LC_ALL=C tr -d '\r' < fc3-de.po.tmp > fc3-de.po.un || Exit 1 : ${DIFF=diff} ${DIFF} fc3-de.po fc3-de.po.un || Exit 1 -LANGUAGE= ../fc3 de_DE -result=$? +if test -z "$USE_SYSTEM_LIBINTL"; then + # In the tests/ dir: Rely on a fake setlocale, so that we can exercise + # the test on all platforms. -exit $result + LANGUAGE= ../fc3 fr_FR || Exit 1 + +else + # In the system-tests/ dir: Don't use a fake setlocale. + + : ${LOCALE_FR=fr_FR} + : ${LOCALE_FR_UTF8=fr_FR.UTF-8} + if test $LOCALE_FR != none; then + prepare_locale_ fc3-dir/fr fc3-dir/$LOCALE_FR + LANGUAGE= ../fc3 $LOCALE_FR || Exit 1 + fi + if test $LOCALE_FR_UTF8 != none; then + prepare_locale_ fc3-dir/fr fc3-dir/$LOCALE_FR_UTF8 + LANGUAGE= ../fc3 $LOCALE_FR_UTF8 || Exit 1 + fi + if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french locale is installed" + else + echo "Skipping test: no french locale is supported" + fi + Exit 77 + fi + +fi + +Exit 0 diff --git a/gettext-tools/tests/format-c-3-prg.c b/gettext-tools/tests/format-c-3-prg.c index 7bee685f9..813dd154a 100644 --- a/gettext-tools/tests/format-c-3-prg.c +++ b/gettext-tools/tests/format-c-3-prg.c @@ -25,11 +25,16 @@ #ifdef HAVE_INTTYPES_H # include #endif -#include "xsetenv.h" +#if USE_SYSTEM_LIBINTL +# define xsetenv setenv +# include +#else +# include "xsetenv.h" /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif /* Disable the override of setlocale that libgnuintl.h activates on MacOS X and Windows. This test relies on the fake setlocale function in diff --git a/gettext-tools/tests/format-c-4 b/gettext-tools/tests/format-c-4 index 3ab9ddcb8..6f76eb6ae 100755 --- a/gettext-tools/tests/format-c-4 +++ b/gettext-tools/tests/format-c-4 @@ -27,20 +27,47 @@ msgstr[1] "Vater von % Kindern" EOF test -d fc4-dir || mkdir fc4-dir -test -d fc4-dir/de || mkdir fc4-dir/de -test -d fc4-dir/de/LC_MESSAGES || mkdir fc4-dir/de/LC_MESSAGES +test -d fc4-dir/fr || mkdir fc4-dir/fr +test -d fc4-dir/fr/LC_MESSAGES || mkdir fc4-dir/fr/LC_MESSAGES : ${MSGFMT=msgfmt} -${MSGFMT} -o fc4-dir/de/LC_MESSAGES/fc4.mo fc4-de.po +${MSGFMT} -o fc4-dir/fr/LC_MESSAGES/fc4.mo fc4-de.po : ${MSGUNFMT=msgunfmt} -${MSGUNFMT} -o fc4-de.po.tmp fc4-dir/de/LC_MESSAGES/fc4.mo || Exit 1 +${MSGUNFMT} -o fc4-de.po.tmp fc4-dir/fr/LC_MESSAGES/fc4.mo || Exit 1 LC_ALL=C tr -d '\r' < fc4-de.po.tmp > fc4-de.po.un || Exit 1 : ${DIFF=diff} ${DIFF} fc4-de.po fc4-de.po.un || Exit 1 -LANGUAGE= ../fc4 de_DE -result=$? +if test -z "$USE_SYSTEM_LIBINTL"; then + # In the tests/ dir: Rely on a fake setlocale, so that we can exercise + # the test on all platforms. -exit $result + LANGUAGE= ../fc4 fr_FR || Exit 1 + +else + # In the system-tests/ dir: Don't use a fake setlocale. + + : ${LOCALE_FR=fr_FR} + : ${LOCALE_FR_UTF8=fr_FR.UTF-8} + if test $LOCALE_FR != none; then + prepare_locale_ fc4-dir/fr fc4-dir/$LOCALE_FR + LANGUAGE= ../fc4 $LOCALE_FR || Exit 1 + fi + if test $LOCALE_FR_UTF8 != none; then + prepare_locale_ fc4-dir/fr fc4-dir/$LOCALE_FR_UTF8 + LANGUAGE= ../fc4 $LOCALE_FR_UTF8 || Exit 1 + fi + if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french locale is installed" + else + echo "Skipping test: no french locale is supported" + fi + Exit 77 + fi + +fi + +Exit 0 diff --git a/gettext-tools/tests/format-c-4-prg.c b/gettext-tools/tests/format-c-4-prg.c index b3e05bf2f..d405f9413 100644 --- a/gettext-tools/tests/format-c-4-prg.c +++ b/gettext-tools/tests/format-c-4-prg.c @@ -25,11 +25,16 @@ #ifdef HAVE_INTTYPES_H # include #endif -#include "xsetenv.h" +#if USE_SYSTEM_LIBINTL +# define xsetenv setenv +# include +#else +# include "xsetenv.h" /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif /* Disable the override of setlocale that libgnuintl.h activates on MacOS X and Windows. This test relies on the fake setlocale function in diff --git a/gettext-tools/tests/format-c-5 b/gettext-tools/tests/format-c-5 index 919296758..1528b17a4 100755 --- a/gettext-tools/tests/format-c-5 +++ b/gettext-tools/tests/format-c-5 @@ -36,17 +36,53 @@ LC_ALL=C tr -d '\r' < fa.po.tmp > fa.po.un || Exit 1 : ${DIFF=diff} ${DIFF} fa.po fa.po.un || Exit 1 -LANGUAGE= ../fc5 fa_IR -case $? in - 0) ;; - 77) +if test -z "$USE_SYSTEM_LIBINTL"; then + # In the tests/ dir: Rely on a fake setlocale, so that we can exercise + # the test on all platforms. + + LANGUAGE= ../fc5 fa_IR + case $? in + 0) ;; + 77) + if test -f /usr/bin/localedef; then + echo "Skipping test: locale fa_IR not installed" + else + echo "Skipping test: locale fa_IR not supported" + fi + Exit 77;; + *) Exit 1;; + esac + +else + # In the system-tests/ dir: Don't use a fake setlocale. + + skipped=true + + prepare_locale_ fa fa_IR + LANGUAGE= ../fc5 fa_IR + case $? in + 0) skipped=false ;; + 77) ;; + *) Exit 1;; + esac + + prepare_locale_ fa fa_IR.UTF-8 + LANGUAGE= ../fc5 fa_IR.UTF-8 + case $? in + 0) skipped=false ;; + 77) ;; + *) Exit 1;; + esac + + if $skipped; then if test -f /usr/bin/localedef; then - echo "Skipping test: locale fa_IR not installed" + echo "Skipping test: no Farsi locale is installed" else - echo "Skipping test: locale fa_IR not supported" + echo "Skipping test: no Farsi locale is supported" fi - Exit 77;; - *) Exit 1;; -esac + Exit 77 + fi + +fi Exit 0 diff --git a/gettext-tools/tests/format-c-5-prg.c b/gettext-tools/tests/format-c-5-prg.c index a453d6bab..bd0be6c28 100644 --- a/gettext-tools/tests/format-c-5-prg.c +++ b/gettext-tools/tests/format-c-5-prg.c @@ -22,16 +22,21 @@ #include #include #include -#include "xsetenv.h" /* For %Id to work, we need the real setlocale(), not the fake one. */ -#if !(__GLIBC__ >= 2 && !defined __UCLIBC__) +#if !USE_SYSTEM_LIBINTL && !(__GLIBC__ >= 2 && !defined __UCLIBC__) # include "setlocale.c" #endif +#if USE_SYSTEM_LIBINTL +# define xsetenv setenv +# include +#else +# include "xsetenv.h" /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif #define _(string) gettext (string) diff --git a/gettext-tools/tests/init.cfg b/gettext-tools/tests/init.cfg index 40ee41f38..cc981491b 100644 --- a/gettext-tools/tests/init.cfg +++ b/gettext-tools/tests/init.cfg @@ -1,5 +1,7 @@ -test -f "./init-env" \ - && . "./init-env" +# This file extends the init.sh (provided by gnulib). + +# Set environment variables for the tests. +. ../tests/init-env prepare_locale_ () { diff --git a/gettext-tools/tests/intl-1-prg.c b/gettext-tools/tests/intl-1-prg.c index fc0a89679..d31455aad 100644 --- a/gettext-tools/tests/intl-1-prg.c +++ b/gettext-tools/tests/intl-1-prg.c @@ -21,11 +21,16 @@ #include #include #include -#include "xsetenv.h" +#if USE_SYSTEM_LIBINTL +# define xsetenv setenv +# include +#else +# include "xsetenv.h" /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif int main (int argc, char *argv[]) diff --git a/gettext-tools/tests/intl-3-prg.c b/gettext-tools/tests/intl-3-prg.c index 19c760319..c3ad2a1a4 100644 --- a/gettext-tools/tests/intl-3-prg.c +++ b/gettext-tools/tests/intl-3-prg.c @@ -21,11 +21,16 @@ #include #include #include -#include "xsetenv.h" +#if USE_SYSTEM_LIBINTL +# define xsetenv setenv +# include +#else +# include "xsetenv.h" /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif int main (int argc, char *argv[]) diff --git a/gettext-tools/tests/intl-4-prg.c b/gettext-tools/tests/intl-4-prg.c index e351bd96b..df4c6fea8 100644 --- a/gettext-tools/tests/intl-4-prg.c +++ b/gettext-tools/tests/intl-4-prg.c @@ -25,11 +25,16 @@ #include #include #include -#include "xsetenv.h" +#if USE_SYSTEM_LIBINTL +# define xsetenv setenv +# include +#else +# include "xsetenv.h" /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif int main (int argc, char *argv[]) diff --git a/gettext-tools/tests/intl-5-prg.c b/gettext-tools/tests/intl-5-prg.c index 8c7c0b304..4794af934 100644 --- a/gettext-tools/tests/intl-5-prg.c +++ b/gettext-tools/tests/intl-5-prg.c @@ -31,9 +31,13 @@ # include #endif +#if USE_SYSTEM_LIBINTL +# include +#else /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif int main () diff --git a/gettext-tools/tests/intl-setlocale-1-prg.c b/gettext-tools/tests/intl-setlocale-1-prg.c index 0463d6c3c..6954099f3 100644 --- a/gettext-tools/tests/intl-setlocale-1-prg.c +++ b/gettext-tools/tests/intl-setlocale-1-prg.c @@ -25,9 +25,13 @@ #include #include +#if USE_SYSTEM_LIBINTL +# include +#else /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif #define N_(string) string diff --git a/gettext-tools/tests/intl-setlocale-2-prg.c b/gettext-tools/tests/intl-setlocale-2-prg.c index e1f9a70c6..93a1b1bff 100644 --- a/gettext-tools/tests/intl-setlocale-2-prg.c +++ b/gettext-tools/tests/intl-setlocale-2-prg.c @@ -25,9 +25,13 @@ #include #include +#if USE_SYSTEM_LIBINTL +# include +#else /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif int main (void) diff --git a/gettext-tools/tests/intl-thread-1-prg.c b/gettext-tools/tests/intl-thread-1-prg.c index 77d64266f..fca7163f0 100644 --- a/gettext-tools/tests/intl-thread-1-prg.c +++ b/gettext-tools/tests/intl-thread-1-prg.c @@ -29,9 +29,13 @@ #include +#if USE_SYSTEM_LIBINTL +# include +#else /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif /* Name of locale to use in thread1. */ const char *locale_name_1; diff --git a/gettext-tools/tests/intl-thread-2-prg.c b/gettext-tools/tests/intl-thread-2-prg.c index 49c3c20d8..5edcbe1c0 100644 --- a/gettext-tools/tests/intl-thread-2-prg.c +++ b/gettext-tools/tests/intl-thread-2-prg.c @@ -29,9 +29,13 @@ #include +#if USE_SYSTEM_LIBINTL +# include +#else /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif /* Name of locale to use in thread1. */ const char *locale_name_1; diff --git a/gettext-tools/tests/intl-thread-3-prg.c b/gettext-tools/tests/intl-thread-3-prg.c index c9ff0bfc7..3fbccbf7d 100644 --- a/gettext-tools/tests/intl-thread-3-prg.c +++ b/gettext-tools/tests/intl-thread-3-prg.c @@ -29,9 +29,13 @@ #include +#if USE_SYSTEM_LIBINTL +# include +#else /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif /* Name of locale to use in thread1. */ const char *locale_name_1; diff --git a/gettext-tools/tests/plural-1 b/gettext-tools/tests/plural-1 index 66dd10b76..f5040dc7a 100755 --- a/gettext-tools/tests/plural-1 +++ b/gettext-tools/tests/plural-1 @@ -48,18 +48,50 @@ sed 1,2d < plural-1-fr.po > plural-1-fr.po.strip : ${DIFF=diff} ${DIFF} plural-1-fr.po.strip plural-1-fr.po.un || Exit 1 -: ${DIFF=diff} -echo 'un morceau de gateau' > plural-1-cake.ok -LANGUAGE= ../cake fr 1 > plural-1-cake.tmp || Exit 1 -LC_ALL=C tr -d '\r' < plural-1-cake.tmp > cake.out || Exit 1 -${DIFF} plural-1-cake.ok cake.out || Exit 1 -echo '2 morceaux de gateau' > plural-1-cake.ok -LANGUAGE= ../cake fr 2 > plural-1-cake.tmp || Exit 1 -LC_ALL=C tr -d '\r' < plural-1-cake.tmp > cake.out || Exit 1 -${DIFF} plural-1-cake.ok cake.out || Exit 1 -echo '10 morceaux de gateau' > plural-1-cake.ok -LANGUAGE= ../cake fr 10 > plural-1-cake.tmp || Exit 1 -LC_ALL=C tr -d '\r' < plural-1-cake.tmp > cake.out || Exit 1 -${DIFF} plural-1-cake.ok cake.out || Exit 1 +func_do_test () +{ + echo 'un morceau de gateau' > plural-1-cake.ok + LANGUAGE= ../cake "$1" 1 > plural-1-cake.tmp || Exit 1 + LC_ALL=C tr -d '\r' < plural-1-cake.tmp > cake.out || Exit 1 + ${DIFF} plural-1-cake.ok cake.out || Exit 1 + echo '2 morceaux de gateau' > plural-1-cake.ok + LANGUAGE= ../cake "$1" 2 > plural-1-cake.tmp || Exit 1 + LC_ALL=C tr -d '\r' < plural-1-cake.tmp > cake.out || Exit 1 + ${DIFF} plural-1-cake.ok cake.out || Exit 1 + echo '10 morceaux de gateau' > plural-1-cake.ok + LANGUAGE= ../cake "$1" 10 > plural-1-cake.tmp || Exit 1 + LC_ALL=C tr -d '\r' < plural-1-cake.tmp > cake.out || Exit 1 + ${DIFF} plural-1-cake.ok cake.out || Exit 1 +} + +if test -z "$USE_SYSTEM_LIBINTL"; then + # In the tests/ dir: Rely on a fake setlocale, so that we can exercise + # the test on all platforms. + + func_do_test fr + +else + # In the system-tests/ dir: Don't use a fake setlocale. + + : ${LOCALE_FR=fr_FR} + : ${LOCALE_FR_UTF8=fr_FR.UTF-8} + if test $LOCALE_FR != none; then + prepare_locale_ plural-1-dir/fr plural-1-dir/$LOCALE_FR + func_do_test $LOCALE_FR + fi + if test $LOCALE_FR_UTF8 != none; then + prepare_locale_ plural-1-dir/fr plural-1-dir/$LOCALE_FR_UTF8 + func_do_test $LOCALE_FR_UTF8 + fi + if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no french locale is installed" + else + echo "Skipping test: no french locale is supported" + fi + Exit 77 + fi + +fi Exit 0 diff --git a/gettext-tools/tests/plural-1-prg.c b/gettext-tools/tests/plural-1-prg.c index 7abea8852..f2bbfee2f 100644 --- a/gettext-tools/tests/plural-1-prg.c +++ b/gettext-tools/tests/plural-1-prg.c @@ -21,11 +21,16 @@ #include #include #include -#include "xsetenv.h" +#if USE_SYSTEM_LIBINTL +# define xsetenv setenv +# include +#else +# include "xsetenv.h" /* Make sure we use the included libintl, not the system's one. */ -#undef _LIBINTL_H -#include "libgnuintl.h" +# undef _LIBINTL_H +# include "libgnuintl.h" +#endif /* Disable the override of setlocale that libgnuintl.h activates on MacOS X and Windows. This test relies on the fake setlocale function in