[PATCH 1/4] test: add known broken test for error handling on closed database

David Bremner david at tethera.net
Mon Jun 29 18:14:08 PDT 2020


Based on id:87d05je1j6.fsf at 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 <<EOF > c_head2
+#include <stdio.h>
+#include <notmuch.h>
+#include <notmuch-test.h>
+#include <assert.h>
+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 at 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 <<EOF > EXPECTED
+== stdout ==
+1258471718-6781-1-git-send-email-dottedmag at 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 <stdio.h>
+#include <stdlib.h>
 #include <notmuch.h>
 
 inline static void
-- 
2.27.0



More information about the notmuch mailing list