aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJani Nikula <jani@nikula.org>2016-11-27 11:59:34 +0200
committerDavid Bremner <david@tethera.net>2016-12-03 07:18:49 -0400
commite682c8f8f84fe5f7af30280bd8ea437772e154fa (patch)
treeab25a4d1bd2b59423cdd25d119d8b5efef984ea0 /test
parentf781b7e7d25102006a9fbf0fcae4ae4b33ab8e2b (diff)
test: check the handling of files vanishing between scandir and indexing
Add a file for scandir to find, but use gdb to remove it before it gets indexed.
Diffstat (limited to 'test')
-rwxr-xr-xtest/T050-new.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/T050-new.sh b/test/T050-new.sh
index beeb574a..2bc799d2 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -298,4 +298,38 @@ 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
+
+# Clean up the file in case gdb isn't available.
+rm -f ${MAIL_DIR}/vanish
+
+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