unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: [PATCH] test: check the handling of files vanishing between scandir and indexing
Date: Sat, 26 Nov 2016 11:18:18 +0200	[thread overview]
Message-ID: <1480151898-17278-1-git-send-email-jani@nikula.org> (raw)
In-Reply-To: <87shqer46p.fsf@nikula.org>

Add a file for scandir to find, but use gdb to remove it before it
gets indexed.

---

The ugly part is that this should require gdb as external dep... but
we shouldn't skip all of T050-new.sh if gdb isn't there. I'm in a
hurry, any good ideas?
---
 test/T050-new.sh | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/test/T050-new.sh b/test/T050-new.sh
index beeb574a3b30..072b63a148cc 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -298,4 +298,34 @@ output=$(NOTMUCH_NEW --debug 2>&1 | sed 's/: .*$//' )
 chmod u+w  ${MAIL_DIR}/.notmuch/xapian/*.${db_ending}
 test_expect_equal "$output" "A Xapian exception occurred opening database"
 
+
+test_begin_subtest "Handle files vanishing between scandir and add_file"
+
+# A file for scandir to find. It won't get indexed, so can be empty.
+touch ${MAIL_DIR}/vanish
+
+# Breakpoint to remove the file before indexing
+cat <<EOF > notmuch-new-vanish.gdb
+set breakpoint pending on
+set logging file notmuch-new-vanish-gdb.log
+set logging on
+break add_file
+commands
+shell rm -f ${MAIL_DIR}/vanish
+continue
+end
+run
+EOF
+
+gdb --batch-silent --return-child-result -x notmuch-new-vanish.gdb \
+    --args notmuch new 2>OUTPUT 1>/dev/null
+echo "exit status: $?" >> OUTPUT
+cat <<EOF > EXPECTED
+Unexpected error with file ${MAIL_DIR}/vanish
+add_file: Something went wrong trying to read or write a file
+Error opening ${MAIL_DIR}/vanish: No such file or directory
+exit status: 75
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
-- 
2.1.4

  reply	other threads:[~2016-11-26  9:20 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-04 12:46 [Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`? David Bremner
2016-11-04 16:26 ` David Bremner
2016-11-13  1:51   ` Austin Clements
2016-11-14 18:44     ` J. Lewis Muir
2016-11-14 18:59       ` David Bremner
2016-11-04 18:47 ` Jani Nikula
2016-11-05  2:15   ` Paul Wise
2016-11-05 12:57     ` [PATCH] cli: consider files vanishing during notmuch new non-fatal Jani Nikula
2016-11-05 13:22       ` Paul Wise
2016-11-12 15:39         ` David Bremner
2016-11-12 16:04           ` Brian Sniffen
2016-11-12 16:10             ` David Bremner
2016-11-12 16:15               ` David Bremner
2016-11-12 21:08               ` Brian Sniffen
2016-11-12 21:36                 ` David Bremner
2016-11-12 20:35             ` Jani Nikula
2016-11-16 11:43       ` David Bremner
2016-11-21 20:14         ` [PATCH v2] " Jani Nikula
2016-11-26  2:44           ` [PATCH] cli/new: document new exit code David Bremner
2016-11-26  9:17             ` Jani Nikula
2016-11-26  9:18               ` Jani Nikula [this message]
2016-11-27  9:59                 ` [PATCH v2] test: check the handling of files vanishing between scandir and indexing Jani Nikula
2016-11-29  2:16                   ` David Bremner
2016-11-29  7:31                     ` Tomi Ollila
2016-12-03 11:24                   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1480151898-17278-1-git-send-email-jani@nikula.org \
    --to=jani@nikula.org \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).