]> git.notmuchmail.org Git - notmuch/blob - test/atomicity.gdb
configure: add debug flags by default.
[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 # work around apparent issue with lazy library loading on some
22 # platforms
23 set breakpoint pending on
24
25 break rename
26 commands
27 # As an optimization, only consider snapshots after a Xapian commit.
28 # Xapian overwrites record.base? as the last step in the commit.
29 shell echo > gdbcmd
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
33 source gdbcmd
34
35 # Save a backtrace in case the test does fail
36 set logging file backtrace
37 set logging on
38 backtrace
39 set logging off
40 shell mv backtrace backtrace.`cat outcount`
41
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
51 cont
52 end
53
54 run