From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YE5tB0oKjmLnkgAAbAwnHQ (envelope-from ) for ; Wed, 25 May 2022 12:51:54 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cAxAB0oKjmLKZwAAauVa8A (envelope-from ) for ; Wed, 25 May 2022 12:51:54 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 9F896158E4 for ; Wed, 25 May 2022 12:51:53 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 191CE5F79F; Wed, 25 May 2022 10:51:30 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 765CA5F701 for ; Wed, 25 May 2022 10:51:27 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id E0F3B5FC01; Wed, 25 May 2022 06:51:26 -0400 (EDT) Received: (nullmailer pid 10845 invoked by uid 1000); Wed, 25 May 2022 10:51:20 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 2/6] test: add known broken test for notmuch_tags_valid (NULL) Date: Wed, 25 May 2022 07:51:13 -0300 Message-Id: <20220525105117.10709-3-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220525105117.10709-1-david@tethera.net> References: <20220525105117.10709-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: WYGM6D3PZ4T6K5BJOOH4V34MG475WOKZ X-Message-ID-Hash: WYGM6D3PZ4T6K5BJOOH4V34MG475WOKZ 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 X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653475913; 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=1F+VFHkBMw/nydESLrFZaNGwDqwcPUCXTu/ubIoacnU=; b=KHhFOEk+7npkTsJKYY6VcWUqrfSVPZwIk3xzqg5YBYtGU2BltQ+gsNoSeEuDBdjPlVBHJs uw7bOcKgfcRSUrf8ckUqKVr1y4gPSTxQBbrqB7kKo828ZN8Lfwyc1zaVrd26wkgcMT3duv RV5eeYKzmLvmBRPFnT19am2QoOPmTlebEznLwm7EqfxKoZlk99su7wy+sMq6JVDJrDqy60 a/UB3GtouF1SonjP+CQZrAXLc4PCTvBH7/u1fJHpTE1oh/5+2wwjg7w8gImyUUizNUpzFL Gzy87cHg0+lIpTjOLQLruaegN+AIXbXK8bXs+ejV4p27G3jpu3mRksXpdkNwsQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653475913; a=rsa-sha256; cv=none; b=buFK0jva3uKxC7LgWOxc0yn5DZgsfG6pqIgTOlbx71m0l4lO0qpEKsnLv8okh6GOKjuMqY V4w2ftcccIE6SRtOxvlj7JzEo6y94opUVfLuZvZlcYMjyf6NfgSN6ktltDd3SKrXOkld/N lDOCEMZBDbVC+k56vTqvKZqmuv6RLDezT4p14KY05aAtSJzPU0gJTK2Uy4/WEIs6NZR1Iu 91tQyXC+3nogaGY3RoVkaWJlFp+HteT5Ge0ZvHSuUBLt90h1ebuuRAmquuW3ECbRsfI3zN BE6/H51NcDTp/DLneDfTUUxgKRciqGesVVa86Q4WTjhWrx1mokuEBomWzhAgZw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.00 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 9F896158E4 X-Spam-Score: -1.00 X-Migadu-Scanner: scn1.migadu.com X-TUID: NspLhSF/1ZyD This should return false, but currently segfaults. Start a new file for tags library API related tests. This is maybe overkill, but new C boilerplate which doesn't corrupt the database is needed anyway. --- test/T560-lib-error.sh | 18 --------- test/T565-lib-tags.sh | 86 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 18 deletions(-) create mode 100755 test/T565-lib-tags.sh diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 1f4482cb..a6d89346 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -245,24 +245,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT.clean restore_database -backup_database -test_begin_subtest "Xapian exception getting tags" -cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${POSTLIST_PATH} - { - notmuch_tags_t *tags = NULL; - tags = notmuch_database_get_all_tags (db); - stat = (tags == NULL); - } -EOF -sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' < OUTPUT > OUTPUT.clean -cat <<'EOF' >EXPECTED -== stdout == -== stderr == -A Xapian exception occurred getting tags -EOF -test_expect_equal_file EXPECTED OUTPUT.clean -restore_database - backup_database test_begin_subtest "Xapian exception creating directory" cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${POSTLIST_PATH} diff --git a/test/T565-lib-tags.sh b/test/T565-lib-tags.sh new file mode 100755 index 00000000..0f3595d2 --- /dev/null +++ b/test/T565-lib-tags.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +test_description="API tests for tags" + +. $(dirname "$0")/test-lib.sh || exit 1 + +add_email_corpus + +test_begin_subtest "building database" +test_expect_success "NOTMUCH_NEW" + +cat < c_head +#include +#include +#include +#include +#include +#include + +int main (int argc, char** argv) +{ + notmuch_database_t *db; + notmuch_status_t stat; + char *path; + char *msg = NULL; + int fd; + + stat = notmuch_database_open_with_config (argv[1], + NOTMUCH_DATABASE_MODE_READ_WRITE, + NULL, NULL, &db, &msg); + if (stat != NOTMUCH_STATUS_SUCCESS) { + fprintf (stderr, "error opening database\n%s\n%s\n", notmuch_status_to_string (stat), msg ? msg : ""); + exit (1); + } +EOF +cat <<'EOF' > c_tail + if (stat) { + const char *stat_str = notmuch_database_status_string (db); + if (stat_str) + fputs (stat_str, stderr); + } + +} +EOF + +POSTLIST_PATH=(${MAIL_DIR}/.notmuch/xapian/postlist.*) + +backup_database +test_begin_subtest "Xapian exception getting tags" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${POSTLIST_PATH} + { + notmuch_tags_t *tags = NULL; + fd = open(argv[2],O_WRONLY|O_TRUNC); + if (fd < 0) { + fprintf (stderr, "error opening %s\n", argv[1]); + exit (1); + } + tags = notmuch_database_get_all_tags (db); + stat = (tags == NULL); + } +EOF +sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' < OUTPUT > OUTPUT.clean +cat <<'EOF' >EXPECTED +== stdout == +== stderr == +A Xapian exception occurred getting tags +EOF +test_expect_equal_file EXPECTED OUTPUT.clean +restore_database + +test_begin_subtest "NULL tags are not valid" +test_subtest_known_broken +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} + { + notmuch_bool_t valid = TRUE; + valid = notmuch_tags_valid (NULL); + fprintf(stdout, "valid = %d\n", valid); + } +EOF +cat <<'EOF' >EXPECTED +== stdout == +valid = 0 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_done -- 2.35.2