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 40EC26DE1270 for ; Sun, 27 Nov 2016 02:01:33 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.282 X-Spam-Level: X-Spam-Status: No, score=0.282 tagged_above=-999 required=5 tests=[AWL=0.302, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] 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 9unV7EVCXVdU for ; Sun, 27 Nov 2016 02:01:32 -0800 (PST) Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by arlo.cworth.org (Postfix) with ESMTPS id 25BAB6DE1216 for ; Sun, 27 Nov 2016 02:01:32 -0800 (PST) Received: by mail-lf0-f67.google.com with SMTP id o141so6745010lff.1 for ; Sun, 27 Nov 2016 02:01:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FpF3qnWO3wE3bigGFIt+UgfxHOE4N05RmSfjehaOpHw=; b=pMwjoAxKynQF4AA1JWN/QI6fFO6t/YK7pa6bblLqK2Rf/zoXGWjcniwL441MmhcH1n SYThEMoxANiLnsYOX3JzkvW//utACnmXXz5Dq6gK1Hy3qUn+b88uR5V0w0/6CjLMEcTv uMIoOBRvMdvaekyW+Q5qWuGhGK1j8JHUmdbuHhqJv6DbSII+isMDCQxtSND8tlFq0vc8 9VozWa4bKFbPS8CRqSmKGY655w7Kkba0oYRNZ3x4tHBKzelOcg5t4Wn96vYb67/zJsQv 9ahcq8rs4sDto4Q+st4SjJwrKbcGBRJaLuazsi6xN0E1A76nSwkzmF9HFkq4oLmSGKdC WBlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FpF3qnWO3wE3bigGFIt+UgfxHOE4N05RmSfjehaOpHw=; b=FqC5CoEW+S6z+WGnrJO+Y6+ol5wxEHhmA95n/67KLaB/fI/FSUPmpdtboxBnemjYe8 4t4xrRVwif+Sa+wvj3FHq4dQfr7RX0gkUBiNIiXW3JiiCQ3QSf9qlwdHNeyCk8Mh5XAM QnAe/MXO3DXnIdVRMvy2Dkj9zmtQmA2daj+qPbABx7cJM4sd0Ur/wNaneyjTfLox4kN3 ZmsfJY71VPf48rvpIaI5Mc6k8hbNagZPaajoCsAk9H4bh+j3tD3de0B2VP9Y6Yyf9lGQ wkNghCZomV3d9ngaP2YLCfwd5bIfHd2U11cFtoCJDLVkLw0ac06hzsDcUdBPkouZV15m K1Fg== X-Gm-Message-State: AKaTC01f8JF8S8LuKh0B3t5RW7wXUNov4toW9duFLlfKpoKOZUIYzgy3AnAua7N0uG0IdQ== X-Received: by 10.46.33.65 with SMTP id h62mr8264325ljh.37.1480240890140; Sun, 27 Nov 2016 02:01:30 -0800 (PST) Received: from localhost (dsl-hkibrasgw2-58c368-70.dhcp.inet.fi. [88.195.104.70]) by smtp.gmail.com with ESMTPSA id u203sm11329548lff.37.2016.11.27.02.01.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Nov 2016 02:01:29 -0800 (PST) From: Jani Nikula To: David Bremner , notmuch@notmuchmail.org Subject: [PATCH v2] test: check the handling of files vanishing between scandir and indexing Date: Sun, 27 Nov 2016 11:59:34 +0200 Message-Id: <1480240774-21255-1-git-send-email-jani@nikula.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1480151898-17278-1-git-send-email-jani@nikula.org> References: <1480151898-17278-1-git-send-email-jani@nikula.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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, 27 Nov 2016 10:01:33 -0000 Add a file for scandir to find, but use gdb to remove it before it gets indexed. --- v2: Apparently our test setup is clever enough to gracefully handle missing prerequisites, and ignore subtest results. Just make sure we remove the test file also in case gdb isn't there, to not leave garbage behind. --- test/T050-new.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/T050-new.sh b/test/T050-new.sh index beeb574a3b30..2bc799d2e2bc 100755 --- a/test/T050-new.sh +++ b/test/T050-new.sh @@ -298,4 +298,38 @@ output=$(NOTMUCH_NEW --debug 2>&1 | sed 's/: .*$//' ) chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.${db_ending} test_expect_equal "$output" "A Xapian exception occurred opening database" + +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 add_file +commands +shell rm -f ${MAIL_DIR}/vanish +continue +end +run +EOF + +gdb --batch-silent --return-child-result -x notmuch-new-vanish.gdb \ + --args notmuch 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 +Error opening ${MAIL_DIR}/vanish: No such file or directory +exit status: 75 +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done -- 2.1.4