[PATCH] tests: add a test for symbol hiding side effects

david at tethera.net david at tethera.net
Wed Jun 22 05:02:36 PDT 2011


From: David Bremner <bremner at debian.org>

The worry here is that a binary linking with libnotmuch might lose
access to Xapian::Error symbols because libnotmuch hides them.
---
 test/basic          |    2 +-
 test/notmuch-test   |    1 +
 test/symbol-hiding  |   21 +++++++++++++++++++++
 test/symbol-test.cc |   17 +++++++++++++++++
 4 files changed, 40 insertions(+), 1 deletions(-)
 create mode 100755 test/symbol-hiding
 create mode 100644 test/symbol-test.cc

diff --git a/test/basic b/test/basic
index 808c968..d6e8c10 100755
--- a/test/basic
+++ b/test/basic
@@ -56,7 +56,7 @@ tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
 available=$(ls -1 ../ | \
     sed -r -e "/^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test)/d" \
 	   -e "/^(README|test-lib.sh|test-lib.el|test-results|tmp.*|valgrind|corpus*)/d" \
-	   -e "/^(emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose)/d" \
+	   -e "/^(emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose|symbol-test.cc)/d" \
 	   -e "/^(test.expected-output|.*~)/d" \
 	   -e "/^(gnupg-secret-key.asc)/d" \
 	   -e "/^(gnupg-secret-key.NOTE)/d" \
diff --git a/test/notmuch-test b/test/notmuch-test
index 83f284d..fe85c6a 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -40,6 +40,7 @@ TESTS="
   emacs-large-search-buffer
   maildir-sync
   crypto
+  symbol-hiding
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
diff --git a/test/symbol-hiding b/test/symbol-hiding
new file mode 100755
index 0000000..1c1f34e
--- /dev/null
+++ b/test/symbol-hiding
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2011 David Bremner
+#
+
+test_description='exception symbol test
+
+This test tests whether hiding Xapian::Error symbols in libnotmuch
+also hides them for other users of libxapian. This is motivated by
+the discussion in http://gcc.gnu.org/wiki/Visibility'
+
+. ./test-lib.sh
+
+output="Error opening database at /nonexistant/.notmuch: No such file or directory
+caught No chert database found at path \`/nonexistant'"
+
+g++ -o symbol-test ../symbol-test.cc -L../lib -lnotmuch -lxapian
+test_expect_success "$message" ./symbol-test
+test_done
+
+
diff --git a/test/symbol-test.cc b/test/symbol-test.cc
new file mode 100644
index 0000000..f077845
--- /dev/null
+++ b/test/symbol-test.cc
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <xapian.h>
+#include <notmuch.h>
+main (int argc, char **argv){
+
+    notmuch_database_t *notmuch
+      = notmuch_database_open ("/nonexistant",
+				     NOTMUCH_DATABASE_MODE_READ_ONLY);
+
+  try{
+    (void)new Xapian::WritableDatabase ("/nonexistant",
+					Xapian::DB_OPEN);
+  } catch (const Xapian::Error &error) {
+    printf("caught %s\n",error.get_msg().c_str());
+  }
+  return 0;
+}
-- 
1.7.5.3



More information about the notmuch mailing list