From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cArUH9P/dmGRvAAAgWs5BA (envelope-from ) for ; Mon, 25 Oct 2021 21:04:51 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id wFWDG9P/dmGXGQAA1q6Kng (envelope-from ) for ; Mon, 25 Oct 2021 19:04:51 +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 3EF542565F for ; Mon, 25 Oct 2021 21:04:51 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 090141F532; Mon, 25 Oct 2021 15:04:47 -0400 (EDT) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by mail.notmuchmail.org (Postfix) with ESMTPS id D60441F531 for ; Mon, 25 Oct 2021 15:04:42 -0400 (EDT) Received: from guru.guru-group.fi (unknown [IPv6:2a02:2380:1:9:5054:ff:feb7:a4bc]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id DA8561B0009A; Mon, 25 Oct 2021 22:04:38 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1635188678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OH3/xc7XHNIuH1/EpR0dYJSf0jyYJba6HfQCFzbHir4=; b=gKOj2xl5RSjgu41ESYlC9zSMNGv2NwSPsn78oOxwVjgOpXOwBa7JsOSgfBuVB9CrDuImbm INeKyLsWg7UVDsjGDXrz/sZ+UULsgx+Ypvg/Qin9euiIwziz+InxqY1hW354+VkuJ41Rs+ uNemn6lRolLByuyZKNj19+BzQ1RWQ19qVU2cQxBTx7Pmg2y1n6KttiM5PJD4JZIhL+MBxP M8tGw+x11wG5DFrPcPYEG9p7iFouQJaDNmKQoIvt+A9MtEBchNOEbnitHVnoR23eZeHUoc g0FRnU+aIAIH+6oe7ecWP8SYNwr2WW7+2vkKSe1omp+RGMOLm1ZDnSAmjpF1mQ== From: Tomi Ollila To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 1/2] test/count: replace use of gdb with a LD_PRELOAD shim In-Reply-To: <20211025011515.2533779-2-david@tethera.net> References: <20211025011515.2533779-1-david@tethera.net> <20211025011515.2533779-2-david@tethera.net> User-Agent: Notmuch/0.33+54~gcaf4513 (https://notmuchmail.org) Emacs/27.1 X-Face: HhBM'cA~ MIME-Version: 1.0 ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1635188678; a=rsa-sha256; cv=none; b=Ct8ZWEnv/RjWYP15FXYi8X6MmW6GI78riJYP5CXSOAMQuIHZF1yuBXFoSgPhQCKQg1EL2d 5BfBIQmey55LaumND26rQt6+vUdhclDGHjPuwc5lwG1OC0nfpk7uQlw0ugypVC5Ygv6kr7 qyCUkh6YZM9DIHatH31pdU4IC1ysQBSPZ+uVjp9nTeWWSqDBLr6KNkaAsSL2BQA8lgEpuL VN1FcUPuwH565fzXrEIopuYkaZwEYYNC6+VVNEF1S7OSKGNLZU71msXM6E4va7X+gLd5LM r+rWH71SDarhLhlyWSWkVLMGLbZ1xssXOva/fs3cvGrrnULvVNEUS34geYDVmA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1635188678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OH3/xc7XHNIuH1/EpR0dYJSf0jyYJba6HfQCFzbHir4=; b=EgZWvHjyRUXuPEMtdR0+mBrD5G5r2wSCDWfxvzdN008lIVoGYLls6VEOmiJVmTz5VjFMz/ oOOUbBcMxOTZER8PEd4MpBdRlI0mfFmEAlBlkjdR/fkC3Fpj77wJUTDqw1ilGUNHWHekw1 rAcKolOb3JhtR0ntcLLPcybv+mgDzkjjMmTIOV059LcoAbU2f6k1BusQMha8qqflLt5AQ6 DUVEVkltSiG2M+Yggs0HP1tP5CopQDHgfx2elhoKWNcSmAQiDYVw7PX6A3MFkZyVNPa7vP JU1EMXbA0IcprQzvhxabsRlTXu7xOhkBdfiykyUri8KPnTOjyXWsAXz1B/Pzaw== Message-ID-Hash: 2BG6Q3JUZ6CU4A5KBNYCKXD5FMUCWWQE X-Message-ID-Hash: 2BG6Q3JUZ6CU4A5KBNYCKXD5FMUCWWQE X-MailFrom: tomi.ollila@iki.fi 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=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1635188691; 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:dkim-signature; bh=aLPwsK8VBzdRSljev81P1ujktRiVppyjREBAVQwPEck=; b=IBfZP7LI/DOURczDKSao/w0nS8u9KP23TOUHNH/cUHvO7xulToyRap+MZV0N0lQze/+NzN taEAWs8hEMUDGrMj3Kl+Lvy1nPjcSa04lPtkvitGzPrWc5OWdtWMBjpJBVIaQmilJfYCJa JDKBdW/xtBhdsnAY7OwBpE1uw/2jHq7m03oNjmdA4x65pirqiY25/5y9+DWDTT2H2NER+z NUcP8og+Palc0JiANSUKSWCSqSF78pWzs8OyGvsFRL+e4krHIjl4LjwsCJCeIOdxQOSy+X Adfw7Ip8DE+GVdCd2LOb5BlY8arVEb88ZYd8a+KHSQMks7fMIiBoxI7f3dF1qQ== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1635188691; a=rsa-sha256; cv=fail; b=LCkU/YYzYXnVrROm+V7cnTX+WJbQgdLCG4R6oJb3ZlGOAmxlFHAcmZghGU8DsNaMlizVhy upO6skB0A5u97EMUOsADmmnBtsKd8RMH+JGp6yknWyK/xC1Sy78wwTfac1STh4WrWRefuB 69qxCdpdI3Uo/LY2pzjnp0FPWbLfU22xK4oQac8hhnLyiSbN7nKphy+NXy92y67wCFZuZ4 +fJXfT0ADA5wUFW3CEGkrHNBvygeweuhiGKYG9OhsnwnprUcLGYC2A0bJwmkDE2/4c3YtD 7YRfhu9tyvUTb/mtcaLIvgwSAj0T/opSIPG42zgrV0oK7MoufMtNdAh44Q682g== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=gKOj2xl5; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); 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.05 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=gKOj2xl5; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); 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: 3EF542565F X-Spam-Score: 1.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: ko9e8z6Ble2+ On Sun, Oct 24 2021, David Bremner wrote: > There is a certain amount of boilerplate to pass the call on the > original function, so abstract it out as a C preprocessor macro, plus > some extra includes in notmuch-test.h Looks like good progress -- some comments... > --- > test/T060-count.sh | 29 +++++++++++++++++------------ > test/notmuch-test.h | 22 ++++++++++++++++++++++ > 2 files changed, 39 insertions(+), 12 deletions(-) > > diff --git a/test/T060-count.sh b/test/T060-count.sh > index 6ad80df9..acf51d88 100755 > --- a/test/T060-count.sh > +++ b/test/T060-count.sh > @@ -102,22 +102,27 @@ output=$(sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' OUTPUT) > test_expect_equal "${output}" "A Xapian exception occurred opening database" > restore_database > > -cat < count-files.gdb > -set breakpoint pending on > -set logging file count-files-gdb.log > -set logging on > -break count_files > -commands > -shell cp /dev/null ${MAIL_DIR}/.notmuch/xapian/postlist.* > -continue > -end > -run > +make_shim qsm-shim< +#include > +notmuch_status_t > +notmuch_query_search_messages (notmuch_query_t *query, notmuch_messages_t **messages) { > + static notmuch_status_t (*orig_notmuch_query_search_messages) > + (notmuch_query_t *query, notmuch_messages_t **messages) = NULL; > + TEST_SAVE_ORIG(notmuch_query_search_messages); The C preprocessor macro could do both of the lines above, deduplicating orig_notmuch_query_search_messages and notmuch_query_search_messages to one, but perhaps this way is clearer...(?) > + > + /* XXX WARNING THIS CORRUPTS THE DATABASE */ > + int fd = open("target_postlist",O_WRONLY|O_TRUNC); missing space after , > + if (fd < 0) > + exit (8); close(fd) ? > + > + return orig_notmuch_query_search_messages(query, messages); > +} > EOF > > backup_database > test_begin_subtest "error message from query_search_messages" > -${TEST_GDB} --batch-silent --return-child-result -x count-files.gdb \ > - --args notmuch count --output=files '*' 2>OUTPUT 1>/dev/null > +ln -s ${MAIL_DIR}/.notmuch/xapian/postlist.* target_postlist > +notmuch_with_shim qsm-shim count --output=files '*' 2>OUTPUT 1>/dev/null > cat < EXPECTED > notmuch count: A Xapian exception occurred > A Xapian exception occurred performing query > diff --git a/test/notmuch-test.h b/test/notmuch-test.h > index 34dbb8e0..8613a299 100644 > --- a/test/notmuch-test.h > +++ b/test/notmuch-test.h > @@ -3,6 +3,10 @@ > #include > #include > #include > +#include > +#include > +#include > +#include > > inline static void > expect0 (int line, notmuch_status_t ret) > @@ -14,4 +18,22 @@ expect0 (int line, notmuch_status_t ret) > } > > #define EXPECT0(v) expect0 (__LINE__, v); > + > +#define TEST_SAVE_ORIG(func) \ > + if (! orig_##func) { \ > + void *handle; \ > + char *error; \ > + handle = dlopen("libnotmuch.so", RTLD_LAZY); \ could have void *handle = dlopen... to reduce one macro line > + if (! handle) { \ > + fputs(dlerror(), stderr); \ > + exit(1); \ > + } \ > + orig_##func = dlsym(handle, #func); \ > + if ((error = dlerror()) != NULL) { \ > + fprintf(stderr, "%s\n", error); \ > + exit(1); \ > + } \ > + } > + > + > #endif > -- > 2.33.0