From: Nick Bowler Date: Wed, 22 Nov 2023 01:25:04 +0000 (-0500) Subject: Add a basic "make installcheck" function. X-Git-Tag: v1.3~80 X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/commitdiff_plain/094c357d91c1fd7c5a7ea165381b00601fe21257 Add a basic "make installcheck" function. Add a very simple post-install test which simply attempts to compile, link and run a test program against the installed header and library. --- diff --git a/Makefile.am b/Makefile.am index 336e443..220280c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -335,6 +335,24 @@ atlocal: config.status check_DATA = atlocal CLEANFILES += atlocal +# Note: to reliably test linking against the installed library we directly +# refer to the just-installed .la file, rather than more typical library flags +# (-Lfoo -lfoo). Otherwise libtool can pick up libcdecl.la from the current +# working directory which defeats the point of an install check. +EXTRA_PROGRAMS = t/installcheck +t_installcheck_CPPFLAGS = -I$(DESTDIR)$(includedir) +t_installcheck_LDADD = $(DESTDIR)$(libdir)/libcdecl.la +t_installcheck_CFLAGS = +t_installcheck_SHORTNAME = x + +installcheck-local: + rm -f t/installcheck$(EXEEXT) + $(MAKE) $(AM_MAKEFLAGS) t/installcheck$(EXEEXT) + t/installcheck$(EXEEXT) | diff - $(srcdir)/t/installcheck.exp +.PHONY: installcheck-local +EXTRA_DIST += t/installcheck.c t/installcheck.exp +CLEANFILES += t/installcheck$(EXEEXT) + include $(top_srcdir)/lib/gnulib.mk include $(top_srcdir)/common/snippet/glconfig.mk include $(top_srcdir)/common/snippet/autotest.mk diff --git a/t/.gitignore b/t/.gitignore index f6bb37d..58a948e 100644 --- a/t/.gitignore +++ b/t/.gitignore @@ -1,5 +1,6 @@ /cdeclerr /crossparse +/installcheck /normalize /randomdecl /rendertest diff --git a/t/installcheck.c b/t/installcheck.c new file mode 100644 index 0000000..1765671 --- /dev/null +++ b/t/installcheck.c @@ -0,0 +1,38 @@ +/* + * Post-installation sanity check for libcdecl. + * + * Copyright © 2023 Nick Bowler + * + * 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 . + */ + +#include + +int main(void) +{ + extern int puts(const char *); + + struct cdecl_declarator decl_array, decl_null = {0}; + struct cdecl_declspec spec = {0, CDECL_TYPE_INT}; + struct cdecl decl = {0, &spec, &decl_array}; + char buf[100]; + + decl_array.child = &decl_null; + decl_array.type = CDECL_DECL_ARRAY; + decl_array.u.array.length = 1234567890; + decl_array.u.array.vla = NULL; + + cdecl_explain(buf, sizeof buf, &decl); + puts(buf); +} diff --git a/t/installcheck.exp b/t/installcheck.exp new file mode 100644 index 0000000..d62e183 --- /dev/null +++ b/t/installcheck.exp @@ -0,0 +1 @@ +type array 1234567890 of int