From f1e0c18340acb7df53d5b638846fe5687255dad0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 10 Nov 2013 22:17:25 -0500 Subject: [PATCH] build-sys: add a link test for exported symbols I know that this is a pretty big net to catch some small fish, but we *do* regularly forget to properly export symbols that were supposed to be exported. This time sd_bus_get_current and some renamed symbols are caught. --- .gitignore | 3 + Makefile.am | 112 ++++++++++++++++++++++++-- src/libsystemd-bus/libsystemd-bus.sym | 6 +- 3 files changed, 112 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index cf9bb6d7d..eeb373f32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /Makefile /defined /undefined +/exported /TAGS /accelerometer /ata_id @@ -156,6 +157,8 @@ /test-utf8 /test-util /test-watchdog +/test-libsystemd-*-sym* +/test-libudev-sym* /timedatectl /udevadm /v4l_id diff --git a/Makefile.am b/Makefile.am index ce47171b7..151c4cc22 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4662,23 +4662,24 @@ install-tree: all # Let's run all tests of the test suite, but under valgrind. Let's # exclude the one perl script we have in there valgrind-tests: $(TESTS) - for f in $(TESTS) ; do \ - [ "$$f" == "$${f/.pl/}" ] && libtool --mode=execute valgrind --leak-check=full --error-exitcode=55 $(builddir)/$$f ; \ + $(AM_V_GEN)for f in $(filter-out %.pl, $^); do \ + echo "Running $$f"; \ + libtool --mode=execute valgrind -q --leak-check=full --max-stackframe=4194400 --error-exitcode=55 $(builddir)/$$f ; \ done exported: $(lib_LTLIBRARIES) - $(AM_V_GEN)for f in $(lib_LTLIBRARIES) ; do \ - nm -g --defined-only $(builddir)/.libs/"$${f/.la/.so}" 2>&1 /dev/null | grep " T " | cut -d" " -f3 ; \ + $(AM_V_GEN)for f in $(lib_LTLIBRARIES:.la=.so) ; do \ + nm -g --defined-only $(builddir)/.libs/"$$f" 2>&1 /dev/null | grep " T " | cut -d" " -f3 ; \ done > $@ check-api-docs: exported man - for symbol in `cat exported` ; do \ + $(AM_V_GEN)for symbol in `cat exported` ; do \ if test -f $(builddir)/man/$$symbol.html ; then \ echo " Symbol $$symbol() is documented." ; \ else \ echo "‣ Symbol $$symbol() lacks documentation." ; \ fi ; \ - done + done OBJECT_VARIABLES:=$(filter %_OBJECTS,$(.VARIABLES)) ALL_OBJECTS:=$(foreach v,$(OBJECT_VARIABLES),$($(v))) @@ -4694,3 +4695,102 @@ CLEANFILES += \ check-api-unused: defined undefined exported ( cat exported undefined ) | sort -u | diff -u - defined | grep ^+ | grep -v ^+++ | cut -c2- + +# Stupid test that everything purported to be exported really is + +define generate-sym-test + $(AM_V_at)$(MKDIR_P) $(dir $@) + $(AM_V_at)echo '#include ' > $@ + $(AM_V_at)for file in $(notdir $(filter %.h, $^)); do \ + echo "#include \"$$file\""; \ + done >> $@ + $(AM_V_at)echo 'void* functions[] = {' >> $@ + $(AM_V_GEN)sed -r -n 's/^( +[a-zA-Z0-9_]+);/\1,/p' $< >> $@ + $(AM_V_at)echo '};' >> $@ + $(AM_V_at)echo 'int main(void) {' >> $@ + $(AM_V_at)echo ' unsigned i; for (i=0;i> $@ + $(AM_V_at)echo 'return 0; }' >> $@ +endef + +test-libsystemd-bus-sym.c: \ + src/libsystemd-bus/libsystemd-bus.sym \ + src/systemd/sd-bus.h \ + src/systemd/sd-utf8.h \ + Makefile + $(generate-sym-test) + +test-libsystemd-daemon-sym.c: \ + src/libsystemd-daemon/libsystemd-daemon.sym \ + src/systemd/sd-daemon.h \ + Makefile + $(generate-sym-test) + +test-libsystemd-id128-sym.c: \ + src/libsystemd-id128/libsystemd-id128.sym \ + src/systemd/sd-id128.h \ + Makefile + $(generate-sym-test) + +test-libsystemd-journal-sym.c: \ + src/journal/libsystemd-journal.sym \ + src/systemd/sd-journal.h \ + Makefile + $(generate-sym-test) + +test-libsystemd-login-sym.c: \ + src/login/libsystemd-login.sym \ + src/systemd/sd-login.h \ + Makefile + $(generate-sym-test) + +test-libudev-sym.c: \ + src/libudev/libudev.sym \ + src/udev/udev.h \ + Makefile + $(generate-sym-test) + +test_libsystemd_bus_sym_SOURCES = \ + test-libsystemd-bus-sym.c +test_libsystemd_bus_sym_LDADD = \ + libsystemd-bus.la + +test_libsystemd_daemon_sym_SOURCES = \ + test-libsystemd-daemon-sym.c +test_libsystemd_daemon_sym_LDADD = \ + libsystemd-daemon.la + +test_libsystemd_id128_sym_SOURCES = \ + test-libsystemd-id128-sym.c +test_libsystemd_id128_sym_LDADD = \ + libsystemd-id128.la + +test_libsystemd_journal_sym_SOURCES = \ + test-libsystemd-journal-sym.c +test_libsystemd_journal_sym_LDADD = \ + libsystemd-journal.la + +test_libsystemd_login_sym_SOURCES = \ + test-libsystemd-login-sym.c +test_libsystemd_login_sym_LDADD = \ + libsystemd-login.la + +test_libudev_sym_SOURCES = \ + test-libudev-sym.c +test_libudev_sym_LDADD = \ + libudev.la + +BUILT_SOURCES += \ + $(test_libsystemd_bus_sym_SOURCES) \ + $(test_libsystemd_daemon_sym_SOURCES) \ + $(test_libsystemd_id128_sym_SOURCES) \ + $(test_libsystemd_journal_sym_SOURCES) \ + $(test_libsystemd_login_sym_SOURCES) \ + $(test_libudev_sym_SOURCES) + +tests += \ + test-libsystemd-bus-sym \ + test-libsystemd-daemon-sym \ + test-libsystemd-id128-sym \ + test-libsystemd-journal-sym \ + test-libsystemd-login-sym \ + test-libudev-sym diff --git a/src/libsystemd-bus/libsystemd-bus.sym b/src/libsystemd-bus/libsystemd-bus.sym index 8f1dba248..f1abf0163 100644 --- a/src/libsystemd-bus/libsystemd-bus.sym +++ b/src/libsystemd-bus/libsystemd-bus.sym @@ -41,9 +41,9 @@ global: sd_bus_can_send; sd_bus_get_server_id; sd_bus_send; - sd_bus_send_with_reply; - sd_bus_send_with_reply_cancel; - sd_bus_send_with_reply_and_block; + sd_bus_call; + sd_bus_call_async; + sd_bus_call_async_cancel; sd_bus_get_fd; sd_bus_get_events; sd_bus_get_timeout; -- 2.30.2