1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 69A08431FD9
\r
6 for <notmuch@notmuchmail.org>; Sat, 14 Mar 2015 10:04:34 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5
\r
12 tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 0mrH15wFt-kA for <notmuch@notmuchmail.org>;
\r
16 Sat, 14 Mar 2015 10:04:32 -0700 (PDT)
\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net
\r
19 (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 93086431FD7
\r
22 for <notmuch@notmuchmail.org>; Sat, 14 Mar 2015 10:04:32 -0700 (PDT)
\r
23 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim
\r
24 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
25 id 1YWpTY-00027S-Cp; Sat, 14 Mar 2015 17:03:48 +0000
\r
26 Received: (nullmailer pid 4985 invoked by uid 1000); Sat, 14 Mar 2015
\r
28 From: David Bremner <david@tethera.net>
\r
29 To: notmuch@notmuchmail.org
\r
30 Subject: [Patch v4 3/9] test: add error reporting tests for lib/database.cc
\r
31 Date: Sat, 14 Mar 2015 18:02:28 +0100
\r
32 Message-Id: <1426352554-4383-4-git-send-email-david@tethera.net>
\r
33 X-Mailer: git-send-email 2.1.4
\r
34 In-Reply-To: <1426352554-4383-1-git-send-email-david@tethera.net>
\r
35 References: <1426352554-4383-1-git-send-email-david@tethera.net>
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.13
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Sat, 14 Mar 2015 17:04:34 -0000
\r
50 Unfortunately quite a few of the error handling paths here require
\r
51 more sophisticated tests using e.g. gdb.
\r
53 test/T560-lib-error.sh | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++
\r
54 1 file changed, 91 insertions(+)
\r
55 create mode 100755 test/T560-lib-error.sh
\r
57 diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
\r
58 new file mode 100755
\r
59 index 0000000..dc2022f
\r
61 +++ b/test/T560-lib-error.sh
\r
63 +#!/usr/bin/env bash
\r
64 +test_description="error reporting for library"
\r
70 +test_expect_success "building database" "NOTMUCH_NEW"
\r
72 +test_begin_subtest "Open null pointer"
\r
75 +#include <notmuch.h>
\r
76 +int main (int argc, char** argv)
\r
78 + notmuch_database_t *db;
\r
79 + notmuch_status_t stat;
\r
80 + stat = notmuch_database_open (NULL, 0, 0);
\r
83 +cat <<EOF >EXPECTED
\r
86 +Error: Cannot open a database for a NULL path.
\r
88 +test_expect_equal_file EXPECTED OUTPUT
\r
90 +test_begin_subtest "Open nonexistent database"
\r
93 +#include <notmuch.h>
\r
94 +int main (int argc, char** argv)
\r
96 + notmuch_database_t *db;
\r
97 + notmuch_status_t stat;
\r
98 + stat = notmuch_database_open ("/nonexistent/foo", 0, 0);
\r
101 +cat <<EOF >EXPECTED
\r
104 +Error opening database at /nonexistent/foo/.notmuch: No such file or directory
\r
106 +test_expect_equal_file EXPECTED OUTPUT
\r
108 +test_begin_subtest "Write to read-only database"
\r
109 +test_C ${MAIL_DIR} <<EOF
\r
110 +#include <stdio.h>
\r
111 +#include <notmuch.h>
\r
112 +int main (int argc, char** argv)
\r
114 + notmuch_database_t *db;
\r
115 + notmuch_status_t stat;
\r
116 + stat = notmuch_database_open (argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY, &db);
\r
117 + if (stat != NOTMUCH_STATUS_SUCCESS) {
\r
118 + fprintf (stderr, "error opening database: %d\n", stat);
\r
120 + stat = notmuch_database_add_message (db, "/dev/null", NULL);
\r
123 +cat <<EOF >EXPECTED
\r
126 +Cannot write to a read-only database.
\r
128 +test_expect_equal_file EXPECTED OUTPUT
\r
130 +test_begin_subtest "compact, overwriting existing backup"
\r
131 +test_C ${MAIL_DIR} <<EOF
\r
132 +#include <stdio.h>
\r
133 +#include <notmuch.h>
\r
135 +status_cb (const char *msg, void *closure)
\r
137 + printf ("%s\n", msg);
\r
139 +int main (int argc, char** argv)
\r
141 + notmuch_database_t *db;
\r
142 + notmuch_status_t stat;
\r
143 + stat = notmuch_database_compact (argv[1], argv[1], status_cb, NULL);
\r
146 +cat <<EOF >EXPECTED
\r
149 +Path already exists: CWD/mail
\r
151 +test_expect_equal_file EXPECTED OUTPUT
\r