Re: [PATCH v2] test: check the handling of files vanishing between scandir and indexing

2016-12-03 Thread David Bremner
Jani Nikula  writes:

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

pushed to master,

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] test: check the handling of files vanishing between scandir and indexing

2016-11-28 Thread Tomi Ollila
On Tue, Nov 29 2016, David Bremner  wrote:

> Jani Nikula  writes:
>
>> +gdb --batch-silent --return-child-result -x notmuch-new-vanish.gdb \
>> +--args notmuch new 2>OUTPUT 1>/dev/null
>
> I wonder if Tomi's suggestion of
>
>   id:20161128221231.25528-2-da...@tethera.net
>
> applies here as well. In this case it is redirecting output, rather than
> input, but I guess the same principle applies?

In case of input it may matter who has chance to consume it. In this
case of output every output of every process is dumped to /dev/null; I'd go
with this simpler approach in this case (and probably in all other cases;
If we wanted to (debug) log things we used `--batch` and redirecs to log
files instead of /dev/null).

Tomi


>
> d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] test: check the handling of files vanishing between scandir and indexing

2016-11-28 Thread David Bremner
Jani Nikula  writes:

> +gdb --batch-silent --return-child-result -x notmuch-new-vanish.gdb \
> +--args notmuch new 2>OUTPUT 1>/dev/null

I wonder if Tomi's suggestion of

  id:20161128221231.25528-2-da...@tethera.net

applies here as well. In this case it is redirecting output, rather than
input, but I guess the same principle applies?

d

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2] test: check the handling of files vanishing between scandir and indexing

2016-11-27 Thread Jani Nikula
Add a file for scandir to find, but use gdb to remove it before it
gets indexed.

---

v2: Apparently our test setup is clever enough to gracefully handle
missing prerequisites, and ignore subtest results. Just make sure we
remove the test file also in case gdb isn't there, to not leave
garbage behind.
---
 test/T050-new.sh | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/test/T050-new.sh b/test/T050-new.sh
index beeb574a3b30..2bc799d2e2bc 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 < 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 < 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

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch