notmuch.git  about / heads / tags
Unnamed repository; edit this file 'description' to name the repository.
   commit 966f40086f36a5bf26d8c180cd34a01636971a84 (patch)
   parent 16d92abf lib/database: propagate status code from _notmuch_message_delete
     tree 1230f395e03cca9bcb0919b44f65ab4564fc0619
   author David Bremner <david@tethera.net>  2022-12-03 22:28:56 -0400
committer David Bremner <david@tethera.net>  2022-12-27 11:59:38 -0400

test: add known broken test for exception handling in _n_m_delete

In [1], Thomas Schneider reported an uncaught Xapian exception when
running out of disk space. We generate the same exception via database
corruption.

[1]: id:wwuk039sk2p.fsf@chaotikum.eu
---
 test/T566-lib-message.sh | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/test/T566-lib-message.sh b/test/T566-lib-message.sh
index 511d56ca..562ab05a 100755
--- a/test/T566-lib-message.sh
+++ b/test/T566-lib-message.sh
@@ -516,4 +516,32 @@ cat <<EOF > EXPECTED
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+TERMLIST_PATH=(${MAIL_DIR}/.notmuch/xapian/termlist.*)
+test_begin_subtest "remove message with corrupted db"
+test_subtest_known_broken
+backup_database
+cat c_head0 - c_tail <<'EOF' | test_private_C ${MAIL_DIR} ${TERMLIST_PATH}
+    {
+        notmuch_status_t status;
+
+        int fd = open(argv[2],O_WRONLY|O_TRUNC);
+        if (fd < 0) {
+            fprintf (stderr, "error opening %s\n", argv[1]);
+            exit (1);
+        }
+
+        stat = _notmuch_message_delete (message);
+        printf ("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
+    }
+EOF
+cat <<EOF > EXPECTED
+== stdout ==
+1
+== stderr ==
+A Xapian exception occurred at message.cc:XXX: EOF reading block YYY
+EOF
+sed 's/EOF reading block [0-9]*/EOF reading block YYY/' < OUTPUT > OUTPUT.clean
+test_expect_equal_file EXPECTED OUTPUT.clean
+restore_database
+
 test_done


glossary
--------
Commit objects reference one tree, and zero or more parents.

Single parent commits can typically generate a patch in
unified diff format via `git format-patch'.

Multiple parents means the commit is a merge.

Root commits have no ancestor.  Note that it is
possible to have multiple root commits when merging independent histories.

Every commit references one top-level tree object.

git clone https://yhetil.org/notmuch.git