From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 0D4C66DE1A0F for ; Sat, 25 Feb 2017 17:35:23 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HakfZCSsCJNW for ; Sat, 25 Feb 2017 17:35:22 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 552746DE1915 for ; Sat, 25 Feb 2017 17:35:22 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1chnjX-0006sQ-Jg; Sat, 25 Feb 2017 20:34:43 -0500 Received: (nullmailer pid 16033 invoked by uid 1000); Sun, 26 Feb 2017 01:35:17 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [patch v2 1/4] test: add known broken test for uncaught DatabaseModifiedError Date: Sat, 25 Feb 2017 21:35:09 -0400 Message-Id: <20170226013512.15868-2-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170226013512.15868-1-david@tethera.net> References: <20170226013512.15868-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Feb 2017 01:35:23 -0000 There are several of these to track down, but one that is in quite a few code paths is _notmuch_message_ensure_metadata. --- test/T640-database-modified.sh | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 test/T640-database-modified.sh diff --git a/test/T640-database-modified.sh b/test/T640-database-modified.sh new file mode 100755 index 00000000..b5b3bc2b --- /dev/null +++ b/test/T640-database-modified.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +test_description="DatabaseModifiedError handling" +. ./test-lib.sh || exit 1 + +# add enough messages to trigger the exception +add_email_corpus + +test_begin_subtest "catching DatabaseModifiedError in _notmuch_message_ensure_metadata" +test_subtest_known_broken +# it seems to need to be an early document to trigger the exception +first_id=$(notmuch search --output=messages '*'| head -1 | sed s/^id://) + +test_C ${MAIL_DIR} < +#include +#include +#include +#include +int +main (int argc, char **argv) +{ + const char *path = argv[1]; + + notmuch_database_t *rw_db, *ro_db; + notmuch_messages_t *messages; + notmuch_message_t *message, *ro_message; + notmuch_query_t *query; + notmuch_tags_t *tags; + + EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_ONLY, &ro_db)); + assert(ro_db); + + EXPECT0 (notmuch_database_find_message (ro_db, "${first_id}", &ro_message)); + assert(ro_message); + + EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &rw_db)); + query = notmuch_query_create(rw_db, ""); + EXPECT0 (notmuch_query_search_messages_st (query, &messages)); + + for (int count=0; + notmuch_messages_valid (messages); + notmuch_messages_move_to_next (messages), count++) { + message = notmuch_messages_get (messages); + for (int i=0; i<200; i++) { + char *tag_str = talloc_asprintf(rw_db, "%d", i); + EXPECT0 (notmuch_message_add_tag (message, tag_str)); + talloc_free (tag_str); + } + } + + notmuch_database_close (rw_db); + + tags = notmuch_message_get_tags (ro_message); + if (tags) + printf("SUCCESS\n"); + return 0; +} +EOF + +cat <<'EOF' >EXPECTED +== stdout == +SUCCESS +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_done -- 2.11.0