From patchwork Thu May 4 21:49:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 9712801 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 0F1E160362 for ; Thu, 4 May 2017 21:49:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F16AD28699 for ; Thu, 4 May 2017 21:49:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6758286B1; Thu, 4 May 2017 21:49:29 +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 0D0E228699 for ; Thu, 4 May 2017 21:49:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 083CE21A134BB; Thu, 4 May 2017 14:49:29 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: 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 6146B21A134AE for ; Thu, 4 May 2017 14:49:28 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 May 2017 14:49:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.38,289,1491289200"; d="scan'208"; a="1164752385" Received: from djiang5-desk3.ch.intel.com ([143.182.137.38]) by fmsmga002.fm.intel.com with ESMTP; 04 May 2017 14:49:12 -0700 Subject: [PATCH v6 3/3] ndctl: add test for clear-error From: Dave Jiang To: dan.j.williams@intel.com Date: Thu, 04 May 2017 14:49:12 -0700 Message-ID: <149393455208.2642.112369988570724817.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <149393422747.2642.5136375594842641153.stgit@djiang5-desk3.ch.intel.com> References: <149393422747.2642.5136375594842641153.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 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: , Cc: linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Adding unit test for ndctl clear-error (and list-errors) Signed-off-by: Dave Jiang --- test/Makefile.am | 1 + test/ndctl-clear-error-dax.sh | 66 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100755 test/ndctl-clear-error-dax.sh diff --git a/test/Makefile.am b/test/Makefile.am index 9353a34..3cd159e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -10,6 +10,7 @@ TESTS =\ clear.sh \ dax-errors.sh \ daxdev-errors.sh \ + ndctl-clear-error-dax.sh \ btt-check.sh \ label-compat.sh \ blk-exhaust.sh diff --git a/test/ndctl-clear-error-dax.sh b/test/ndctl-clear-error-dax.sh new file mode 100755 index 0000000..1608db9 --- /dev/null +++ b/test/ndctl-clear-error-dax.sh @@ -0,0 +1,66 @@ +#!/bin/bash -x +DEV="" +NDCTL="../ndctl/ndctl" +BUS="-b nfit_test.0" +BUS1="-b nfit_test.1" +json2var="s/[{}\",]//g; s/:/=/g" +rc=77 + +check_min_kver() +{ + local ver="$1" + : "${KVER:=$(uname -r)}" + + [ -n "$ver" ] || return 1 + [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]] +} + +check_min_kver "4.12" || { echo "kernel $KVER lacks dax dev error handling"; exit $rc; } + +set -e + +err() { + echo "test/clear: failed at line $1" + exit $rc +} + +set -e +trap 'err $LINENO' ERR + +# setup (reset nfit_test dimms) +modprobe nfit_test +$NDCTL disable-region $BUS all +$NDCTL zero-labels $BUS all +$NDCTL enable-region $BUS all + +rc=1 + +query=". | sort_by(.available_size) | reverse | .[0].dev" +region=$($NDCTL list $BUS -t pmem -Ri | jq -r "$query") + +# create dax +chardev="x" +json=$($NDCTL create-namespace $BUS -r $region -t pmem -m dax -a 4096) +chardev=$(echo $json | jq -r ". | select(.mode == \"dax\") | .daxregion.devices[0].chardev") +[ $chardev = "x" ] && echo "fail: $LINENO" && exit 1 + +json1=$($NDCTL list $BUS) +eval $(sed -e "$json2var" <<< "$json1") + +read sector len <<< `$NDCTL list-errors -f /dev/$chardev` +echo "sector: $sector len: $len" + +# clearing using ndctl +$NDCTL clear-error -f /dev/$chardev -s $sector -l $len + +# check badblocks, should be empty +read sector len <<< `$NDCTL list-errors -f /dev/$chardev` +[ -n "$sector" ] && echo "fail: $LINENO" && exit 1 + +echo "badblocks empty, expected" + +$NDCTL disable-region $BUS all +$NDCTL disable-region $BUS1 all +modprobe -r nfit_test + +exit 0