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
23 # As an optimization, only consider snapshots after a Xapian commit.
24 # Xapian overwrites record.base? as the last step in the commit.
26 shell stat -c %i $MAIL_DIR/.notmuch/xapian/record.base* > inodes.new
27 shell if cmp inodes inodes.new; then echo cont > gdbcmd; fi
28 shell mv inodes.new inodes
31 # Save a backtrace in case the test does fail
32 set logging file backtrace
36 shell mv backtrace backtrace.`cat outcount`
38 # Snapshot the database
39 shell rm -r $MAIL_DIR.snap/.notmuch
40 shell cp -r $MAIL_DIR/.notmuch $MAIL_DIR.snap/.notmuch
41 # Restore the mtime of $MAIL_DIR.snap, which we just changed
42 shell touch -r $MAIL_DIR $MAIL_DIR.snap
43 # Run notmuch new to completion on the snapshot
44 shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap XAPIAN_FLUSH_THRESHOLD=1000 notmuch new > /dev/null
45 shell NOTMUCH_CONFIG=${NOTMUCH_CONFIG}.snap notmuch search '*' > search.`cat outcount` 2>&1
46 shell echo $(expr $(cat outcount) + 1) > outcount