From 776684c7b6804388088cd787f7d5faff7cfbe4c2 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 3 Oct 2014 12:58:03 -0400 Subject: [PATCH 1/8] test: Port atomicity test to Python Previously, this was implemented using a horrible GDB script (because there is no such thing as a non-horrible GDB script). This GDB script often broke with newer versions of GDB for mysterious reasons. Port the test script to GDB's Python API, which makes the code much cleaner and, hopefully, more stable. (cherry picked from commit cbbda62258360f035894cff9dfd66c60b0cc707f) Conflicts: test/T380-atomicity.sh --- test/T380-atomicity.sh | 2 +- test/atomicity.gdb | 54 -------------------------------- test/atomicity.py | 71 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 55 deletions(-) delete mode 100644 test/atomicity.gdb create mode 100644 test/atomicity.py diff --git a/test/T380-atomicity.sh b/test/T380-atomicity.sh index 1c786fa2..ee1e2f43 100755 --- a/test/T380-atomicity.sh +++ b/test/T380-atomicity.sh @@ -64,7 +64,7 @@ if test_require_external_prereq gdb; then # -tty /dev/null works around a conflict between the 'timeout' wrapper # and gdb's attempt to control the TTY. export MAIL_DIR - gdb -tty /dev/null -batch -x $TEST_DIRECTORY/atomicity.gdb notmuch >/dev/null 2>/dev/null + gdb -tty /dev/null -batch -x $TEST_DIRECTORY/atomicity.py notmuch 1>gdb.out 2>&1 # Get the final, golden output notmuch search '*' > expected diff --git a/test/atomicity.gdb b/test/atomicity.gdb deleted file mode 100644 index 15adb16c..00000000 --- a/test/atomicity.gdb +++ /dev/null @@ -1,54 +0,0 @@ -# This gdb script runs notmuch new and simulates killing and -# restarting notmuch new after every Xapian commit. To simulate this -# more efficiently, this script runs notmuch new and, immediately -# after every Xapian commit, it *pauses* the running notmuch new, -# copies the entire database and maildir to a snapshot directory, and -# executes a full notmuch new on that snapshot, comparing the final -# results with the expected output. It can then resume the paused -# notmuch new, which is still running on the original maildir, and -# repeat this process. - -set args new - -# Make Xapian commit after every operation instead of batching -set environment XAPIAN_FLUSH_THRESHOLD = 1 - -# gdb can't keep track of a simple integer. This is me weeping. -shell echo 0 > outcount - -shell touch inodes - -# work around apparent issue with lazy library loading on some -# platforms -set breakpoint pending on - -break rename -commands -# As an optimization, only consider snapshots after a Xapian commit. -# Xapian overwrites record.base? as the last step in the commit. -shell echo > gdbcmd -shell stat -c %i $MAIL_DIR/.notmuch/xapian/record.base* > inodes.new -shell if cmp inodes inodes.new; then echo cont > gdbcmd; fi -shell mv inodes.new inodes -source gdbcmd - -# Save a backtrace in case the test does fail -set logging file backtrace -set logging on -backtrace -set logging off -shell mv backtrace backtrace.`cat outcount` - -# Snapshot the database -shell rm -r $MAIL_DIR.snap/.notmuch -shell cp -r $MAIL_DIR/.notmuch $MAIL_DIR.snap/.notmuch -# Restore the mtime of $MAIL_DIR.snap, which we just changed -shell touch -r $MAIL_DIR $MAIL_DIR.snap -# Run notmuch new to completion on the snapshot -shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap XAPIAN_FLUSH_THRESHOLD=1000 notmuch new > /dev/null -shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap notmuch search '*' > search.`cat outcount` 2>&1 -shell echo $(expr $(cat outcount) + 1) > outcount -cont -end - -run diff --git a/test/atomicity.py b/test/atomicity.py new file mode 100644 index 00000000..01a42051 --- /dev/null +++ b/test/atomicity.py @@ -0,0 +1,71 @@ +# This gdb Python script runs notmuch new and simulates killing and +# restarting notmuch new after every Xapian commit. To simulate this +# more efficiently, this script runs notmuch new and, immediately +# after every Xapian commit, it *pauses* the running notmuch new, +# copies the entire database and maildir to a snapshot directory, and +# executes a full notmuch new on that snapshot, comparing the final +# results with the expected output. It can then resume the paused +# notmuch new, which is still running on the original maildir, and +# repeat this process. + +import gdb +import os +import glob +import shutil +import subprocess + +gdb.execute('set args new') + +# Make Xapian commit after every operation instead of batching +gdb.execute('set environment XAPIAN_FLUSH_THRESHOLD = 1') + +maildir = os.environ['MAIL_DIR'] + +# Trap calls to rename, which happens just before Xapian commits +class RenameBreakpoint(gdb.Breakpoint): + def __init__(self, *args, **kwargs): + super(RenameBreakpoint, self).__init__(*args, **kwargs) + self.last_inodes = {} + self.n = 0 + + def stop(self): + # As an optimization, only consider snapshots after a Xapian + # has really committed. Xapian overwrites record.base? as the + # last step in the commit, so keep an eye on their inumbers. + inodes = {} + for path in glob.glob('%s/.notmuch/xapian/record.base*' % maildir): + inodes[path] = os.stat(path).st_ino + if inodes == self.last_inodes: + # Continue + return False + self.last_inodes = inodes + + # Save a backtrace in case the test does fail + backtrace = gdb.execute('backtrace', to_string=True) + open('backtrace.%d' % self.n, 'w').write(backtrace) + + # Snapshot the database + shutil.rmtree('%s.snap/.notmuch' % maildir) + shutil.copytree('%s/.notmuch' % maildir, '%s.snap/.notmuch' % maildir) + # Restore the mtime of $MAIL_DIR.snap/ + shutil.copystat('%s/.notmuch' % maildir, '%s.snap/.notmuch' % maildir) + + # Run notmuch new to completion on the snapshot + env = os.environ.copy() + env.update(NOTMUCH_CONFIG=os.environ['NOTMUCH_CONFIG'] + '.snap', + XAPIAN_FLUSH_THRESHOLD='1000') + subprocess.check_call( + ['notmuch', 'new'], env=env, stdout=open('/dev/null', 'w')) + subprocess.check_call( + ['notmuch', 'search', '*'], env=env, + stdout=open('search.%d' % self.n, 'w')) + + # Tell the shell how far we've gotten + open('outcount', 'w').write(str(self.n + 1)) + + # Continue + self.n += 1 + return False +RenameBreakpoint('rename') + +gdb.execute('run') From b4278d4e8e95663ce4bab346a1a9d47a3206bb4a Mon Sep 17 00:00:00 2001 From: David Bremner Date: Wed, 10 Sep 2014 08:41:11 +0200 Subject: [PATCH 2/8] test: simplify T360-symbol-hiding, use nm instead of objdump After yet another variation in objdump output caused this test to fail (on a Debian port, no less), I decided whatever putative benefit we get from looking at the object files instead of the library isn't worth the maintenence headache. This version uses nm -P. nm -P should be portable, and fixed format. It purposely doesn't use the -D argument, since that is non-POSIX and nm on GNU/Linux seems do the right thing without it. It still won't work out of the box on e.g. Mac OS/X. I think the right thing to do there is to move some more configuration information into sh.config. (cherry picked from commit c34d6bad0f9da300eac2181e2073aee130432932) --- test/T360-symbol-hiding.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/T360-symbol-hiding.sh b/test/T360-symbol-hiding.sh index 636ec917..8fc4bdf6 100755 --- a/test/T360-symbol-hiding.sh +++ b/test/T360-symbol-hiding.sh @@ -26,7 +26,7 @@ test_begin_subtest 'checking output' test_expect_equal "$result" "$output" test_begin_subtest 'comparing existing to exported symbols' -objdump -t $TEST_DIRECTORY/../lib/*.o | awk '$4 == ".text" && $6 ~ "^notmuch" {print $6}' | sort | uniq > ACTUAL +nm -P $TEST_DIRECTORY/../lib/libnotmuch.so | awk '$2 == "T" && $1 ~ "^notmuch" {print $1}' | sort | uniq > ACTUAL sed -n 's/[[:blank:]]*\(notmuch_[^;]*\);/\1/p' $TEST_DIRECTORY/../notmuch.sym | sort | uniq > EXPORTED test_expect_equal_file EXPORTED ACTUAL From 1de97ee586cd3306b5fd7eb665db3f84061ed94b Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 25 Oct 2014 08:53:29 +0200 Subject: [PATCH 3/8] test/emacs: force *Messages* buffer to be writable In emacs 24.4 the messages buffer starts being read-only, which kills these tests. This seems to be the point of the variable inihibit-read-only, which has existed at least since emacs 21. --- test/T310-emacs.sh | 6 ++++-- test/T450-emacs-show.sh | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh index ac966e52..af6b2126 100755 --- a/test/T310-emacs.sh +++ b/test/T310-emacs.sh @@ -877,7 +877,8 @@ exit 1 EOF chmod a+x notmuch_fail test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\")) - (with-current-buffer \"*Messages*\" (erase-buffer)) + (with-current-buffer \"*Messages*\" + (let ((inhibit-read-only t)) (erase-buffer))) (with-current-buffer (get-buffer-create \"*Notmuch errors*\") (erase-buffer)) (notmuch-search \"tag:inbox\") @@ -909,7 +910,8 @@ exit 0 EOF chmod a+x notmuch_fail test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\")) - (with-current-buffer \"*Messages*\" (erase-buffer)) + (with-current-buffer \"*Messages*\" + (let ((inhibit-read-only t)) (erase-buffer))) (with-current-buffer (get-buffer-create \"*Notmuch errors*\") (erase-buffer)) (notmuch-search \"tag:inbox\") diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh index 2a3a5356..bfcd5efe 100755 --- a/test/T450-emacs-show.sh +++ b/test/T450-emacs-show.sh @@ -173,7 +173,8 @@ exit 1 EOF chmod a+x notmuch_fail test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\")) - (with-current-buffer \"*Messages*\" (erase-buffer)) + (with-current-buffer \"*Messages*\" + (let ((inhibit-read-only t)) (erase-buffer))) (condition-case err (notmuch-show \"*\") (error (message \"%s\" (second err)))) From e32bb2009930e9daf0d8addfc584289abdd3332a Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 25 Oct 2014 09:57:12 +0200 Subject: [PATCH 4/8] test: kill '"filename": "signature.asc"' from json output This starts to appear with emacs24.4, so we can't easily have it in our expected output. --- test/test-lib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test-lib.sh b/test/test-lib.sh index 17deaaba..72559cce 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -690,6 +690,7 @@ notmuch_json_show_sanitize () sed \ -e 's|"id": "[^"]*",|"id": "XXXXX",|g' \ -e 's|"Date": "Fri, 05 Jan 2001 [^"]*0000"|"Date": "GENERATED_DATE"|g' \ + -e 's|"filename": "signature.asc",||g' \ -e 's|"filename": "/[^"]*",|"filename": "YYYYY",|g' \ -e 's|"timestamp": 97.......|"timestamp": 42|g' } From 60bbc06ac062f121bc44b486a733880c3a6ac4d6 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 25 Oct 2014 10:38:11 +0200 Subject: [PATCH 5/8] version: bump to 0.18.2~rc1 --- bindings/python/notmuch/version.py | 2 +- version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/python/notmuch/version.py b/bindings/python/notmuch/version.py index 40f3e889..5e4f9b77 100644 --- a/bindings/python/notmuch/version.py +++ b/bindings/python/notmuch/version.py @@ -1,2 +1,2 @@ # this file should be kept in sync with ../../../version -__VERSION__ = '0.18.1' +__VERSION__ = '0.18.2~rc1' diff --git a/version b/version index 249afd51..34a761f3 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.18.1 +0.18.2~rc1 From 47b477faad9792241f92ca4391247f03fafea5a5 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 25 Oct 2014 10:42:00 +0200 Subject: [PATCH 6/8] NEWS: add minimal news item for 0.18.2 The less said, the less typos to make. --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index eb8174cd..546882be 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +Notmuch 0.18.2 (2014-10-25) +=========================== + +Test Suite +---------- + +Portability and bug fixes for test suite to improve compatibility with Emacs 24.4, gdb 7.8, and the ppc64el architecture. + Notmuch 0.18.1 (2014-06-25) =========================== From 5aeb28be2afcca65a6cf907ec7b99a584c6bcfe1 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 25 Oct 2014 10:48:31 +0200 Subject: [PATCH 7/8] debian: add changelog stanza for 0.18.2~rc-1 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 661aabee..d2dd25e1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +notmuch (0.18.2~rc1-1) experimental; urgency=medium + + * Test suite bug and portability fix release. + + -- David Bremner Sat, 25 Oct 2014 10:48:16 +0200 + notmuch (0.18.1-2) unstable; urgency=medium * Update build-deps to use emacs24 on buildd (Closes: #756085) From 26e857b7126b1963fe44801f235aa7764fdffed7 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 25 Oct 2014 11:20:57 +0200 Subject: [PATCH 8/8] debian: build depend on dh-python The build log asked me nicely, so I did. --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index 6fa1fa7b..50de2ff7 100644 --- a/debian/control +++ b/debian/control @@ -15,6 +15,7 @@ Build-Depends: libz-dev, python-all (>= 2.6.6-3~), python3-all (>= 3.1.2-7~), + dh-python, python-sphinx (>= 1.0), ruby, ruby-dev (>>1:1.9.3~), emacs24-nox | emacs24 (>=24~) | emacs24-lucid (>=24~) |