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 ms0.migadu.com with LMTPS id Vt7zIGCetGEWSQAAgWs5BA (envelope-from ) for ; Sat, 11 Dec 2021 13:49:36 +0100 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 eFoWHGCetGHoGgAA1q6Kng (envelope-from ) for ; Sat, 11 Dec 2021 12:49:36 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 002E6EF4A for ; Sat, 11 Dec 2021 13:49:35 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id A103029701; Sat, 11 Dec 2021 07:49:27 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5856E296FF for ; Sat, 11 Dec 2021 07:49:22 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 513775FC42; Sat, 11 Dec 2021 07:49:22 -0500 (EST) Received: (nullmailer pid 1823585 invoked by uid 1000); Sat, 11 Dec 2021 12:49:18 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 2/2] test/libconfig: add two tests for the config = "" case Date: Sat, 11 Dec 2021 08:49:12 -0400 Message-Id: <20211211124912.1823559-2-david@tethera.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211211124912.1823559-1-david@tethera.net> References: <20211211124912.1823559-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 2BCQ5DYR472S24JMYP67BJAAN2B6S3C6 X-Message-ID-Hash: 2BCQ5DYR472S24JMYP67BJAAN2B6S3C6 X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639226976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=u03fb1Z1AUNYHVZUnH4ThCAoKS/afnLJeTj6zSkmh98=; b=mdLk8lb4Em1VbINKX+05O2jvqcld7vVGZ++wcuYsGjTjRlET1crZ5Pf/vRjwRYtgJ3zhFV vt6FGYmeYnyS+Bs3qEDSjY6PZA2HrhFvoR6juB5VpKgYqBHHsOl1RrwhbpyPodNuUlelXR mbo53TbOYlm9QcQG4ymLISiqjqJoR+1NqFR4EK/vH3EVBWtDyqby6t4qAiGwZR2CKsE67z uyKbadJqi734GfMCEn+/Pa07mra6VB3z1WzZUAIapxgxCyzHuVaxn7JHhy34sFB1G70dTn oZpugLgUipIXYPp9ilRqeXlXflV8PHJ+G+sjHj7rY0e9PbyMh3r3E+t+dfwPPg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639226976; a=rsa-sha256; cv=none; b=ou5DAH5v0Zvd5q04DUF/N5gBqw+HFowq4tr4+s1AIwB59e7BBeGsDUxkB6Kq0kaRko/kJf GkkFLp6xvKCi/GAQQkqGV6N5U2l8Ku7GrlJRoediC6As5INdGJ+TSX1YyCC78jGH3ttuu3 iT5qLpZ6R2akmjlcgXfxhilqkjP/a5b9s7sDGr0KSvMAVUOqvoujVGITHe31XY8cvpkB3r RdNRMTmQ4gwNTjqIFcQq4NWRDYxwoSlA9y4p73Ob+xVoh5SHboSoLFI5ecApZ6Q+beRoWE 7X0al9RuZxF1eaKJETRusfyo7CvXHmK7F+CpaL3fXHuzWdahvyXB0NHXQg91zw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.95 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 002E6EF4A X-Spam-Score: -0.95 X-Migadu-Scanner: scn1.migadu.com X-TUID: ogcAbN0h4Lzp If notmuch_database_open_with_config finds a database, but that database is not in a legacy, non-split configuration, then it currently incorrectly deduces the mail root and returns SUCCESS. Add to two tests to demonstrate this bug. --- test/T590-libconfig.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh index 089b4e58..9cc79e8c 100755 --- a/test/T590-libconfig.sh +++ b/test/T590-libconfig.sh @@ -994,4 +994,44 @@ EOF notmuch_dir_sanitize < OUTPUT > OUTPUT.clean test_expect_equal_file EXPECTED OUTPUT.clean +cat < c_body + notmuch_status_t st = notmuch_database_open_with_config(NULL, + NOTMUCH_DATABASE_MODE_READ_ONLY, + "", NULL, &db, NULL); + printf ("status == SUCCESS: %d\n", st == NOTMUCH_STATUS_SUCCESS); + if (db) { + const char *mail_root = NULL; + mail_root = notmuch_config_get (db, NOTMUCH_CONFIG_MAIL_ROOT); + printf ("mail_root: %s\n", mail_root ? mail_root : "(null)"); + } +EOF + +cat < EXPECTED.common +== stdout == +status == SUCCESS: 0 +db == NULL: 1 +== stderr == +EOF + +test_begin_subtest "open/error: config=empty with no mail root in db " +old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG} +unset NOTMUCH_CONFIG +cat c_head3 c_body c_tail3 | test_C +export NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG} +notmuch_dir_sanitize < OUTPUT > OUTPUT.clean +test_expect_equal_file EXPECTED.common OUTPUT.clean + +test_begin_subtest "open/error: config=empty with no mail root in db (xdg)" +test_subtest_known_broken +old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG} +unset NOTMUCH_CONFIG +backup_database +mkdir -p home/.local/share/notmuch +mv mail/.notmuch home/.local/share/notmuch/default +cat c_head3 c_body c_tail3 | test_C +restore_database +export NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG} +notmuch_dir_sanitize < OUTPUT > OUTPUT.clean +test_expect_equal_file EXPECTED.common OUTPUT.clean + test_done -- 2.33.0