]> git.draconx.ca Git - cdecl99.git/commitdiff
Add a basic "make installcheck" function.
authorNick Bowler <nbowler@draconx.ca>
Wed, 22 Nov 2023 01:25:04 +0000 (20:25 -0500)
committerNick Bowler <nbowler@draconx.ca>
Wed, 22 Nov 2023 03:47:35 +0000 (22:47 -0500)
Add a very simple post-install test which simply attempts to compile,
link and run a test program against the installed header and library.

Makefile.am
t/.gitignore
t/installcheck.c [new file with mode: 0644]
t/installcheck.exp [new file with mode: 0644]

index 336e4439ba82f760cb776d09d7ef32fb8894cafd..220280ce76ff8f87a06827f36cd02a06d763f5a8 100644 (file)
@@ -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
index f6bb37d1ebd4ee72a8dc6860da4d4a1beaf65d9a..58a948e1eab5bb7dd664c02b7ef2448284c12622 100644 (file)
@@ -1,5 +1,6 @@
 /cdeclerr
 /crossparse
+/installcheck
 /normalize
 /randomdecl
 /rendertest
diff --git a/t/installcheck.c b/t/installcheck.c
new file mode 100644 (file)
index 0000000..1765671
--- /dev/null
@@ -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 <https://www.gnu.org/licenses/>.
+ */
+
+#include <cdecl.h>
+
+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 (file)
index 0000000..d62e183
--- /dev/null
@@ -0,0 +1 @@
+type array 1234567890 of int