]> git.draconx.ca Git - cdecl99.git/commitdiff
Add a test case to verify symbol prefixes.
authorNick Bowler <nbowler@draconx.ca>
Sun, 26 Feb 2012 22:13:53 +0000 (17:13 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 1 Mar 2012 01:16:59 +0000 (20:16 -0500)
Our very first automated test case!

.gitignore
Makefile.am
tests/.gitignore [new file with mode: 0644]
tests/libcdecl-static-symbols.sh [new file with mode: 0755]

index dbb2be57eb5d79843e9bbbb148177dc3811b7026..e3e7561b691e193ba65fb7a0fab7429c7ca017e6 100644 (file)
@@ -23,3 +23,4 @@ Makefile.in
 /ABOUT-NLS
 /exported.sh
 /snippet
+/test-suite.log
index f12bc0ad9a3cc8e97cf150c890b82d4b7fba0130..e11d380e197a56d7fadfd6de70cc456acfd3444c 100644 (file)
@@ -4,6 +4,7 @@
 # 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.
 
+AUTOMAKE_OPTIONS = parallel-tests color-tests
 ACLOCAL_AMFLAGS = -I m4
 
 # For Gnulib
@@ -49,6 +50,9 @@ libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
 $(libcdecl_la_OBJECTS): $(gnulib_headers)
 
 bin_PROGRAMS = cdecl99
+cdecl99_SOURCES = src/cdecl99.c
+cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
+$(cdecl99_OBJECTS): $(gnulib_headers)
 
 check_PROGRAMS =
 check_LTLIBRARIES = libtest.la
@@ -61,13 +65,16 @@ libtest_la_SOURCES += test/declgen.c
 check_PROGRAMS += test/randomdecl
 endif
 
-cdecl99_SOURCES = src/cdecl99.c
-cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
-$(cdecl99_OBJECTS): $(gnulib_headers)
-
 test_randomdecl_LDADD = libcdecl.la libtest.la libgnu.la
 $(test_randomdecl_OBJECTS): $(gnulib_headers)
 
+TESTS_ENVIRONMENT = SHELL='$(SHELL)' LIBTOOL='$(LIBTOOL)'
+TEST_EXTENSIONS = .sh
+SH_LOG_COMPILER = $(SHELL)
+
+TESTS = tests/libcdecl-static-symbols.sh
+EXTRA_DIST += $(TESTS)
+
 src/parse.lo: src/scan.h
 src/scan.lo: src/parse.h
 src/parse-decl.lo: src/scan.h src/parse.h
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644 (file)
index 0000000..397b4a7
--- /dev/null
@@ -0,0 +1 @@
+*.log
diff --git a/tests/libcdecl-static-symbols.sh b/tests/libcdecl-static-symbols.sh
new file mode 100755 (executable)
index 0000000..66fca23
--- /dev/null
@@ -0,0 +1,48 @@
+#!/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