From: Bruno Haible Date: Thu, 19 Jun 2025 09:46:19 +0000 (+0200) Subject: gettext-runtime: Implement 'installcheck' target. X-Git-Tag: v0.26~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04f810d72742259c1c198d2505fe03fa330e9d7d;p=thirdparty%2Fgettext.git gettext-runtime: Implement 'installcheck' target. * gettext-runtime/install-tests/test-version.c: New file. * gettext-runtime/install-tests/test-api.c: New file. * gettext-runtime/install-tests/itest.pot: New file. * gettext-runtime/install-tests/locale/en_US/LC_MESSAGES/itest.mo: New file. * gettext-runtime/install-tests/Makefile.am: New file. * gettext-runtime/configure.ac (INSTALLED_LIBINTL, PATH_SEPARATOR, AUGMENT_SHLIBPATH): New variables. (AC_CONFIG_FILES): Add install-tests/Makefile. * gettext-runtime/Makefile.am (SUBDIRS): Add install-tests. --- diff --git a/gettext-runtime/Makefile.am b/gettext-runtime/Makefile.am index 542f8c490..86c0ea754 100644 --- a/gettext-runtime/Makefile.am +++ b/gettext-runtime/Makefile.am @@ -26,7 +26,7 @@ SUBDIR_libasprintf = libasprintf else SUBDIR_libasprintf = endif -SUBDIRS = doc intl intl-java intl-csharp intl-d intl-modula2 gnulib-lib $(SUBDIR_libasprintf) src po man m4 tests +SUBDIRS = doc intl intl-java intl-csharp intl-d intl-modula2 gnulib-lib $(SUBDIR_libasprintf) src po man m4 tests install-tests EXTRA_DIST = BUGS diff --git a/gettext-runtime/configure.ac b/gettext-runtime/configure.ac index 9d2b6060c..c4119f8cd 100644 --- a/gettext-runtime/configure.ac +++ b/gettext-runtime/configure.ac @@ -238,6 +238,26 @@ dnl Determine variables used by uninstalled-config.sh. ENABLE_SHARED="$enable_shared" AC_SUBST([ENABLE_SHARED]) +dnl Test for features used in install-tests. +dnl shlibpath_var and PATH_SEPARATOR are set by LT_INIT. +if test $USE_INCLUDED_LIBINTL = yes; then + INSTALLED_LIBINTL="-lintl $INTL_MACOSX_LIBS" +else + INSTALLED_LIBINTL= +fi +AC_SUBST([INSTALLED_LIBINTL]) +AC_SUBST([PATH_SEPARATOR]) +if test -n "${shlibpath_var}"; then + if test "${shlibpath_var}" = PATH; then + AUGMENT_SHLIBPATH="PATH='\$(bindir)'${PATH_SEPARATOR}\"\$\$PATH\";" + else + AUGMENT_SHLIBPATH="${shlibpath_var}='\$(libdir)':\"\$\$${shlibpath_var}\"; export ${shlibpath_var};" + fi +else + AUGMENT_SHLIBPATH= +fi +AC_SUBST([AUGMENT_SHLIBPATH]) + AC_CONFIG_SUBDIRS([intl]) AC_CONFIG_SUBDIRS([libasprintf]) @@ -271,4 +291,6 @@ AC_CONFIG_FILES([m4/Makefile]) AC_CONFIG_FILES([tests/Makefile]) +AC_CONFIG_FILES([install-tests/Makefile]) + AC_OUTPUT diff --git a/gettext-runtime/install-tests/Makefile.am b/gettext-runtime/install-tests/Makefile.am new file mode 100644 index 000000000..a05ddd419 --- /dev/null +++ b/gettext-runtime/install-tests/Makefile.am @@ -0,0 +1,40 @@ +## Makefile for gettext-runtime/install-tests. +## Copyright (C) 2025 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. + +installcheck-local: + $(CC) -I$(includedir) -L$(libdir) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o test-version $(srcdir)/test-version.c $(INSTALLED_LIBINTL) + @AUGMENT_SHLIBPATH@ ./test-version + rm -rf test-version test-version$(EXEEXT) + $(CC) -I$(includedir) -L$(libdir) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + -DSRCDIR=\"$(srcdir)/\" \ + $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o test-api $(srcdir)/test-api.c $(INSTALLED_LIBINTL) + @AUGMENT_SHLIBPATH@ ./test-api + rm -rf test-api test-api$(EXEEXT) + PATH='$(bindir)'@PATH_SEPARATOR@"$$PATH"; gettext --version | grep 'GNU gettext' > /dev/null + +EXTRA_DIST = \ + test-version.c \ + test-api.c locale/en_US/LC_MESSAGES/itest.mo +CLEANFILES = \ + test-version test-version$(EXEEXT) \ + test-api test-api$(EXEEXT) diff --git a/gettext-runtime/install-tests/itest.pot b/gettext-runtime/install-tests/itest.pot new file mode 100644 index 000000000..1e404767e --- /dev/null +++ b/gettext-runtime/install-tests/itest.pot @@ -0,0 +1,22 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Free Software Foundation, Inc. +# This file is distributed under the same license as the GNU gettext package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: GNU gettext 0.25\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-06-18 20:12+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: test-api.c:68 +msgid "She is the doppelganger of my fiancee." +msgstr "" diff --git a/gettext-runtime/install-tests/locale/en_US/LC_MESSAGES/itest.mo b/gettext-runtime/install-tests/locale/en_US/LC_MESSAGES/itest.mo new file mode 100644 index 000000000..8707c3c75 Binary files /dev/null and b/gettext-runtime/install-tests/locale/en_US/LC_MESSAGES/itest.mo differ diff --git a/gettext-runtime/install-tests/test-api.c b/gettext-runtime/install-tests/test-api.c new file mode 100644 index 000000000..16c7df1b5 --- /dev/null +++ b/gettext-runtime/install-tests/test-api.c @@ -0,0 +1,78 @@ +/* Test parts of the API. + Copyright (C) 2025 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 . */ + +/* Written by Bruno Haible , 2025. */ + +#include + +#include +#include +#include +#include + +#if defined _WIN32 && !defined __CYGWIN__ + +# define ENGLISH "English_United States" +# define ENCODING ".1252" + +# define LOCALE1 ENGLISH ENCODING + +#else + +# define LOCALE1 "en_US.UTF-8" + +#endif + +int +main () +{ + /* Clean up environment. */ +#if defined _WIN32 && !defined __CYGWIN__ + _putenv ("LANGUAGE="); + _putenv ("OUTPUT_CHARSET="); +#else + unsetenv ("LANGUAGE"); + unsetenv ("OUTPUT_CHARSET"); +#endif + + textdomain ("itest"); + +#if defined _WIN32 && !defined __CYGWIN__ + _putenv ("LC_ALL=" LOCALE1); +#else + setenv ("LC_ALL", LOCALE1, 1); +#endif + if (setlocale (LC_ALL, "") == NULL) + { + fprintf (stderr, "Skipping test: Locale %s is not installed.\n", LOCALE1); + return 0; + } + + bindtextdomain ("itest", SRCDIR "locale"); + + bind_textdomain_codeset ("itest", "UTF-8"); + + const char *s = gettext ("She is the doppelganger of my fiancee."); + const char *expected = "She is the doppelgänger of my fiancée."; + if (strcmp (s, expected) != 0) + { + fprintf (stderr, "gettext() => %s\n", s); + fprintf (stderr, "Expected: %s\n", expected); + return 1; + } + + return 0; +} diff --git a/gettext-runtime/install-tests/test-version.c b/gettext-runtime/install-tests/test-version.c new file mode 100644 index 000000000..c2f9c8b6b --- /dev/null +++ b/gettext-runtime/install-tests/test-version.c @@ -0,0 +1,36 @@ +/* Test the version information. + Copyright (C) 2025 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 . */ + +/* Written by Bruno Haible , 2025. */ + +#include + +#include + +int +main () +{ +#if defined LIBINTL_VERSION /* GNU libintl, not GNU libc */ + if (!(libintl_version == LIBINTL_VERSION)) + { + fprintf (stderr, "Installation problem: include file says version 0x%x, whereas library says version 0x%x\n", + LIBINTL_VERSION, libintl_version); + return 1; + } +#endif + + return 0; +}