[glib] Add new API checking utility



commit 614f6c5e7073737cf1f531120287688859f88bd7
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Jan 18 13:56:10 2013 -0500

    Add new API checking utility
    
    Add a test script to make sure that (with a few exceptions) only symbols
    that start with 'g_' are being exported from our public libraries.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692029

 Makefile.am   |    7 ++++++-
 check-abis.sh |   23 +++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 5df81cc..b2555ad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,10 @@ endif
 
 bin_SCRIPTS = glib-gettextize
 
+if OS_LINUX
+TESTS = check-abis.sh
+endif
+
 AM_CPPFLAGS = 					\
 	-DG_LOG_DOMAIN=g_log_domain_glib 	\
 	@GLIB_DEBUG_FLAGS@ 			\
@@ -58,7 +62,8 @@ EXTRA_DIST += 			\
 	gthread-2.0.pc.in	\
 	gio-2.0.pc.in		\
 	gio-unix-2.0.pc.in	\
-	gio-windows-2.0.pc.in
+	gio-windows-2.0.pc.in	\
+	check-abis.sh
 
 
 # These may be in the builddir too
diff --git a/check-abis.sh b/check-abis.sh
new file mode 100755
index 0000000..037cca6
--- /dev/null
+++ b/check-abis.sh
@@ -0,0 +1,23 @@
+#!/bin/sh -e
+
+list_leaked_symbols () {
+	nm -D "$1" | grep ' T ' | cut -f 3 -d ' ' | egrep -v "$2"
+}
+
+check_symbols () {
+	if [ "`list_leaked_symbols "$1" "$2" | wc -l`" -ne 0 ]; then
+		echo File "$1" possibly leaking symbols:
+		list_leaked_symbols "$1" "$2"
+		exit 1
+	fi
+}
+
+allowed="^_init$|^_fini$|^g_"
+allowed_in_libglib="${allowed}|^glib__private__$|^glib_gettext$|^glib_pgettext$|^glib_check_version$"
+allowed_in_libgthread='^_init$|^_fini$|^g_thread_init$|^g_thread_init_with_errorcheck_mutexes$'
+
+check_symbols glib/.libs/libglib-2.0.so "$allowed_in_libglib"
+check_symbols gthread/.libs/libgthread-2.0.so "$allowed_in_libgthread"
+for file in gmodule/.libs/libgmodule-2.0.so gobject/.libs/libgobject-2.0.so gio/.libs/libgio-2.0.so; do
+	check_symbols "$file" "$allowed"
+done



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]