From 2c17327ee5c428e3d52a188b0433a130b4684438 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Mon, 29 Jun 2020 22:14:08 -0300 Subject: [PATCH] test: add known broken test for error handling on closed database Based on id:87d05je1j6.fsf@powell.devork.be --- test/T560-lib-error.sh | 41 +++++++++++++++++++++++++++++++++++++++++ test/notmuch-test.h | 1 + 2 files changed, 42 insertions(+) diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 06a6b860..7284a92b 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -318,4 +318,45 @@ 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" +test_subtest_known_broken +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