1 # This gdb script runs notmuch new and simulates killing and
2 # restarting notmuch new after every Xapian commit. To simulate this
3 # more efficiently, this script runs notmuch new and, immediately
4 # after every Xapian commit, it *pauses* the running notmuch new,
5 # copies the entire database and maildir to a snapshot directory, and
6 # executes a full notmuch new on that snapshot, comparing the final
7 # results with the expected output. It can then resume the paused
8 # notmuch new, which is still running on the original maildir, and
13 # Make Xapian commit after every operation instead of batching
14 set environment XAPIAN_FLUSH_THRESHOLD = 1
16 # gdb can't keep track of a simple integer. This is me weeping.
17 shell echo 0 > outcount
21 # work around apparent issue with lazy library loading on some
23 set breakpoint pending on
27 # As an optimization, only consider snapshots after a Xapian commit.
28 # Xapian overwrites record.base? as the last step in the commit.
30 shell stat -c %i $MAIL_DIR/.notmuch/xapian/record.base* > inodes.new
31 shell if cmp inodes inodes.new; then echo cont > gdbcmd; fi
32 shell mv inodes.new inodes
35 # Save a backtrace in case the test does fail
36 set logging file backtrace
40 shell mv backtrace backtrace.`cat outcount`
42 # Snapshot the database
43 shell rm -r $MAIL_DIR.snap/.notmuch
44 shell cp -r $MAIL_DIR/.notmuch $MAIL_DIR.snap/.notmuch
45 # Restore the mtime of $MAIL_DIR.snap, which we just changed
46 shell touch -r $MAIL_DIR $MAIL_DIR.snap
47 # Run notmuch new to completion on the snapshot
48 shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap XAPIAN_FLUSH_THRESHOLD=1000 notmuch new > /dev/null
49 shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap notmuch search '*' > search.`cat outcount` 2>&1
50 shell echo $(expr $(cat outcount) + 1) > outcount