]> git.notmuchmail.org Git - notmuch/blob - test/atomicity.gdb
test: add tests for date:since..until range queries
[notmuch] / test / atomicity.gdb
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
9 # repeat this process.
10
11 set args new
12
13 # Make Xapian commit after every operation instead of batching
14 set environment XAPIAN_FLUSH_THRESHOLD = 1
15
16 # gdb can't keep track of a simple integer.  This is me weeping.
17 shell echo 0 > outcount
18
19 shell touch inodes
20
21 break rename
22 commands
23 # As an optimization, only consider snapshots after a Xapian commit.
24 # Xapian overwrites record.base? as the last step in the commit.
25 shell echo > gdbcmd
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
29 source gdbcmd
30
31 # Save a backtrace in case the test does fail
32 set logging file backtrace
33 set logging on
34 backtrace
35 set logging off
36 shell mv backtrace backtrace.`cat outcount`
37
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
47 cont
48 end
49
50 run