From 966f40086f36a5bf26d8c180cd34a01636971a84 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 3 Dec 2022 22:28:56 -0400 Subject: [PATCH] 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 < 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 < 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