From patchwork Fri Oct 6 01:54:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 9988251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7BCBB60291 for ; Fri, 6 Oct 2017 01:56:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EECA28CE0 for ; Fri, 6 Oct 2017 01:56:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63B9028D53; Fri, 6 Oct 2017 01:56:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 178EB28CE0 for ; Fri, 6 Oct 2017 01:56:21 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 90DC121EA15BD; Thu, 5 Oct 2017 18:52:55 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=vishal.l.verma@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0D27B21EA15C8 for ; Thu, 5 Oct 2017 18:52:54 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Oct 2017 18:56:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,482,1500966000"; d="scan'208";a="143341409" Received: from omniknight.lm.intel.com ([10.232.112.27]) by orsmga002.jf.intel.com with ESMTP; 05 Oct 2017 18:56:15 -0700 From: Vishal Verma To: Subject: [ndctl PATCH 7/8] ndctl/test: update existing unit tests to use error-inject Date: Thu, 5 Oct 2017 19:54:04 -0600 Message-Id: <20171006015405.29908-8-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171006015405.29908-1-vishal.l.verma@intel.com> References: <20171006015405.29908-1-vishal.l.verma@intel.com> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Unitl now, various unit tests related to error handling used to expect 'canned' errors to be present in the middle of every nfit_test namespace. With the ACPI error injection patches for nfit_test, this is no longer the case. Update the existing unit tests it inject any errors they need for testing themselves using inject-error, rather than expecting canned errors. Cc: Dan Williams Signed-off-by: Vishal Verma --- test/clear.sh | 5 ++++- test/dax-errors.sh | 5 ++++- test/daxdev-errors.sh | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/test/clear.sh b/test/clear.sh index a60c3d9..13dcce0 100755 --- a/test/clear.sh +++ b/test/clear.sh @@ -54,7 +54,10 @@ eval $(echo $json | sed -e "$json2var") [ $dev = "x" ] && echo "fail: $LINENO" && exit 1 [ $mode != "raw" ] && echo "fail: $LINENO" && exit 1 -# check for expected errors in the middle of the namespace +# inject errors in the middle of the namespace, verify that reading fails +err_sector="$(((size/512) / 2))" +err_count=8 +$NDCTL inject-error --sector="$err_sector" --count=$err_count $dev read sector len < /sys/block/$blockdev/badblocks [ $((sector * 2)) -ne $((size /512)) ] && echo "fail: $LINENO" && exit 1 if dd if=/dev/$blockdev of=/dev/null iflag=direct bs=512 skip=$sector count=$len; then diff --git a/test/dax-errors.sh b/test/dax-errors.sh index 5af3859..ac56fb1 100755 --- a/test/dax-errors.sh +++ b/test/dax-errors.sh @@ -64,7 +64,10 @@ eval $(echo $json | sed -e "$json2var") [ $dev = "x" ] && echo "fail: $LINENO" && exit 1 [ $mode != "raw" ] && echo "fail: $LINENO" && exit 1 -# check for expected errors in the middle of the namespace +# inject errors in the middle of the namespace, verify that reading fails +err_sector="$(((size/512) / 2))" +err_count=8 +$NDCTL inject-error --sector="$err_sector" --count=$err_count $dev read sector len < /sys/block/$blockdev/badblocks [ $((sector * 2)) -ne $((size /512)) ] && echo "fail: $LINENO" && exit 1 if dd if=/dev/$blockdev of=/dev/null iflag=direct bs=512 skip=$sector count=$len; then diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh index 8115087..1ee9ad6 100755 --- a/test/daxdev-errors.sh +++ b/test/daxdev-errors.sh @@ -37,6 +37,7 @@ check_min_kver "4.12" || { echo "kernel $KVER lacks dax dev error handling"; exi set -e trap 'err $LINENO' ERR +rc=1 # setup (reset nfit_test dimms) modprobe nfit_test @@ -68,18 +69,28 @@ chardev=$(echo $json | jq ". | select(.mode == \"dax\") | .daxregion.devices[0]. # } #} +json1=$($NDCTL list $BUS --mode=dax --namespaces) +eval $(echo $json1 | sed -e "$json2var") +nsdev=$dev + json1=$($NDCTL list $BUS) eval $(echo $json1 | sed -e "$json2var") +busdev=$dev + +# inject errors in the middle of the namespace +err_sector="$(((size/512) / 2))" +err_count=8 +$NDCTL inject-error --sector="$err_sector" --count=$err_count $nsdev -read sector len < /sys/bus/platform/devices/nfit_test.0/$dev/$region/badblocks +read sector len < /sys/bus/nd/devices/$region/badblocks echo "sector: $sector len: $len" # run the daxdev-errors test test -x ./daxdev-errors -./daxdev-errors $dev $region +./daxdev-errors $busdev $region # check badblocks, should be empty -if read sector len < /sys/bus/platform/devices/nfit_test.0/$dev/$region/badblocks; then +if read sector len < /sys/bus/platform/devices/nfit_test.0/$busdev/$region/badblocks; then echo "badblocks empty, expected" fi [ -n "$sector" ] && echo "fail: $LINENO" && exit 1