From: Bruno Haible Date: Thu, 19 Jun 2025 09:42:59 +0000 (+0200) Subject: libtextstyle: Implement 'installcheck' target. X-Git-Tag: v0.26~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=caf86941ba7595c79dc2f7b7980cb796df664856;p=thirdparty%2Fgettext.git libtextstyle: Implement 'installcheck' target. * libtextstyle/install-tests/test-version.c: New file. * libtextstyle/install-tests/test-api.c: New file. * libtextstyle/install-tests/Makefile.am: New file. * libtextstyle/configure.ac (AUGMENT_SHLIBPATH): New variable. (AC_CONFIG_FILES): Add install-tests/Makefile. * libtextstyle/Makefile.am (SUBDIRS): Add install-tests. --- diff --git a/libtextstyle/Makefile.am b/libtextstyle/Makefile.am index 4a363cde1..e06ec61ec 100644 --- a/libtextstyle/Makefile.am +++ b/libtextstyle/Makefile.am @@ -1,5 +1,5 @@ ## Makefile for the toplevel directory of GNU libtextstyle -## Copyright (C) 1995-2024 Free Software Foundation, Inc. +## Copyright (C) 1995-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 @@ -20,7 +20,7 @@ AUTOMAKE_OPTIONS = 1.13 gnu ACLOCAL_AMFLAGS = -I m4 -I gnulib-m4 # The list of subdirectories containing Makefiles. -SUBDIRS = lib tests adhoc-tests doc +SUBDIRS = lib tests adhoc-tests install-tests doc EXTRA_DIST = \ version.sh \ diff --git a/libtextstyle/configure.ac b/libtextstyle/configure.ac index dce1439e4..12317ce1c 100644 --- a/libtextstyle/configure.ac +++ b/libtextstyle/configure.ac @@ -170,6 +170,19 @@ AC_PATH_PROG([TEXI2DVI], [texi2dvi], [$ac_aux_dir_abs/missing texi2dvi]) AC_PATH_PROG([DVIPS], [dvips], [$ac_aux_dir_abs/missing dvips]) AC_PATH_PROG([PERL], [perl], [$ac_aux_dir_abs/missing perl]) +dnl Test for features used in install-tests. +dnl shlibpath_var and PATH_SEPARATOR are set by LT_INIT. +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_FILES([Makefile]) AC_CONFIG_FILES([doc/Makefile]) AC_CONFIG_FILES([lib/Makefile]) @@ -178,4 +191,5 @@ AC_CONFIG_FILES([lib/textstyle/version.h:lib/textstyle/version.in.h]) AC_CONFIG_FILES([lib/textstyle/woe32dll.h:lib/textstyle/woe32dll.in.h]) AC_CONFIG_FILES([tests/Makefile]) AC_CONFIG_FILES([adhoc-tests/Makefile]) +AC_CONFIG_FILES([install-tests/Makefile]) AC_OUTPUT diff --git a/libtextstyle/install-tests/Makefile.am b/libtextstyle/install-tests/Makefile.am new file mode 100644 index 000000000..7f833b1fd --- /dev/null +++ b/libtextstyle/install-tests/Makefile.am @@ -0,0 +1,35 @@ +## Makefile for libtextstyle/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 -ltextstyle + @AUGMENT_SHLIBPATH@ ./test-version + rm -rf test-version test-version$(EXEEXT) + $(CC) -I$(includedir) -L$(libdir) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + -DTOP_SRCDIR=\"$(top_srcdir)/\" \ + $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o test-api $(srcdir)/test-api.c -ltextstyle + @AUGMENT_SHLIBPATH@ ./test-api + rm -rf test-api test-api$(EXEEXT) + +EXTRA_DIST = test-version.c test-api.c +CLEANFILES = test-version test-version$(EXEEXT) test-api test-api$(EXEEXT) diff --git a/libtextstyle/install-tests/test-api.c b/libtextstyle/install-tests/test-api.c new file mode 100644 index 000000000..dc5fc1594 --- /dev/null +++ b/libtextstyle/install-tests/test-api.c @@ -0,0 +1,90 @@ +/* Test parts of the API. + Copyright (C) 2018-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 + +int +main () +{ + /* Test based on libtextstyle/adhoc-tests/hello.c. */ + + memory_ostream_t mstream = memory_ostream_create (); + + style_file_name = TOP_SRCDIR "adhoc-tests/hello-default.css"; + styled_ostream_t stream = + html_styled_ostream_create (mstream, style_file_name); + + ostream_write_str (stream, "Hello "); + + /* Associate the entire full name in CSS class 'name'. */ + styled_ostream_begin_use_class (stream, "name"); + + ostream_write_str (stream, "Dr. "); + styled_ostream_begin_use_class (stream, "boy-name"); + /* Start a hyperlink. */ + styled_ostream_set_hyperlink (stream, "https://en.wikipedia.org/wiki/Linus_Pauling", NULL); + ostream_write_str (stream, "Linus"); + styled_ostream_end_use_class (stream, "boy-name"); + ostream_write_str (stream, " Pauling"); + /* End the current hyperlink. */ + styled_ostream_set_hyperlink (stream, NULL, NULL); + + /* Terminate the name. */ + styled_ostream_end_use_class (stream, "name"); + + ostream_write_str (stream, "!\n"); + + /* Flush and close the stream. */ + styled_ostream_free (stream); + + const void *buf; + size_t buflen; + memory_ostream_contents (mstream, &buf, &buflen); + + const char *expected = + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "Hello Dr. Linus Pauling!
\n" + "\n"; + assert (buflen == strlen (expected)); + assert (memcmp ((const char *) buf, expected, buflen) == 0); + + ostream_free (mstream); + + return 0; +} diff --git a/libtextstyle/install-tests/test-version.c b/libtextstyle/install-tests/test-version.c new file mode 100644 index 000000000..0b2afe431 --- /dev/null +++ b/libtextstyle/install-tests/test-version.c @@ -0,0 +1,33 @@ +/* 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 (!(_libtextstyle_version == _LIBTEXTSTYLE_VERSION)) + { + fprintf (stderr, "Installation problem: include file says version 0x%x, whereas library says version 0x%x\n", + _LIBTEXTSTYLE_VERSION, _libtextstyle_version); + return 1; + } + return 0; +}