X-Envelope-From: notmuch-bounces@notmuchmail.org  Sat Aug 15 14:12:12 2026
Return-Path: <notmuch-bounces@notmuchmail.org>
X-Original-To: nmbug@yantan.tethera.net
Delivered-To: nmbug@yantan.tethera.net
Received: from yantan.tethera.net (localhost [127.0.0.1])
	by mail.notmuchmail.org (Postfix) with ESMTP id DCFF05F8AB;
	Sat, 15 Aug 2026 14:12:11 +0000 (UTC)
Received: from mail1.khirnov.net (mail1.khirnov.net [IPv6:2a00:c500:561:206::5])
	by mail.notmuchmail.org (Postfix) with ESMTPS id A755D5F88A
	for <notmuch@notmuchmail.org>; Sat, 15 Aug 2026 14:12:05 +0000 (UTC)
Authentication-Results: mail1.khirnov.net;
	dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=O3t9ktyo;
	dkim-atps=neutral
Received: from localhost (mail1.khirnov.net [IPv6:::1])
	by mail1.khirnov.net (Postfix) with ESMTP id 365C91FF3
	for <notmuch@notmuchmail.org>; Sat, 15 Aug 2026 16:02:45 +0200 (CEST)
Received: from mail1.khirnov.net ([IPv6:::1])
 by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP
 id 4PNJTrbLgjFn for <notmuch@notmuchmail.org>;
 Sat, 15 Aug 2026 16:02:44 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail;
	t=1786802561; bh=4G2Xn3dayQooPjYmf+QazVppX7OT4FMUz9eaLc804lk=;
	h=From:To:Subject:Date:In-Reply-To:References:From;
	b=O3t9ktyoLubxwWdidQXDIRgITd6YYpe3H4n7Y4k2J3w84m+iCrVF7I4L0akuDhteq
	 zWSaPmnkWTQgDt/ZRB7Ifqo9uRQuqTdVffP4AHxYiOChLjKeByQmnZPN4iCyYFamrO
	 BuRc0HhN4dv50LEtXyZVX/B6fBeZK5uz7Oms/7q3HDP8pB+vH21uLXyKkgm9FIQu6D
	 lLl70laPKYvjKi+jq1tM7ZLt3Tyx8LkpUALZ5oKebTqIQ/bw7k/uXgMbZWn4VCqgvs
	 F00oyCq37OzSTudjYVPS0pJQ9JR+g7Gst2wE3hB6EXC5ltUXCPTS/6pn6AcFr/u3HZ
	 rgWyxhHWrEtYA==
Received: from dev0.khirnov.net (dev0.khirnov.net [IPv6:2a00:c500:561:201::6])
	(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
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "dev0.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK))
	by mail1.khirnov.net (Postfix) with ESMTPS id 8CBC51FEB
	for <notmuch@notmuchmail.org>; Sat, 15 Aug 2026 16:02:41 +0200 (CEST)
Received: by dev0.khirnov.net (Postfix, from userid 1000)
	id 8FEA7402B5A; Sat, 15 Aug 2026 16:02:40 +0200 (CEST)
From: Anton Khirnov <anton@khirnov.net>
To: notmuch@notmuchmail.org
Subject: [PATCH v5 3/6] test: add tests for attachment filtering
Date: Sat, 15 Aug 2026 16:01:25 +0200
Message-ID: <20260815140127.26199-5-anton@khirnov.net>
X-Mailer: git-send-email 2.47.3
In-Reply-To: <20260815140127.26199-2-anton@khirnov.net>
References: <20260815140127.26199-2-anton@khirnov.net>
MIME-Version: 1.0
Message-ID-Hash: EKTLNWWSTTLOK7IGXA6EUVAREUF4RQY2
X-Message-ID-Hash: EKTLNWWSTTLOK7IGXA6EUVAREUF4RQY2
X-MailFrom: anton@khirnov.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." <notmuch.notmuchmail.org>
List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
List-Owner: <mailto:notmuch-owner@notmuchmail.org>
List-Post: <mailto:notmuch@notmuchmail.org>
List-Subscribe: <mailto:notmuch-join@notmuchmail.org>
List-Unsubscribe: <mailto:notmuch-leave@notmuchmail.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

This tests the libnotmuch interface, i.e. feeding the data to an
external filter and retrieving the resuls; NOT the filter itself, which
is user-supplied.
---
 test/T681-index-filter.sh | 84 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100755 test/T681-index-filter.sh

diff --git a/test/T681-index-filter.sh b/test/T681-index-filter.sh
new file mode 100755
index 00000000..6ef7b9e4
--- /dev/null
+++ b/test/T681-index-filter.sh
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+test_description="indexing attachment with a filter"
+. $(dirname "$0")/test-lib.sh || exit 1
+
+notmuch config set index.as_text ".*"
+
+cat <<EOF > $MAIL_DIR/attachment-empty.eml
+From: example@example.net
+To: example@example.com
+Subject: zero-size attachment
+Date: Sun, 09 Feb 2025 12:33:43 +0000
+Message-ID: <177064044971.16863.empty@localhost>
+MIME-Version: 1.0
+Content-Type: text/plain
+Content-Disposition: attachment; filename=foo.txt
+Content-Transfer-Encoding: base64
+
+EOF
+
+MSG_FILE_LARGE=${MAIL_DIR}/attachment-large.eml
+
+cat <<EOF > $MSG_FILE_LARGE
+From: example@example.net
+To: example@example.com
+Subject: large attachment
+Date: Sun, 09 Feb 2025 12:33:44 +0000
+Message-ID: <177064044971.16863.large@localhost>
+MIME-Version: 1.0
+Content-Type: text/plain
+Content-Disposition: attachment; filename=foo.txt
+Content-Transfer-Encoding: base64
+
+EOF
+
+{ for i in $(seq 65536); do echo $i; done } | base64 >> $MSG_FILE_LARGE
+
+notmuch new
+
+cat <<EOF > EXPECTED
+thread:XXX   2025-02-09 [1/1] example@example.net; large attachment (attachment inbox unread)
+thread:XXX   2025-02-09 [1/1] example@example.net; zero-size attachment (attachment inbox unread)
+EOF
+
+test_begin_subtest 'input ignored'
+notmuch config set index.filter "/bin/sh -c 'echo secretstring'"
+notmuch reindex '*'
+notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest 'input consumed'
+notmuch config set index.filter "/bin/sh -c 'cat - > /dev/null; echo secretstring'"
+notmuch reindex '*'
+notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest 'interleaved IO'
+# this filter interleaves reads of increasingly large weird-sized blocks
+# with writes
+notmuch config set index.filter '/bin/sh -c "
+bs=53;
+while true; do
+    dd bs=\$bs count=1 2>&1 >/dev/null | grep -q \"^0+0 records in$\" >&2 && break;
+    echo \$bs;
+    bs=\$((\$bs+48));
+done;
+echo secretstring;
+"'
+notmuch reindex '*'
+notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest 'exit failure'
+notmuch config set index.filter "/bin/sh -c 'echo secretstring; exit 1'"
+notmuch reindex '*'
+notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
+test_expect_equal_file /dev/null OUTPUT
+
+test_begin_subtest 'exit signal'
+notmuch config set index.filter "/bin/sh -c 'echo secretstring; kill -ABRT \$\$'"
+notmuch reindex '*'
+notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
+test_expect_equal_file /dev/null OUTPUT
+
+test_done
-- 
2.47.3

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org
