From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 6GIgOjsFdmFMLAAAgWs5BA (envelope-from ) for ; Mon, 25 Oct 2021 03:15:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id EDLJNTsFdmFsaAAAB5/wlQ (envelope-from ) for ; Mon, 25 Oct 2021 01:15:39 +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 9F0A136460 for ; Mon, 25 Oct 2021 03:15:39 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 143D61F4DC; Sun, 24 Oct 2021 21:15:28 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 7241B1F4D6 for ; Sun, 24 Oct 2021 21:15:23 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 67E1E5FC42; Sun, 24 Oct 2021 21:15:23 -0400 (EDT) Received: (nullmailer pid 2533946 invoked by uid 1000); Mon, 25 Oct 2021 01:15:20 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 2/2] test/new: replace use of gdb in vanishing file test Date: Sun, 24 Oct 2021 22:15:15 -0300 Message-Id: <20211025011515.2533779-3-david@tethera.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211025011515.2533779-1-david@tethera.net> References: <20211025011515.2533779-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: L364QY3LDEVQYQC6HVE6ZM6OHJZ76Z67 X-Message-ID-Hash: L364QY3LDEVQYQC6HVE6ZM6OHJZ76Z67 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=1635124539; 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=M+0l8SBSdTxhLNYkKQ33/yLSEtUI/VBjzYYu1puH1WA=; b=nbOq3xcirsjBn9wGDIIxhUaOf75biZRbS22dP7x/dgbsMCwbAeT8yBH1XJGlrdCnrHEjv9 Uzb1j2dCw79sVm6HL0qHaQ6ppop+wVlUaymLodg7LH0S3o81pDrBRKI/j+leeH6SczHeZD tJC+BFv/BTohVuzjv0imZJof7p/0MsYd01qCfkuIWLAibnxPAvvDeY5AGTkBu7Ay9GSuKS 5sTbaMOKhmpv75nRcwy+nKCIRGYu0pgUuK2l09jYlydesFY0Efhd1HzY3F4/bpNdMWaWMS lYj7AFlIu7dBzV222PZ5miZo7U61d5W2uygC7pLqXRW9v+91NFSpCPka8RgWpg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1635124539; a=rsa-sha256; cv=none; b=T5Yg/iOIdaTmxsKcZUhRgUP0wY/Ck+rTpttVuo7jSl/zz+ItHny+hZlg8DZMOXZW97NjPG H1kZbWzBKLA9sISnxd6h3T2DNELm1BFvdJpQL+mRZCJOEcgKqLjzRtwE6XVmurGaQwvrsY fpa5bbbvB+M8988sEjoQCHvErluBEjeK34kIzaEdlnd3fZymNri/CW6yfC6xUGsoYu0RiH mHart8uQ3exDY15DY70rDmti4/x9e/PIJiggnAZD1bZRvuVc6CiAyhGvCxgx71fumeER17 XQtB+jskYThNZaLl98W9mgipHX/64KtXTGwdc66eBwqwKCWKY/sv7jrmaR3eZg== 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: -1.15 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: 9F0A136460 X-Spam-Score: -1.15 X-Migadu-Scanner: scn0.migadu.com X-TUID: u3+dlybOfRPk Because the file to be removed has a predictable name, we can hard code it in the generated shim. --- test/T050-new.sh | 44 ++++++++++++++++++++++++-------------------- test/notmuch-test.h | 1 + 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/test/T050-new.sh b/test/T050-new.sh index 1141c1e3..5a03998b 100755 --- a/test/T050-new.sh +++ b/test/T050-new.sh @@ -368,31 +368,35 @@ chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.* test_expect_equal "$output" "A Xapian exception occurred opening database" +make_shim dif-shim< +notmuch_status_t +notmuch_database_index_file (notmuch_database_t *database, + const char *filename, + notmuch_indexopts_t *indexopts, + notmuch_message_t **message) +{ + static notmuch_status_t (*orig_notmuch_database_index_file) + (notmuch_database_t *database, + const char *filename, + notmuch_indexopts_t *indexopts, + notmuch_message_t **message) = NULL; + TEST_SAVE_ORIG(notmuch_database_index_file); + + if (unlink("${MAIL_DIR}/vanish")) { + fprintf(stderr, "unlink failed\n"); + exit(42); + } + return orig_notmuch_database_index_file(database, filename, indexopts, message); +} +EOF + test_begin_subtest "Handle files vanishing between scandir and add_file" # A file for scandir to find. It won't get indexed, so can be empty. touch ${MAIL_DIR}/vanish - -# Breakpoint to remove the file before indexing -cat < notmuch-new-vanish.gdb -set breakpoint pending on -set logging file notmuch-new-vanish-gdb.log -set logging on -break notmuch_database_index_file -commands -shell rm -f ${MAIL_DIR}/vanish -continue -end -run -EOF - -${TEST_GDB} --batch-silent --return-child-result -x notmuch-new-vanish.gdb \ - --args notmuch new 2>OUTPUT 1>/dev/null +notmuch_with_shim dif-shim new 2>OUTPUT 1>/dev/null echo "exit status: $?" >> OUTPUT - -# Clean up the file in case gdb isn't available. -rm -f ${MAIL_DIR}/vanish - cat < EXPECTED Unexpected error with file ${MAIL_DIR}/vanish add_file: Something went wrong trying to read or write a file diff --git a/test/notmuch-test.h b/test/notmuch-test.h index 8613a299..94348d69 100644 --- a/test/notmuch-test.h +++ b/test/notmuch-test.h @@ -7,6 +7,7 @@ #include #include #include +#include inline static void expect0 (int line, notmuch_status_t ret) -- 2.33.0