From 24a138b38b11dcfc5f7c360d601244af14c5488a Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Tue, 30 Jun 2020 00:59:55 -0400 Subject: [PATCH] Begin converting testsuite to Autotest. This is better. Port the static symbol check to Autotest. --- .gitignore | 38 ++++++++++++++----------- Makefile.am | 7 +++-- configure.ac | 6 +++- tests/general.at | 31 +++++++++++++++++++++ tests/libcdecl-static-symbols.sh | 48 -------------------------------- testsuite.at | 25 +++++++++++++++++ 6 files changed, 87 insertions(+), 68 deletions(-) create mode 100644 tests/general.at delete mode 100755 tests/libcdecl-static-symbols.sh create mode 100644 testsuite.at diff --git a/.gitignore b/.gitignore index 366ba2c..911090e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,33 @@ -*.o -*.lo *.la -.libs +*.lo +*.o .deps .dirstamp -Makefile -Makefile.in -/config.* -/configure +.libs +/ABOUT-NLS /aclocal.m4 -/libtool -/missing +/atconfig /autom4te.cache -/ltmain.sh -/depcomp -/missing +/cdecl99 /compile -/stamp-h1 +/config.* +/configure +/depcomp +/exported.sh /install-sh /lib -/cdecl99 -/ABOUT-NLS -/exported.sh +/libtool +/ltmain.sh +/missing +/missing +/package.m4 /snippet +/stamp-h1 /test-driver /test-suite.log +/testsuite +/testsuite.deps +/testsuite.dir +/testsuite.log +Makefile +Makefile.in diff --git a/Makefile.am b/Makefile.am index c597499..2efe622 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -# Copyright © 2011-2013,2019 Nick Bowler +# Copyright © 2011-2013,2019-2020 Nick Bowler # # License WTFPL2: Do What The Fuck You Want To Public License, version 2. # This is free software: you are free to do what the fuck you want to. @@ -76,8 +76,8 @@ TESTS_ENVIRONMENT = SHELL='$(SHELL)' LIBTOOL='$(LIBTOOL)' EXEEXT='$(EXEEXT)' TEST_EXTENSIONS = .sh SH_LOG_COMPILER = $(SHELL) -TESTS = tests/libcdecl-static-symbols.sh tests/randomdecl-sanity.sh \ - tests/crossparse-c-random.sh tests/cdecl99-c-invalid.sh +TESTS = tests/randomdecl-sanity.sh tests/crossparse-c-random.sh \ + tests/cdecl99-c-invalid.sh dist_check_SCRIPTS = tests/randomdecl-sanity.sed $(TESTS) @@ -206,3 +206,4 @@ FLEX_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'FLEX ' $<; include $(top_srcdir)/lib/gnulib.mk include $(top_srcdir)/common/snippet/glconfig.mk +include $(top_srcdir)/common/snippet/autotest.mk diff --git a/configure.ac b/configure.ac index 1aae33e..eed1a19 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -dnl Copyright © 2011-2012 Nick Bowler +dnl Copyright © 2011-2013, 2020 Nick Bowler dnl dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2. dnl This is free software: you are free to do what the fuck you want to. @@ -71,6 +71,10 @@ AS_CASE([$with_gsl], [DX_CHECK_GSL([1.0], [have_gsl=yes], [have_gsl=no])]) AM_CONDITIONAL([HAVE_GSL], [test x"$have_gsl" = x"yes"]) +AC_CONFIG_TESTDIR([.]) +DX_PROG_AUTOTEST +AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"]) + AC_CONFIG_FILES([ Makefile ]) diff --git a/tests/general.at b/tests/general.at new file mode 100644 index 0000000..337afdd --- /dev/null +++ b/tests/general.at @@ -0,0 +1,31 @@ +# Copyright © 2012, 2020 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 . + +m4_define([LIBTOOL_VARS], + [eval `sed -n[]m4_foreach([var], m4_cdr($@), [ -e '/^var='/p]) <$1`]) + +dnl Verify that all symbols in the static library are properly prefixed. +AT_SETUP([libcdecl static symbol prefixes]) + +AT_CHECK([{ $LIBTOOL --config || exit 99; } >libtool.cfg]) +LIBTOOL_VARS([libtool.cfg], [objdir], [build_old_libs]) +AT_SKIP_IF([test x"$build_old_libs" = x"no"]) + +LIBTOOL_VARS([$builddir/libcdecl.la], [old_library]) +archive="$builddir/$objdir/$old_library" +AT_CHECK([$SHELL "$builddir/exported.sh" "$archive" || exit 99], [0], [stdout]) +AT_CHECK([sed '/^cdecl_/d' stdout]) + +AT_CLEANUP diff --git a/tests/libcdecl-static-symbols.sh b/tests/libcdecl-static-symbols.sh deleted file mode 100755 index 66fca23..0000000 --- a/tests/libcdecl-static-symbols.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# -# Copyright © 2012 Nick Bowler -# -# Verify that a static library does not export any unprefixed symbols. -# -# License WTFPL2: Do What The Fuck You Want To Public License, version 2. -# This is free software: you are free to do what the fuck you want to. -# There is NO WARRANTY, to the extent permitted by law. - -ltlib=libcdecl.la -sym_prefix=cdecl_ - -eval `$LIBTOOL --config | sed -n \ - -e '/^objdir=/p' \ - -e '/^build_old_libs=/p'` || exit 1 -eval `< $ltlib sed -ne '/^old_library=/p'` || exit 1 - -if test x"$build_old_libs" = x"no"; then - # Not building static libs. - exit 77 -fi - -lib=`expr "$ltlib" : '\(.*\)/'` -lib="$lib${lib:+/}$objdir/$old_library" - -found_sym=no -bad_sym=no - -for i in `$SHELL exported.sh "$lib"` -do - if expr "$i" : "$sym_prefix" >/dev/null; then - # Record that we found at least one exported symbol. - found_sym=yes - else - printf 'unprefixed global symbol: %s\n' "$i" 1>&2 - bad_sym=yes - fi -done - -test x"$bad_sym" = x"yes" && exit 1 - -if test x"$found_sym" = x"no"; then - printf 'no exported symbols found\n' 1>&2 - exit 1 -fi - -exit 0 diff --git a/testsuite.at b/testsuite.at new file mode 100644 index 0000000..93bc0ed --- /dev/null +++ b/testsuite.at @@ -0,0 +1,25 @@ +AT_COPYRIGHT([Copyright © 2020 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 . + +AT_INIT +AT_COLOR_TESTS + +AT_TESTED([cdecl99]) + +m4_divert_push([PREPARE_TESTS])dnl +: ${LIBTOOL="$SHELL $builddir/libtool"} +m4_divert_pop([PREPARE_TESTS]) + +m4_include([tests/general.at]) -- 2.43.2