Commit fa1b4543282413598e6f33f58903bfd55f0703e9

Ran Benita 2016-03-13T20:56:58

test: add a test that all symbol version file is updated It is easy to forget to update these files when adding new symbols. Stolen with slight changes from libinput (commit by Marek Chalupa): https://cgit.freedesktop.org/wayland/libinput/commit/?id=a9f216ab47ea2f643f20ed741b741a2b5766eba3 Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/Makefile.am b/Makefile.am
index 3e3a0c1..b77d0d9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,8 @@ EXTRA_DIST = \
 	doc/doxygen-extra.css \
 	xkbcommon.map \
 	xkbcommon-x11.map \
-	PACKAGING
+	PACKAGING \
+	test/symbols-leak-test.bash
 
 AM_CPPFLAGS = \
 	-DDFLT_XKB_CONFIG_ROOT='"$(XKBCONFIGROOT)"' \
@@ -181,7 +182,8 @@ libtest_la_SOURCES = \
 AM_TESTS_ENVIRONMENT = \
 	XKB_LOG_LEVEL=debug; export XKB_LOG_LEVEL; \
 	XKB_LOG_VERBOSITY=10; export XKB_LOG_VERBOSITY; \
-	$(XORG_MALLOC_DEBUG_ENV)
+	$(XORG_MALLOC_DEBUG_ENV) \
+	top_srcdir=$(top_srcdir)
 
 build_run_tests = \
 	test/keysym \
@@ -201,6 +203,8 @@ build_run_tests = \
 build_only_tests = \
 	test/rmlvo-to-kccgst \
 	test/print-compiled-keymap
+run_only_tests = \
+	test/symbols-leak-test.bash
 
 TESTS_LDADD = libtest.la
 
@@ -248,7 +252,7 @@ test_interactive_x11_CFLAGS = $(TESTS_X11_CFLAGS)
 endif ENABLE_X11
 
 check_PROGRAMS = $(build_run_tests) $(build_only_tests)
-TESTS = $(build_run_tests)
+TESTS = $(build_run_tests) $(run_only_tests)
 
 ##
 # Benchmarks
diff --git a/test/symbols-leak-test.bash b/test/symbols-leak-test.bash
new file mode 100755
index 0000000..eac0da5
--- /dev/null
+++ b/test/symbols-leak-test.bash
@@ -0,0 +1,24 @@
+#!/bin/bash
+set -e
+
+# Check that all exported symbols are specified in the symbol
+# version scripts.  If this fails, please update the appropriate
+# (adding new version nodes when needed).
+
+# xkbcommon symbols
+diff -a -u \
+    <(cat "$top_srcdir"/xkbcommon.map | \
+        grep '^\s\+xkb_.*' | \
+        sed -e 's/^\s\+\(.*\);/\1/' | sort) \
+    <(cat "$top_srcdir"/src/{,xkbcomp,compose}/*.c | \
+        grep XKB_EXPORT -A 1 | grep '^xkb_.*' | \
+        sed -e 's/(.*//' | sort)
+
+# xkbcommon-x11 symbols
+diff -a -u \
+    <(cat "$top_srcdir"/xkbcommon-x11.map | \
+        grep '^\s\+xkb_.*' | \
+        sed -e 's/^\s\+\(.*\);/\1/' | sort) \
+    <(cat "$top_srcdir"/src/x11/*.c | \
+        grep XKB_EXPORT -A 1 | grep '^xkb_.*' | \
+        sed -e 's/(.*//' | sort)