From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KJrJMqIw+15begAA0tVLHw (envelope-from ) for ; Tue, 30 Jun 2020 12:31:30 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id sJimLqIw+17VaQAA1q6Kng (envelope-from ) for ; Tue, 30 Jun 2020 12:31:30 +0000 Received: from arlo.cworth.org (arlo.cworth.org [50.126.95.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 187BB94013C for ; Tue, 30 Jun 2020 12:31:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 7DF8A6DE13DE; Tue, 30 Jun 2020 05:31:28 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org 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 UscYLdC2F65E; Tue, 30 Jun 2020 05:31:27 -0700 (PDT) Received: from arlo.cworth.org (localhost [IPv6:::1]) by arlo.cworth.org (Postfix) with ESMTP id 5A61C6DE0F76; Tue, 30 Jun 2020 05:31:27 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 89C7B6DE0F76 for ; Tue, 30 Jun 2020 05:31:26 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org 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 P3WFR-8WI68L for ; Tue, 30 Jun 2020 05:31:25 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTP id A0F116DE0F16 for ; Tue, 30 Jun 2020 05:31:25 -0700 (PDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 53B496141D; Tue, 30 Jun 2020 08:31:25 -0400 (EDT) Received: (nullmailer pid 2275033 invoked by uid 1000); Tue, 30 Jun 2020 12:31:24 -0000 Resent-To: notmuch@notmuchmail.org Resent-From: David Bremner Resent-Date: Tue, 30 Jun 2020 09:31:24 -0300 Resent-Message-ID: <87366cka5f.fsf@tethera.net> Received: by fethera.tethera.net (Postfix, from userid 1001) id 3639361423; Mon, 29 Jun 2020 21:14:32 -0400 (EDT) Received: (nullmailer pid 612640 invoked by uid 1000); Tue, 30 Jun 2020 01:14:18 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 1/4] test: add known broken test for error handling on closed database Date: Mon, 29 Jun 2020 22:14:08 -0300 Message-Id: <20200630011411.612552-2-david@tethera.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200630011411.612552-1-david@tethera.net> References: <20200630011411.612552-1-david@tethera.net> MIME-Version: 1.0 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: notmuch-bounces@notmuchmail.org Sender: "notmuch" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 50.126.95.6 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: -0.01 X-TUID: Zrq5390yOWrp Based on id:87d05je1j6.fsf@powell.devork.be --- test/T560-lib-error.sh | 40 ++++++++++++++++++++++++++++++++++++++++ test/notmuch-test.h | 1 + 2 files changed, 41 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 06a6b860..5a5f66b8 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -318,4 +318,44 @@ EOF test_expect_equal_file EXPECTED OUTPUT.clean restore_database +cat < c_head2 +#include +#include +#include +#include +int main (int argc, char** argv) +{ + notmuch_database_t *db; + notmuch_status_t stat; + char *msg = NULL; + notmuch_message_t *message = NULL; + const char *id = "1258471718-6781-1-git-send-email-dottedmag@dottedmag.net"; + + stat = notmuch_database_open_verbose (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db, &msg); + if (stat != NOTMUCH_STATUS_SUCCESS) { + fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : ""); + exit (1); + } + EXPECT0(notmuch_database_find_message (db, id, &message)); + assert(message != NULL); + EXPECT0(notmuch_database_close (db)); +EOF + +backup_database +test_begin_subtest "Handle getting message-id from closed database" +cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + const char *id2; + id2=notmuch_message_get_message_id (message); + printf("%s\n%d\n", id, id2==NULL); + } +EOF +cat < EXPECTED +== stdout == +1258471718-6781-1-git-send-email-dottedmag@dottedmag.net +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done diff --git a/test/notmuch-test.h b/test/notmuch-test.h index df852da9..34dbb8e0 100644 --- a/test/notmuch-test.h +++ b/test/notmuch-test.h @@ -1,6 +1,7 @@ #ifndef _NOTMUCH_TEST_H #define _NOTMUCH_TEST_H #include +#include #include inline static void -- 2.27.0