From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 359D96DE12DE for ; Sun, 26 May 2019 06:09:00 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.041 X-Spam-Level: X-Spam-Status: No, score=-0.041 tagged_above=-999 required=5 tests=[AWL=-0.040, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TJChCjU27CqO for ; Sun, 26 May 2019 06:08:58 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id E90306DE0E7E for ; Sun, 26 May 2019 06:08:57 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1hUstV-0005NQ-31; Sun, 26 May 2019 09:08:57 -0400 Received: (nullmailer pid 8437 invoked by uid 1000); Sun, 26 May 2019 13:08:58 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 2/2] test: replace use of gdb with LD_PRELOAD shims in T070-insert.sh Date: Sun, 26 May 2019 10:08:54 -0300 Message-Id: <20190526130854.8348-3-david@tethera.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190526130854.8348-1-david@tethera.net> References: <20190526130854.8348-1-david@tethera.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 May 2019 13:09:00 -0000 This removes the dependency of this test script on gdb, and considerably speeds up the running of the tests. --- test/T070-insert.sh | 50 ++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/test/T070-insert.sh b/test/T070-insert.sh index 48165caa..ab26ecd4 100755 --- a/test/T070-insert.sh +++ b/test/T070-insert.sh @@ -2,8 +2,6 @@ test_description='"notmuch insert"' . $(dirname "$0")/test-lib.sh || exit 1 -test_require_external_prereq gdb - # subtests about file permissions assume that we're working with umask # 022 by default. umask 022 @@ -246,50 +244,38 @@ test_expect_code 1 "notmuch insert $gen_msg_filename 2>&1" notmuch config set new.tags $OLDCONFIG # DUPLICATE_MESSAGE_ID is not tested here, because it should actually pass. +gen_insert_msg -for code in OUT_OF_MEMORY XAPIAN_EXCEPTION FILE_NOT_EMAIL \ - READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do -cat < index-file-$code.gdb -set breakpoint pending on -set logging file index-file-$code.log -set logging on -break notmuch_database_index_file -commands -return NOTMUCH_STATUS_$code -continue -end -run +# pregenerate all of the test shims +for code in FILE_NOT_EMAIL READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR OUT_OF_MEMORY XAPIAN_EXCEPTION; do + make_shim shim-$code < +#include +notmuch_status_t +notmuch_database_index_file (notmuch_database_t *notmuch, + const char *filename, + notmuch_indexopts_t *indexopts, + notmuch_message_t **message_ret) +{ + return NOTMUCH_STATUS_$code; +} EOF done -gen_insert_msg - for code in FILE_NOT_EMAIL READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do test_begin_subtest "EXIT_FAILURE when index_file returns $code" - test_expect_code 1 \ - "${TEST_GDB} --batch-silent --return-child-result \ - -ex 'set args insert < $gen_msg_filename' \ - -x index-file-$code.gdb notmuch" + test_expect_code 1 "notmuch_with_shim shim-$code insert < \"$gen_msg_filename\"" test_begin_subtest "success exit with --keep when index_file returns $code" - test_expect_code 0 \ - "${TEST_GDB} --batch-silent --return-child-result \ - -ex 'set args insert --keep < $gen_msg_filename' \ - -x index-file-$code.gdb notmuch" + test_expect_code 0 "notmuch_with_shim shim-$code insert --keep < \"$gen_msg_filename\"" done for code in OUT_OF_MEMORY XAPIAN_EXCEPTION ; do test_begin_subtest "EX_TEMPFAIL when index_file returns $code" - test_expect_code 75 \ - "${TEST_GDB} --batch-silent --return-child-result \ - -ex 'set args insert < $gen_msg_filename' \ - -x index-file-$code.gdb notmuch" + test_expect_code 75 "notmuch_with_shim shim-$code insert < \"$gen_msg_filename\"" test_begin_subtest "success exit with --keep when index_file returns $code" - test_expect_code 0 \ - "${TEST_GDB} --batch-silent --return-child-result \ - -ex 'set args insert --keep < $gen_msg_filename' \ - -x index-file-$code.gdb notmuch" + test_expect_code 0 "notmuch_with_shim shim-$code insert --keep < \"$gen_msg_filename\"" done test_done -- 2.20.1