From patchwork Mon Apr 18 17:10:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivaprasad G Bhat X-Patchwork-Id: 12816966 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48BCFA29 for ; Mon, 18 Apr 2022 17:10:12 +0000 (UTC) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23IEL1fR010106; Mon, 18 Apr 2022 17:10:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=xPEC9nWdoOqoqBKVu7LRDgzQ7HmM5576Kx9aFYz0W+M=; b=N0dbF6tMlK2LUhrTyiFJJGII396JufzC3De4q0D+sX+25uKxg27Do+Ft/yITPbHuHEZ9 52yZ/6Ax1Frl3h2xFya6ZtXmJk31UWdooACFDNaes5oPvKbO8OQtBooytapsyxcpv9xh s1y+tf/SO/dbIaI9D8A8E+SNsESO0BUNcyu6Im63AA9/ERZcD26yYL7ujUz3hkuffo+z b7TQEY1atkFs94H9G3D1OibaUXMcuT7nzILbRsrzzZfqquvoWAsHfE5XKyJnKWSE2mOu /z6K7YAxpxQJ6vT20EIATodLTNH59yDmlyxhB7fGjsyIyLDrGMnUUDbtomEol+Fp/GjR Zw== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7bt1jev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:10:10 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23IH2xAi002612; Mon, 18 Apr 2022 17:10:08 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3ffne931cw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:10:08 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23IHAGDJ64815596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Apr 2022 17:10:16 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 53C6BA404D; Mon, 18 Apr 2022 17:10:05 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 60E0EA4040; Mon, 18 Apr 2022 17:10:04 +0000 (GMT) Received: from lep8c.aus.stglabs.ibm.com (unknown [9.40.192.207]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 18 Apr 2022 17:10:04 +0000 (GMT) Subject: [RFC ndctl PATCH 1/9] test/common: Ensure to unload test modules From: Shivaprasad G Bhat To: nvdimm@lists.linux.dev, dan.j.williams@intel.com, vishal.l.verma@intel.com Cc: aneesh.kumar@linux.ibm.com, sbhat@linux.ibm.com, vaibhav@linux.ibm.com Date: Mon, 18 Apr 2022 12:10:03 -0500 Message-ID: <165030179767.3224737.3430509039595994936.stgit@lep8c.aus.stglabs.ibm.com> In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> References: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> User-Agent: StGit/1.1+40.g1b20 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: l-uSEnssAbXIp-Rj0QY55wTb1plIKMx7 X-Proofpoint-ORIG-GUID: l-uSEnssAbXIp-Rj0QY55wTb1plIKMx7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 phishscore=0 mlxlogscore=760 clxscore=1015 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180101 The _cleanup is easily missed to be called at places where trap ERR is set, ex security.sh. The patch moves all the modprobes into the _init in test/common and sets the trap on exit for "any" of the reasons to invoke _cleanup. The patch also gracefully skips the test if the module load fails instead of continuing, which otherwise makes the tests fail erroneously in random places during the tests. Signed-off-by: Shivaprasad G Bhat --- test/btt-check.sh | 3 +-- test/btt-errors.sh | 3 +-- test/btt-pad-compat.sh | 3 +-- test/clear.sh | 4 +--- test/common | 12 ++++++++++++ test/create.sh | 4 +--- test/daxdev-errors.sh | 4 +--- test/firmware-update.sh | 3 +-- test/inject-error.sh | 3 +-- test/inject-smart.sh | 3 +-- test/label-compat.sh | 4 +--- test/max_available_extent_ns.sh | 3 +-- test/monitor.sh | 3 +-- test/multi-dax.sh | 4 +--- test/pfn-meta-errors.sh | 3 +-- test/pmem-errors.sh | 3 +-- test/rescan-partitions.sh | 3 +-- test/sector-mode.sh | 4 +--- test/security.sh | 3 +-- test/track-uuid.sh | 3 +-- 20 files changed, 31 insertions(+), 44 deletions(-) diff --git a/test/btt-check.sh b/test/btt-check.sh index 65b5c58b..1039d0eb 100755 --- a/test/btt-check.sh +++ b/test/btt-check.sh @@ -150,10 +150,9 @@ do_tests() } # setup (reset nfit_test dimms, create the BTT namespace) -modprobe nfit_test +_init rc=1 reset && create do_tests reset -_cleanup exit 0 diff --git a/test/btt-errors.sh b/test/btt-errors.sh index 18518d50..ea1a6627 100755 --- a/test/btt-errors.sh +++ b/test/btt-errors.sh @@ -42,7 +42,7 @@ mkdir -p $MNT trap 'err $LINENO cleanup' ERR # setup (reset nfit_test dimms) -modprobe nfit_test +_init resetV rc=1 @@ -144,5 +144,4 @@ dd if=/dev/$blockdev of=/dev/null iflag=direct bs=4096 count=1 && err $LINENO || # done, exit reset cleanup -_cleanup exit 0 diff --git a/test/btt-pad-compat.sh b/test/btt-pad-compat.sh index 005316a2..de85fec7 100755 --- a/test/btt-pad-compat.sh +++ b/test/btt-pad-compat.sh @@ -172,11 +172,10 @@ do_tests() ns_info_wipe } -modprobe nfit_test +_init check_prereq xxd rc=1 reset do_tests reset -_cleanup exit 0 diff --git a/test/clear.sh b/test/clear.sh index c4d02d54..9b785e35 100755 --- a/test/clear.sh +++ b/test/clear.sh @@ -13,7 +13,7 @@ check_min_kver "4.6" || do_skip "lacks clear poison support" trap 'err $LINENO' ERR # setup (reset nfit_test dimms) -modprobe nfit_test +_init reset rc=1 @@ -72,6 +72,4 @@ if check_min_kver "4.9"; then fi fi -_cleanup - exit 0 diff --git a/test/common b/test/common index fb487958..d3216a0c 100644 --- a/test/common +++ b/test/common @@ -113,6 +113,18 @@ _cleanup() modprobe -r nfit_test } +_init() +{ + set +e + modprobe nfit_test + if [ $? -ne 0 ]; then + echo "Could not load the nfit_test module." + exit 77 + fi + set -e + trap _cleanup EXIT INT TERM HUP PIPE +} + # json2var # stdin: json # diff --git a/test/create.sh b/test/create.sh index 9a6f3733..c2fdee2e 100755 --- a/test/create.sh +++ b/test/create.sh @@ -14,7 +14,7 @@ check_min_kver "4.5" || do_skip "may lack namespace mode attribute" trap 'err $LINENO' ERR # setup (reset nfit_test dimms) -modprobe nfit_test +_init reset rc=1 @@ -40,6 +40,4 @@ eval $(echo $json | json2var) # free capacity for blk creation $NDCTL destroy-namespace -f $dev -_cleanup - exit 0 diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh index 7f797181..f32f8b80 100755 --- a/test/daxdev-errors.sh +++ b/test/daxdev-errors.sh @@ -14,7 +14,7 @@ check_prereq "jq" trap 'err $LINENO' ERR # setup (reset nfit_test dimms) -modprobe nfit_test +_init reset rc=1 @@ -71,6 +71,4 @@ if read sector len < /sys/bus/platform/devices/nfit_test.0/$busdev/$region/badbl fi [ -n "$sector" ] && echo "fail: $LINENO" && exit 1 -_cleanup - exit 0 diff --git a/test/firmware-update.sh b/test/firmware-update.sh index 93ce166e..1fac9dc1 100755 --- a/test/firmware-update.sh +++ b/test/firmware-update.sh @@ -70,11 +70,10 @@ do_tests() check_min_kver "4.16" || do_skip "may lack firmware update test handling" -modprobe nfit_test +_init fwupd_reset detect rc=1 do_tests rm -f $image -_cleanup exit 0 diff --git a/test/inject-error.sh b/test/inject-error.sh index fd823b6c..15d0dbe8 100755 --- a/test/inject-error.sh +++ b/test/inject-error.sh @@ -79,10 +79,9 @@ do_tests() check_status } -modprobe nfit_test +_init rc=1 reset && create do_tests reset -_cleanup exit 0 diff --git a/test/inject-smart.sh b/test/inject-smart.sh index 046322bf..80af058a 100755 --- a/test/inject-smart.sh +++ b/test/inject-smart.sh @@ -167,7 +167,7 @@ do_tests() check_min_kver "4.19" || do_skip "kernel $KVER may not support smart (un)injection" check_prereq "jq" -modprobe nfit_test +_init rc=1 jlist=$($TEST_PATH/list-smart-dimm -b $bus) @@ -175,5 +175,4 @@ dimm="$(jq '.[]."dev"?, ."dev"?' <<< $jlist | sort | head -1 | xargs)" test -n "$dimm" do_tests -_cleanup exit 0 diff --git a/test/label-compat.sh b/test/label-compat.sh index 7ae4d5ef..4ccf69fa 100755 --- a/test/label-compat.sh +++ b/test/label-compat.sh @@ -15,7 +15,7 @@ check_prereq "jq" trap 'err $LINENO' ERR # setup (reset nfit_test dimms) -modprobe nfit_test +_init $NDCTL disable-region -b $NFIT_TEST_BUS0 all $NDCTL init-labels -f -b $NFIT_TEST_BUS0 all @@ -43,6 +43,4 @@ if [ -z $len ]; then exit 1 fi -_cleanup - exit 0 diff --git a/test/max_available_extent_ns.sh b/test/max_available_extent_ns.sh index 47a921f5..98235424 100755 --- a/test/max_available_extent_ns.sh +++ b/test/max_available_extent_ns.sh @@ -31,9 +31,8 @@ do_test() $NDCTL create-namespace -r $region -t pmem } -modprobe nfit_test +_init rc=1 reset do_test -_cleanup exit 0 diff --git a/test/monitor.sh b/test/monitor.sh index e58c908b..10e65374 100755 --- a/test/monitor.sh +++ b/test/monitor.sh @@ -161,10 +161,9 @@ do_tests() test_filter_dimmevent } -modprobe nfit_test +_init rc=1 reset set_smart_supported_bus do_tests -_cleanup exit 0 diff --git a/test/multi-dax.sh b/test/multi-dax.sh index 04070adb..2b21c28c 100755 --- a/test/multi-dax.sh +++ b/test/multi-dax.sh @@ -16,7 +16,7 @@ trap 'err $LINENO' ERR ALIGN_SIZE=`getconf PAGESIZE` # setup (reset nfit_test dimms) -modprobe nfit_test +_init reset rc=1 @@ -28,6 +28,4 @@ chardev1=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M) chardev2=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev") -_cleanup - exit 0 diff --git a/test/pfn-meta-errors.sh b/test/pfn-meta-errors.sh index 63148979..ccf5b7a1 100755 --- a/test/pfn-meta-errors.sh +++ b/test/pfn-meta-errors.sh @@ -28,7 +28,7 @@ set -e trap 'err $LINENO' ERR # setup (reset nfit_test dimms) -modprobe nfit_test +_init reset rc=1 @@ -67,5 +67,4 @@ if read -r sector len < "/sys/block/$raw_bdev/badblocks"; then false fi -_cleanup exit 0 diff --git a/test/pmem-errors.sh b/test/pmem-errors.sh index 9a59c25d..550114ac 100755 --- a/test/pmem-errors.sh +++ b/test/pmem-errors.sh @@ -25,7 +25,7 @@ mkdir -p $MNT trap 'err $LINENO cleanup' ERR # setup (reset nfit_test dimms) -modprobe nfit_test +_init reset rc=1 @@ -110,6 +110,5 @@ echo $((start_sect + 1)) 1 > /sys/block/$blockdev/badblocks dd if=$MNT/$FILE of=/dev/null iflag=direct bs=4096 count=1 && err $LINENO || true cleanup -_cleanup exit 0 diff --git a/test/rescan-partitions.sh b/test/rescan-partitions.sh index 51bbd731..f46e17ed 100755 --- a/test/rescan-partitions.sh +++ b/test/rescan-partitions.sh @@ -65,11 +65,10 @@ test_mode() $NDCTL destroy-namespace $dev } -modprobe nfit_test +_init rc=1 reset test_mode "raw" test_mode "fsdax" test_mode "sector" -_cleanup exit 0 diff --git a/test/sector-mode.sh b/test/sector-mode.sh index f70b0f17..d4a62bf3 100755 --- a/test/sector-mode.sh +++ b/test/sector-mode.sh @@ -14,7 +14,7 @@ trap 'err $LINENO' ERR ALIGN_SIZE=`getconf PAGESIZE` # setup (reset nfit_test dimms) -modprobe nfit_test +_init reset reset1 @@ -27,6 +27,4 @@ NAMESPACE=$($NDCTL create-namespace --no-autolabel -r $REGION -m sector -f -l 4K $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a $ALIGN_SIZE $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K -_cleanup - exit 0 diff --git a/test/security.sh b/test/security.sh index 34c4977b..7ae6e88c 100755 --- a/test/security.sh +++ b/test/security.sh @@ -246,7 +246,7 @@ if [ "$uid" -ne 0 ]; then do_skip "run as root or with a sudo login shell for test to work" fi -modprobe nfit_test +_init setup check_prereq "keyctl" rc=1 @@ -275,5 +275,4 @@ test_6_load_keys test_cleanup post_cleanup -_cleanup exit 0 diff --git a/test/track-uuid.sh b/test/track-uuid.sh index a967d0e4..954afe7c 100755 --- a/test/track-uuid.sh +++ b/test/track-uuid.sh @@ -11,7 +11,7 @@ set -e trap 'err $LINENO' ERR # setup (reset nfit_test dimms) -modprobe nfit_test +_init reset rc=1 @@ -34,5 +34,4 @@ $NDCTL disable-namespace $dev uuidgen > /sys/bus/nd/devices/$dev/uuid $NDCTL enable-namespace $dev -_cleanup exit 0 From patchwork Mon Apr 18 17:10:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivaprasad G Bhat X-Patchwork-Id: 12816967 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB46DA29 for ; Mon, 18 Apr 2022 17:10:25 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23IGIiK0016996; Mon, 18 Apr 2022 17:10:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=OsEke/7OB8/xkVaFAhd/D0jZL1z6mL5+MBiR2jh4bBQ=; b=XjpL9qn7a0rVxgpLPW8WQhbUEK8bOThaPCDVtHnVyYZeqML4xFz647L5KLiqInXlDcEq mOsa+8Ko+NL60Rcru6xd0nHTVenrXecxSW7A0s04X/UlgmfKfPLQmEvD2F4PuTjmvN2d M/i229+bDfvcfzohpLHK0/CSlBfQutYJxVP75+AaUYdtMvL5zHFdVHrdjh8S4hZ6Jb+Y IUjWWpNN5sXXbv0Q7vBd8QUhDTDNd6nFGMTmspXtA1GKF0fyCaHZSouTLQBhK67iI6wC ss53yBgLHnRL+GDHbGKlHKkm4ko49y0S5l1B7qjLiCTCndVcyiDmsEojMcRGnWE5itU3 2w== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7d6s7ef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:10:24 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23IH2pUY027218; Mon, 18 Apr 2022 17:10:21 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma01fra.de.ibm.com with ESMTP id 3ffne8tdfe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:10:21 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23IHAI9w37945758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Apr 2022 17:10:18 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FD9542047; Mon, 18 Apr 2022 17:10:18 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 746264203F; Mon, 18 Apr 2022 17:10:17 +0000 (GMT) Received: from lep8c.aus.stglabs.ibm.com (unknown [9.40.192.207]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 18 Apr 2022 17:10:17 +0000 (GMT) Subject: [RFC ndctl PATCH 2/9] test: core: Fix module unload failures From: Shivaprasad G Bhat To: nvdimm@lists.linux.dev, dan.j.williams@intel.com, vishal.l.verma@intel.com Cc: aneesh.kumar@linux.ibm.com, sbhat@linux.ibm.com, vaibhav@linux.ibm.com Date: Mon, 18 Apr 2022 12:10:16 -0500 Message-ID: <165030181048.3224737.7100905803654677976.stgit@lep8c.aus.stglabs.ibm.com> In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> References: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> User-Agent: StGit/1.1+40.g1b20 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 58wJGlHTaJb70Rx-FKjo5fKgxXIW4hCX X-Proofpoint-GUID: 58wJGlHTaJb70Rx-FKjo5fKgxXIW4hCX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 spamscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180101 The kmod_module_remove_module() called by the tests without disabling the regions from the test provider. So, the module remove fails during many of the tests. The patch writes a wrapper which properly disables the test provider specific regions before calling the kmod_module_remove_module(). Signed-off-by: Shivaprasad G Bhat --- test.h | 2 ++ test/ack-shutdown-count-set.c | 4 ++-- test/core.c | 28 ++++++++++++++++++++++++++++ test/dsm-fail.c | 4 ++-- test/libndctl.c | 3 +-- test/pmem_namespaces.c | 23 ++++++----------------- 6 files changed, 41 insertions(+), 23 deletions(-) diff --git a/test.h b/test.h index b2267e66..6cff4189 100644 --- a/test.h +++ b/test.h @@ -23,6 +23,8 @@ struct kmod_module; int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, struct ndctl_ctx *nd_ctx, int log_level, struct ndctl_test *test); +int ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod, + struct ndctl_ctx *nd_ctx); struct ndctl_ctx; int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx); diff --git a/test/ack-shutdown-count-set.c b/test/ack-shutdown-count-set.c index f091a404..2d77aa07 100644 --- a/test/ack-shutdown-count-set.c +++ b/test/ack-shutdown-count-set.c @@ -109,9 +109,9 @@ static int test_ack_shutdown_count_set(int loglevel, struct ndctl_test *test, } result = do_test(ctx, test); - kmod_module_remove_module(mod, 0); - kmod_unref(kmod_ctx); + ndctl_test_module_remove(&kmod_ctx, &mod, ctx); + return result; } diff --git a/test/core.c b/test/core.c index 5d1aa237..7b23e258 100644 --- a/test/core.c +++ b/test/core.c @@ -107,6 +107,34 @@ int ndctl_test_get_skipped(struct ndctl_test *test) return test->skip; } +void ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod, + struct ndctl_ctx *nd_ctx) +{ + struct ndctl_bus *bus; + int rc; + + ndctl_bus_foreach(nd_ctx, bus) { + struct ndctl_region *region; + + if ((strcmp(ndctl_bus_get_provider(bus), + "nfit_test.0") != 0) && + strcmp(ndctl_bus_get_provider(bus), + "nfit_test.1") != 0) + continue; + + ndctl_region_foreach(bus, region) + ndctl_region_disable_invalidate(region); + } + + rc = kmod_module_remove_module(*mod, 0); + if (rc < 0 && rc != -ENOENT) { + fprintf(stderr, "couldn't remove module %s\n", + strerror(-rc)); + } + + kmod_unref(*ctx); +} + int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, struct ndctl_ctx *nd_ctx, int log_level, struct ndctl_test *test) diff --git a/test/dsm-fail.c b/test/dsm-fail.c index 5b443dcd..65ac2bd4 100644 --- a/test/dsm-fail.c +++ b/test/dsm-fail.c @@ -356,9 +356,9 @@ int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) } result = do_test(ctx, test); - kmod_module_remove_module(mod, 0); - kmod_unref(kmod_ctx); + ndctl_test_module_remove(&kmod_ctx, &mod, ctx); + return result; } diff --git a/test/libndctl.c b/test/libndctl.c index 51245cf4..df61f84c 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -2612,8 +2612,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) if (i >= ARRAY_SIZE(do_test)) result = EXIT_SUCCESS; - kmod_module_remove_module(mod, 0); - kmod_unref(kmod_ctx); + ndctl_test_module_remove(&kmod_ctx, &mod, ctx); return result; } diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c index 4bafff51..64207020 100644 --- a/test/pmem_namespaces.c +++ b/test/pmem_namespaces.c @@ -198,7 +198,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test, rc = 77; ndctl_test_skip(test); fprintf(stderr, "nfit_test unavailable skipping tests\n"); - goto err_module; + goto exit; } } @@ -214,7 +214,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test, if (rc < 0) { fprintf(stderr, "failed to zero %s\n", ndctl_dimm_get_devname(dimm)); - goto err; + goto exit; } } @@ -228,14 +228,14 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test, if (!pmem_region || ndctl_region_enable(pmem_region) < 0) { fprintf(stderr, "%s: failed to find PMEM region\n", comm); rc = -ENODEV; - goto err; + goto exit; } rc = -ENODEV; ndns = create_pmem_namespace(pmem_region); if (!ndns) { fprintf(stderr, "%s: failed to create PMEM namespace\n", comm); - goto err; + goto exit; } sprintf(bdev, "/dev/%s", ndctl_namespace_get_block_device(ndns)); @@ -243,20 +243,9 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test, disable_pmem_namespace(ndns); - err: - /* unload nfit_test */ - bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); - if (bus) - ndctl_region_foreach(bus, region) - ndctl_region_disable_invalidate(region); - bus = ndctl_bus_get_by_provider(ctx, "nfit_test.1"); - if (bus) - ndctl_region_foreach(bus, region) - ndctl_region_disable_invalidate(region); - kmod_module_remove_module(mod, 0); + exit: + ndctl_test_module_remove(&kmod_ctx, &mod, ctx); - err_module: - kmod_unref(kmod_ctx); return rc; } From patchwork Mon Apr 18 17:10:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivaprasad G Bhat X-Patchwork-Id: 12816968 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B48B2A29 for ; Mon, 18 Apr 2022 17:10:40 +0000 (UTC) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23IE6bCc031025; Mon, 18 Apr 2022 17:10:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=F2nWhvq2+3uzn1bXyzy+0hpw7AESjVQ/xhUoZ7gi6bM=; b=loye6H+HZXjGBTogLXZ5+fU26VoglnORQpd27bqu8nXrmp4+yq7xJ8exsWQ+pTuwv4Os /s4ODVCVto+IQICLwkojqkZUzvNbzimHi9tUm/kc8JnbHHSDBC1INfhhuTmGahcbgrv6 X34GfyMshpdjWfC/pgpURzgMuGoMhb3kDHmdtiQpCqm4I1+jD9H/5zrE51aHyChbw7o1 Qdk5Cx373VJ810pECh0KNyO4Gip3PJqpced3Vl79mdeFp53xz/RB5mvHlpEJLGHbXt/O q+z2d/N1ndf7NWB9vczhwHTd3SXV6EX14Zxfjb6ErsfxW4x6ldrUdf6T/YWseFF6Apcl 5A== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 3ffpdxq2k7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:10:37 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23IH33DY002629; Mon, 18 Apr 2022 17:10:36 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04ams.nl.ibm.com with ESMTP id 3ffne931d8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:10:35 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23IGvnpk54133042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Apr 2022 16:57:49 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4CDAAE056; Mon, 18 Apr 2022 17:10:32 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0932AAE045; Mon, 18 Apr 2022 17:10:32 +0000 (GMT) Received: from lep8c.aus.stglabs.ibm.com (unknown [9.40.192.207]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 18 Apr 2022 17:10:31 +0000 (GMT) Subject: [RFC ndctl PATCH 3/9] test: Unload the nfit module during cleanup From: Shivaprasad G Bhat To: nvdimm@lists.linux.dev, dan.j.williams@intel.com, vishal.l.verma@intel.com Cc: aneesh.kumar@linux.ibm.com, sbhat@linux.ibm.com, vaibhav@linux.ibm.com Date: Mon, 18 Apr 2022 12:10:31 -0500 Message-ID: <165030182353.3224737.2306830041576864838.stgit@lep8c.aus.stglabs.ibm.com> In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> References: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> User-Agent: StGit/1.1+40.g1b20 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: YJtVsudiLCO04prmBEFDaO43fRiQnuxD X-Proofpoint-GUID: YJtVsudiLCO04prmBEFDaO43fRiQnuxD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 priorityscore=1501 suspectscore=0 adultscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180101 The nfit module which is needed for nfit_test is probed and is never unloaded. The future patches attempt to load the ndtest modules and continue the tests for PAPR family. Let there be clean state, so unload it. Signed-off-by: Shivaprasad G Bhat --- test/common | 7 +++++++ test/core.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/test/common b/test/common index d3216a0c..d2cb3f73 100644 --- a/test/common +++ b/test/common @@ -31,6 +31,10 @@ if [ -z $TEST_PATH ]; then export TEST_PATH=. fi +if [ ! -v NDCTL_TEST_FAMILY ]; then + export NDCTL_TEST_FAMILY=INTEL +fi + # NFIT_TEST_BUS[01] # NFIT_TEST_BUS0="nfit_test.0" @@ -111,6 +115,9 @@ _cleanup() $NDCTL disable-region -b $NFIT_TEST_BUS0 all $NDCTL disable-region -b $NFIT_TEST_BUS1 all modprobe -r nfit_test + if [ $NDCTL_TEST_FAMILY == "INTEL" ]; then + modprobe -r nfit + fi } _init() diff --git a/test/core.c b/test/core.c index 7b23e258..bc7542aa 100644 --- a/test/core.c +++ b/test/core.c @@ -130,8 +130,22 @@ void ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod, if (rc < 0 && rc != -ENOENT) { fprintf(stderr, "couldn't remove module %s\n", strerror(-rc)); + kmod_unref(*ctx); + return; } + rc = kmod_module_new_from_name(*ctx, "nfit", mod); + if (rc == 0) { + int state = kmod_module_get_initstate(*mod); + + if (state > 0) { + rc = kmod_module_remove_module(*mod, 0); + if (rc < 0) { + fprintf(stderr, "couldn't remove module %s\n", + strerror(-rc)); + } + } + } kmod_unref(*ctx); } From patchwork Mon Apr 18 17:10:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivaprasad G Bhat X-Patchwork-Id: 12816969 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DE7FA29 for ; Mon, 18 Apr 2022 17:10:52 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23IFg2CD020257; Mon, 18 Apr 2022 17:10:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=Jcch8HH6yAyXSsJ5muSXjcRVMAju0r1IkdEJnbTZeBM=; b=NzST7nSn0SlwBLAhhUZq4S/ZH9klBLEPegkpu+8ZkhOu8q4u5Vid/jC0VV/oFlIJHWp1 kStoHCSJqRLo2hFSls2PryqnHbZd3KaeZY3z6I5CVmf8+ZCusQnPaBCPsVzmhegVjei5 Fj0gGfWqFVX4ePDqFXJEdnsllLQNvvrEhZmVv+rt/VAOgD0JI4gywnjFjJAg+FqKQl2p oMrGgNtoog6cwrwLTKBJbUDuag0GgMdYX3HW8W7s2RBWSH4eZVrfm7XBh7eOtwwokGhv PGMdTDzb2tM/JURSuHHhIkVVSR/lkQtIPJZwzClWu3U6oCC1WUGOMuG8WGGEva7U9Ep0 eg== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fg75psujc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:10:49 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23IH2onP002587; Mon, 18 Apr 2022 17:10:47 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma02fra.de.ibm.com with ESMTP id 3fgu6u0vqk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:10:47 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23IHAiQT44892654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Apr 2022 17:10:44 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 35042AE045; Mon, 18 Apr 2022 17:10:44 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43ADAAE051; Mon, 18 Apr 2022 17:10:43 +0000 (GMT) Received: from lep8c.aus.stglabs.ibm.com (unknown [9.40.192.207]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 18 Apr 2022 17:10:43 +0000 (GMT) Subject: [RFC ndctl PATCH 4/9] test: Introduce skip file to skip irrelevant tests From: Shivaprasad G Bhat To: nvdimm@lists.linux.dev, dan.j.williams@intel.com, vishal.l.verma@intel.com Cc: aneesh.kumar@linux.ibm.com, sbhat@linux.ibm.com, vaibhav@linux.ibm.com Date: Mon, 18 Apr 2022 12:10:42 -0500 Message-ID: <165030183808.3224737.13932338864318081260.stgit@lep8c.aus.stglabs.ibm.com> In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> References: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> User-Agent: StGit/1.1+40.g1b20 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: uT166OY8AmyI2bKtwQYnrE2r7IAceJ6b X-Proofpoint-GUID: uT166OY8AmyI2bKtwQYnrE2r7IAceJ6b X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180101 Having a skip file containing the list of tests to be skipped on a given platform is useful to avoid false negatives when running the tests on multiple platforms. The meson sets the specific environment variables during test. Tests when run under meson or with these specific env variables, are supposed to check the skip_INTEL|PAPR.js file and decide if the current test is to skipped or not. The json file format is chosen for the skip file as the current ndctl code base already has the json dependencies linked to the sources. The patch also adds the PAPR specific skip_PAPR.js file to skip all the irrelevant and failing tests on the ndtest module. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Vaibhav Jain --- ndctl/bat.c | 4 +-- ndctl/test.c | 4 +-- test.h | 4 +-- test/ack-shutdown-count-set.c | 2 + test/common | 10 +++++++ test/core.c | 62 ++++++++++++++++++++++++++++++++++++++++- test/dax-dev.c | 2 + test/dax-pmd.c | 2 + test/device-dax.c | 2 + test/dsm-fail.c | 2 + test/libndctl.c | 2 + test/meson.build | 1 + test/pmem_namespaces.c | 2 + test/revoke-devmem.c | 2 + test/skip_PAPR.js | 34 ++++++++++++++++++++++ 15 files changed, 120 insertions(+), 15 deletions(-) create mode 100644 test/skip_PAPR.js diff --git a/ndctl/bat.c b/ndctl/bat.c index 13e964dc..53e9d951 100644 --- a/ndctl/bat.c +++ b/ndctl/bat.c @@ -32,9 +32,9 @@ int cmd_bat(int argc, const char **argv, struct ndctl_ctx *ctx) usage_with_options(u, options); if (force) - test = ndctl_test_new(UINT_MAX); + test = ndctl_test_new(UINT_MAX, argv[0]); else - test = ndctl_test_new(0); + test = ndctl_test_new(0, argv[0]); if (!test) { fprintf(stderr, "failed to initialize test\n"); diff --git a/ndctl/test.c b/ndctl/test.c index a0f5bc95..43b8c383 100644 --- a/ndctl/test.c +++ b/ndctl/test.c @@ -42,9 +42,9 @@ int cmd_test(int argc, const char **argv, struct ndctl_ctx *ctx) usage_with_options(u, options); if (force) - test = ndctl_test_new(UINT_MAX); + test = ndctl_test_new(UINT_MAX, argv[0]); else - test = ndctl_test_new(0); + test = ndctl_test_new(0, argv[0]); if (!test) return EXIT_FAILURE; diff --git a/test.h b/test.h index 6cff4189..cb61e0d9 100644 --- a/test.h +++ b/test.h @@ -6,7 +6,7 @@ struct ndctl_test; struct ndctl_ctx; -struct ndctl_test *ndctl_test_new(unsigned int kver); +struct ndctl_test *ndctl_test_new(unsigned int kver, const char *testname); int ndctl_test_result(struct ndctl_test *test, int rc); int ndctl_test_get_skipped(struct ndctl_test *test); int ndctl_test_get_attempted(struct ndctl_test *test); @@ -23,7 +23,7 @@ struct kmod_module; int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, struct ndctl_ctx *nd_ctx, int log_level, struct ndctl_test *test); -int ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod, +void ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod, struct ndctl_ctx *nd_ctx); struct ndctl_ctx; diff --git a/test/ack-shutdown-count-set.c b/test/ack-shutdown-count-set.c index 2d77aa07..5d38ad9d 100644 --- a/test/ack-shutdown-count-set.c +++ b/test/ack-shutdown-count-set.c @@ -118,7 +118,7 @@ static int test_ack_shutdown_count_set(int loglevel, struct ndctl_test *test, int main(int argc, char *argv[]) { char *test_env = getenv("NDCTL_TEST_FAMILY"); - struct ndctl_test *test = ndctl_test_new(0); + struct ndctl_test *test = ndctl_test_new(0, argv[0]); struct ndctl_ctx *ctx; int rc; diff --git a/test/common b/test/common index d2cb3f73..31395ece 100644 --- a/test/common +++ b/test/common @@ -35,6 +35,16 @@ if [ ! -v NDCTL_TEST_FAMILY ]; then export NDCTL_TEST_FAMILY=INTEL fi +if [ -f "$(dirname $0)/skip_${NDCTL_TEST_FAMILY}.js" ]; then + length=$(cat $(dirname $0)/skip_${NDCTL_TEST_FAMILY}.js |\ + sed 's|//.*||' | jq length) + for (( i=0; i #include #include +#include +#include #include #include @@ -39,9 +41,67 @@ static unsigned int get_system_kver(void) return KERNEL_VERSION(a,b,c); } -struct ndctl_test *ndctl_test_new(unsigned int kver) +static bool skip_current_test(char *skip_file, const char *curtest) +{ + FILE *fp; + char buffer[16384]; //16k large enough for file with comments + const char *curtestname = basename(curtest); + struct json_object *skip_array; + struct json_object *test; + const char *testname; + size_t i, size; + + fp = fopen(skip_file, "r"); + if (fp == NULL) { + fprintf(stderr, "Failed to open the %s file. Ignore, and continue..\n", skip_file); + return false; + } + + size = fread(buffer, 1, 16384, fp); + if (size == 0) { + fprintf(stderr, "Failed to read the %s file. Ignore, and continue..\n", skip_file); + return false; + } + fclose(fp); + + skip_array = json_tokener_parse(buffer); + if (json_object_get_type(skip_array) != json_type_array) { + fprintf(stderr, "Failed to parse the %s file. Ignore, and continue..\n", skip_file); + return false; + } + + for (i = 0; i < json_object_array_length(skip_array); i++) { + test = json_object_array_get_idx(skip_array, i); + testname = json_object_get_string(test); + if (testname && strcmp(curtestname, testname) == 0) + return true; + } + + return false; +} + +struct ndctl_test *ndctl_test_new(unsigned int kver, const char *testpath) { struct ndctl_test *test = calloc(1, sizeof(*test)); + const char *data_path = getenv("DATA_PATH"); + const char *test_family = getenv("NDCTL_TEST_FAMILY"); + char *skip_file = NULL; + + if (test_family && data_path && + (asprintf(&skip_file, "%s/skip_%s.js", data_path, test_family) < 0)) { + fprintf(stderr, "test : allocation failed\n"); + free(test); + return NULL; + } + + if (skip_file && + (access(skip_file, F_OK) == 0) && + skip_current_test(skip_file, testpath)) { + fprintf(stderr, "test : skip requested in the skip_%s.js\n", + test_family); + ndctl_test_skip(test); + exit(ndctl_test_result(test, 77)); + } if (!test) return NULL; diff --git a/test/dax-dev.c b/test/dax-dev.c index 6a1b76d6..2c9b6156 100644 --- a/test/dax-dev.c +++ b/test/dax-dev.c @@ -118,7 +118,7 @@ static int emit_e820_device(int loglevel, struct ndctl_test *test) int __attribute__((weak)) main(int argc, char *argv[]) { - struct ndctl_test *test = ndctl_test_new(0); + struct ndctl_test *test = ndctl_test_new(0, argv[0]); int rc; if (!test) { diff --git a/test/dax-pmd.c b/test/dax-pmd.c index f8408759..7f74ea03 100644 --- a/test/dax-pmd.c +++ b/test/dax-pmd.c @@ -358,7 +358,7 @@ err_mmap: int __attribute__((weak)) main(int argc, char *argv[]) { - struct ndctl_test *test = ndctl_test_new(0); + struct ndctl_test *test = ndctl_test_new(0, argv[0]); int fd, rc; if (!test) { diff --git a/test/device-dax.c b/test/device-dax.c index 49c9bc8b..14ea2f82 100644 --- a/test/device-dax.c +++ b/test/device-dax.c @@ -423,7 +423,7 @@ static int test_device_dax(int loglevel, struct ndctl_test *test, int __attribute__((weak)) main(int argc, char *argv[]) { - struct ndctl_test *test = ndctl_test_new(0); + struct ndctl_test *test = ndctl_test_new(0, argv[0]); struct ndctl_ctx *ctx; int rc; diff --git a/test/dsm-fail.c b/test/dsm-fail.c index 65ac2bd4..e7a35ca6 100644 --- a/test/dsm-fail.c +++ b/test/dsm-fail.c @@ -364,7 +364,7 @@ int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) int __attribute__((weak)) main(int argc, char *argv[]) { - struct ndctl_test *test = ndctl_test_new(0); + struct ndctl_test *test = ndctl_test_new(0, argv[0]); struct ndctl_ctx *ctx; int rc; diff --git a/test/libndctl.c b/test/libndctl.c index df61f84c..de95c83e 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -2618,7 +2618,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) int __attribute__((weak)) main(int argc, char *argv[]) { - struct ndctl_test *test = ndctl_test_new(0); + struct ndctl_test *test = ndctl_test_new(0, argv[0]); struct ndctl_ctx *ctx; int rc; diff --git a/test/meson.build b/test/meson.build index 07a5bb6e..395b5333 100644 --- a/test/meson.build +++ b/test/meson.build @@ -9,6 +9,7 @@ libndctl_deps = [ daxctl_dep, uuid, kmod, + json, ] ndctl_deps = libndctl_deps + [ diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c index 64207020..f3a00c79 100644 --- a/test/pmem_namespaces.c +++ b/test/pmem_namespaces.c @@ -251,7 +251,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test, int __attribute__((weak)) main(int argc, char *argv[]) { - struct ndctl_test *test = ndctl_test_new(0); + struct ndctl_test *test = ndctl_test_new(0, argv[0]); struct ndctl_ctx *ctx; int rc; diff --git a/test/revoke-devmem.c b/test/revoke-devmem.c index 59d1a72d..c0d84e8b 100644 --- a/test/revoke-devmem.c +++ b/test/revoke-devmem.c @@ -124,7 +124,7 @@ out_devmem: int main(int argc, char *argv[]) { - struct ndctl_test *test = ndctl_test_new(0); + struct ndctl_test *test = ndctl_test_new(0, argv[0]); struct ndctl_ctx *ctx; int rc; diff --git a/test/skip_PAPR.js b/test/skip_PAPR.js new file mode 100644 index 00000000..367257c4 --- /dev/null +++ b/test/skip_PAPR.js @@ -0,0 +1,34 @@ +// List of tests to be skipped on ndtest +// +// Append new test cases to this array below until support is added on ndtest. +// +["clear.sh", // No error injection support on PPC. + "daxdev-errors.sh", // "" + "inject-error.sh", // "" + "pfn-meta-errors.sh", // "" + "pmem-errors.sh", // "" + "btt-errors.sh", // "" + "label-compat.sh", // Legacy namespace support test/irrelavent on + // ndtest. + "security.sh", // No support on PPC yet. + "daxctl-create.sh", // Depends on dax_hmem + "sub-section.sh", // Tests using nd_e820, either duplication when + // running on INTEL host, or cannot be tested on + // PPC host. + "dax-dev", // "" + "device-dax", // "" + "device-dax-fio.sh", // "" + "dax-ext4.sh", // "" + "dax-xfs.sh", // "" + "daxctl-devices.sh", // "" + "revoke_devmem", // "" + "align.sh", // "" + "dm.sh", // "" + "mmap.sh", // "" + "monitor.sh", // To be fixed + "inject-smart.sh", // "" + "libndctl" // "" +] + +// NOTE: The libjson-c doesn't like comments in json files, so keep the file +// extension as .js to pacify. From patchwork Mon Apr 18 17:10:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivaprasad G Bhat X-Patchwork-Id: 12816970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B434A30 for ; Mon, 18 Apr 2022 17:11:04 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23IEHTIu010782; Mon, 18 Apr 2022 17:11:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=C5iGUS6+LIhOpp8qDvVGzFWsIWbCdUEefphv1q7H+Pg=; b=FXYdUG5YBMoXL/OqDNi11vdKw00oqCPGYDBCP5jhDOJ1u54n4yUeBKlV2kaO/Hx/0Fl7 wIc06Gwb6vdD+BU/nclZW0BUqoSPXqhBxYRJC2bqDZtKUGLN2hmt0SfcXg6QpE7AdVaG rGGiRBLA/J1BKNlzMt3VX7moat7RouZnFWykZsjZW5Y7Sl7zWwdEfBvMY5L0cCVODHua Xk/c7kiUBk+TlscXxx1+ZigQ3BPvWD6DDsLoyHmRW6kBUEiqzUClDNyBlXWhMQYX8i8A 6ZIvqlfnUQhnG/jy5sttr5xk0PFo8I144/VV4op28cO0BxKYsjLGWay1Mr5L0cN4/vip RQ== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7vn93yn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:11:03 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23IH2q7A018068; Mon, 18 Apr 2022 17:11:00 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3ffne8k1kv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:11:00 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23IHAv0d46924234 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Apr 2022 17:10:57 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EAA4A4054; Mon, 18 Apr 2022 17:10:57 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BF6CA405C; Mon, 18 Apr 2022 17:10:56 +0000 (GMT) Received: from lep8c.aus.stglabs.ibm.com (unknown [9.40.192.207]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 18 Apr 2022 17:10:56 +0000 (GMT) Subject: [RFC ndctl PATCH 5/9] test: Assign provider name based on the test family From: Shivaprasad G Bhat To: nvdimm@lists.linux.dev, dan.j.williams@intel.com, vishal.l.verma@intel.com Cc: aneesh.kumar@linux.ibm.com, sbhat@linux.ibm.com, vaibhav@linux.ibm.com Date: Mon, 18 Apr 2022 12:10:55 -0500 Message-ID: <165030184936.3224737.4501499015485134399.stgit@lep8c.aus.stglabs.ibm.com> In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> References: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> User-Agent: StGit/1.1+40.g1b20 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: HUoRoKsbV6tvOJKpY7KTiAiIlD54KMF_ X-Proofpoint-GUID: HUoRoKsbV6tvOJKpY7KTiAiIlD54KMF_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180101 The provider name is used by test scripts in a hard-coded fashion like nfit_test.X today. With the kernel modules names being different per nvdimm family and the provider name too would change because of that. The patch reassigns the correct provider name based on the test family. The default family and the provider is set to INTEL to keep the original behaviour intact. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Vaibhav Jain --- test.h | 6 ++++++ test/ack-shutdown-count-set.c | 11 +++-------- test/core.c | 23 +++++++++++++++++++---- test/daxdev-errors.sh | 2 +- test/dsm-fail.c | 27 ++++++++++++++++++--------- test/libndctl.c | 8 ++++---- test/pmem_namespaces.c | 4 +++- 7 files changed, 54 insertions(+), 27 deletions(-) diff --git a/test.h b/test.h index cb61e0d9..7c7f620c 100644 --- a/test.h +++ b/test.h @@ -6,6 +6,12 @@ struct ndctl_test; struct ndctl_ctx; + +extern char TEST_PROVIDER0[15]; +extern char TEST_PROVIDER1[15]; +extern int ndctl_test_family; +void init_env(void); + struct ndctl_test *ndctl_test_new(unsigned int kver, const char *testname); int ndctl_test_result(struct ndctl_test *test, int rc); int ndctl_test_get_skipped(struct ndctl_test *test); diff --git a/test/ack-shutdown-count-set.c b/test/ack-shutdown-count-set.c index 5d38ad9d..d35ee717 100644 --- a/test/ack-shutdown-count-set.c +++ b/test/ack-shutdown-count-set.c @@ -56,7 +56,7 @@ static void reset_bus(struct ndctl_bus *bus) static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) { - struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); + struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, TEST_PROVIDER0); struct ndctl_dimm *dimm; struct ndctl_region *region; struct log_ctx log_ctx; @@ -117,17 +117,12 @@ static int test_ack_shutdown_count_set(int loglevel, struct ndctl_test *test, int main(int argc, char *argv[]) { - char *test_env = getenv("NDCTL_TEST_FAMILY"); struct ndctl_test *test = ndctl_test_new(0, argv[0]); struct ndctl_ctx *ctx; int rc; - if (!test) { - fprintf(stderr, "failed to initialize test\n"); - return EXIT_FAILURE; - } - - if (test_env && strcmp(test_env, "PAPR") == 0) + init_env(); + if (ndctl_test_family == NVDIMM_FAMILY_PAPR) return ndctl_test_result(test, 77); rc = ndctl_new(&ctx); diff --git a/test/core.c b/test/core.c index 130e4aed..f5cf6c82 100644 --- a/test/core.c +++ b/test/core.c @@ -24,6 +24,21 @@ struct ndctl_test { int skip; }; +char TEST_PROVIDER0[15] = "nfit_test.0"; +char TEST_PROVIDER1[15] = "nfit_test.1"; +int ndctl_test_family = NVDIMM_FAMILY_INTEL; + +void init_env(void) +{ + char *test_env = getenv("NDCTL_TEST_FAMILY"); + + if (test_env && strcmp(test_env, "PAPR") == 0) { + ndctl_test_family = NVDIMM_FAMILY_PAPR; + strcpy(TEST_PROVIDER0, "ndtest.0"); + strcpy(TEST_PROVIDER1, "ndtest.1"); + } +} + static unsigned int get_system_kver(void) { const char *kver = getenv("KVER"); @@ -177,9 +192,9 @@ void ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod, struct ndctl_region *region; if ((strcmp(ndctl_bus_get_provider(bus), - "nfit_test.0") != 0) && + TEST_PROVIDER0) != 0) && strcmp(ndctl_bus_get_provider(bus), - "nfit_test.1") != 0) + TEST_PROVIDER1) != 0) continue; ndctl_region_foreach(bus, region) @@ -360,7 +375,7 @@ retry: struct ndctl_region *region; if (strcmp(ndctl_bus_get_provider(bus), - "nfit_test.0") != 0) + TEST_PROVIDER0) != 0) continue; ndctl_region_foreach(bus, region) ndctl_region_disable_invalidate(region); @@ -386,7 +401,7 @@ retry: struct ndctl_region *region; struct ndctl_dimm *dimm; - if (strcmp(ndctl_bus_get_provider(bus), "nfit_test.0") != 0) + if (strcmp(ndctl_bus_get_provider(bus), TEST_PROVIDER0) != 0) continue; ndctl_region_foreach (bus, region) diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh index f32f8b80..d80a536c 100755 --- a/test/daxdev-errors.sh +++ b/test/daxdev-errors.sh @@ -66,7 +66,7 @@ test -x $TEST_PATH/daxdev-errors $TEST_PATH/daxdev-errors $busdev $region # check badblocks, should be empty -if read sector len < /sys/bus/platform/devices/nfit_test.0/$busdev/$region/badblocks; then +if read sector len < /sys/bus/platform/devices/$NFIT_TEST_BUS0/$busdev/$region/badblocks; then echo "badblocks empty, expected" fi [ -n "$sector" ] && echo "fail: $LINENO" && exit 1 diff --git a/test/dsm-fail.c b/test/dsm-fail.c index e7a35ca6..382d8da3 100644 --- a/test/dsm-fail.c +++ b/test/dsm-fail.c @@ -18,8 +18,6 @@ #include #include -#define DIMM_PATH "/sys/devices/platform/nfit_test.0/nfit_test_dimm/test_dimm0" - static int reset_bus(struct ndctl_bus *bus) { struct ndctl_region *region; @@ -176,10 +174,11 @@ static int test_regions_enable(struct ndctl_bus *bus, static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) { - struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); + struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, TEST_PROVIDER0); struct ndctl_region *region, *victim_region = NULL; struct ndctl_dimm *dimm, *victim = NULL; char path[1024], buf[SYSFS_ATTR_SIZE]; + char *dimm_path; struct log_ctx log_ctx; unsigned int handle; int rc, err = 0; @@ -197,7 +196,14 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) return -ENXIO; } - sprintf(path, "%s/handle", DIMM_PATH); + if (asprintf(&dimm_path, + "/sys/devices/platform/%s/nfit_test_dimm/test_dimm0", + TEST_PROVIDER0) < 0) { + fprintf(stderr, "Path allocation failed\n"); + return -ENOMEM; + } + + sprintf(path, "%s/handle", dimm_path); rc = __sysfs_read_attr(&log_ctx, path, buf); if (rc) { fprintf(stderr, "failed to retrieve test dimm handle\n"); @@ -280,7 +286,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) goto out; - rc = set_dimm_response(DIMM_PATH, ND_CMD_GET_CONFIG_SIZE, -EACCES, + rc = set_dimm_response(dimm_path, ND_CMD_GET_CONFIG_SIZE, -EACCES, &log_ctx); if (rc) goto out; @@ -290,7 +296,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) rc = test_regions_enable(bus, victim, victim_region, true, 2); if (rc) goto out; - rc = set_dimm_response(DIMM_PATH, ND_CMD_GET_CONFIG_SIZE, 0, &log_ctx); + rc = set_dimm_response(dimm_path, ND_CMD_GET_CONFIG_SIZE, 0, &log_ctx); if (rc) goto out; @@ -300,7 +306,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) if (rc) goto out; - rc = set_dimm_response(DIMM_PATH, ND_CMD_GET_CONFIG_DATA, -EACCES, + rc = set_dimm_response(dimm_path, ND_CMD_GET_CONFIG_DATA, -EACCES, &log_ctx); if (rc) goto out; @@ -311,7 +317,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) rc = test_regions_enable(bus, victim, victim_region, false, 0); if (rc) goto out; - rc = set_dimm_response(DIMM_PATH, ND_CMD_GET_CONFIG_DATA, 0, &log_ctx); + rc = set_dimm_response(dimm_path, ND_CMD_GET_CONFIG_DATA, 0, &log_ctx); if (rc) goto out; rc = dimms_disable(bus); @@ -320,7 +326,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) out: err = rc; - sprintf(path, "%s/fail_cmd", DIMM_PATH); + sprintf(path, "%s/fail_cmd", dimm_path); sprintf(buf, "0\n"); rc = __sysfs_write_attr(&log_ctx, path, buf); if (rc) @@ -333,6 +339,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) rc = -ENXIO; } reset_bus(bus); + free(dimm_path); if (rc) err = rc; @@ -368,6 +375,8 @@ int __attribute__((weak)) main(int argc, char *argv[]) struct ndctl_ctx *ctx; int rc; + init_env(); + if (!test) { fprintf(stderr, "failed to initialize test\n"); return EXIT_FAILURE; diff --git a/test/libndctl.c b/test/libndctl.c index de95c83e..ab9f73c9 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -73,8 +73,6 @@ * dimm. */ -static const char *NFIT_PROVIDER0 = "nfit_test.0"; -static const char *NFIT_PROVIDER1 = "nfit_test.1"; #define SZ_4K 0x00001000 #define SZ_128K 0x00020000 #define SZ_7M 0x00700000 @@ -2496,7 +2494,7 @@ static void reset_bus(struct ndctl_bus *bus, enum dimm_reset reset) static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test) { - struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER0); + struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, TEST_PROVIDER0); struct ndctl_region *region; int rc; @@ -2550,7 +2548,7 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test) static int do_test1(struct ndctl_ctx *ctx, struct ndctl_test *test) { - struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER1); + struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, TEST_PROVIDER1); int rc; if (!bus) @@ -2622,6 +2620,8 @@ int __attribute__((weak)) main(int argc, char *argv[]) struct ndctl_ctx *ctx; int rc; + init_env(); + if (!test) { fprintf(stderr, "failed to initialize test\n"); return EXIT_FAILURE; diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c index f3a00c79..973c9ce3 100644 --- a/test/pmem_namespaces.c +++ b/test/pmem_namespaces.c @@ -193,7 +193,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test, fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n"); rc = ndctl_test_init(&kmod_ctx, &mod, NULL, log_level, test); ndctl_invalidate(ctx); - bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); + bus = ndctl_bus_get_by_provider(ctx, TEST_PROVIDER0); if (rc < 0 || !bus) { rc = 77; ndctl_test_skip(test); @@ -255,6 +255,8 @@ int __attribute__((weak)) main(int argc, char *argv[]) struct ndctl_ctx *ctx; int rc; + init_env(); + comm = argv[0]; if (!test) { fprintf(stderr, "failed to initialize test\n"); From patchwork Mon Apr 18 17:11:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivaprasad G Bhat X-Patchwork-Id: 12816971 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 422C7A29 for ; Mon, 18 Apr 2022 17:11:20 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23IDwchX005167; Mon, 18 Apr 2022 17:11:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=86IsUsPYdo0u1q9rI6lvz0XvnVoT1JCkxr0dhMA+A3o=; b=IuLb5bdY5czpKzqOqqrmlPK8FahblrzcytjvhZ172eDPWD6DLY7/F1ERzGVgo2HRyzP5 4fQ5u0eD+wm8uNTZ06g009TzfB9NXEHLZeBot9j33ySDwoHjynluAVixmzmZHk+ovlwq ndavr67e/7C/WOM/OkzEJFO/93SU0mdEe4qoxX2qtR1s9Ff0GTzj1p8M5E9tVLjsrsHr H70o0LBodQg33c+6KkKoCLeOnSTkRfZ/5nspTekiziunwBqZ0UEVvktxljE9t5C2t1DI aBEwrwu9LH8Px+3S3a//zTQyx8ccKCv5KUCT0BHGZhNSnATDmTR67I7WhSLCkxFJqUZp LA== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7ek9mcv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:11:17 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23IH34Qu018103; Mon, 18 Apr 2022 17:11:16 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3ffne8k1m1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:11:15 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23IHBDfQ41091452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Apr 2022 17:11:13 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E747CA4051; Mon, 18 Apr 2022 17:11:12 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE15CA4040; Mon, 18 Apr 2022 17:11:11 +0000 (GMT) Received: from lep8c.aus.stglabs.ibm.com (unknown [9.40.192.207]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 18 Apr 2022 17:11:11 +0000 (GMT) Subject: [RFC ndctl PATCH 6/9] test: Enable PAPR test family tests after INTEL family tests From: Shivaprasad G Bhat To: nvdimm@lists.linux.dev, dan.j.williams@intel.com, vishal.l.verma@intel.com Cc: aneesh.kumar@linux.ibm.com, sbhat@linux.ibm.com, vaibhav@linux.ibm.com Date: Mon, 18 Apr 2022 12:11:11 -0500 Message-ID: <165030186233.3224737.11514053958670858450.stgit@lep8c.aus.stglabs.ibm.com> In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> References: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> User-Agent: StGit/1.1+40.g1b20 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: GJtZzEbfflFSyc-HSU0tQVqFSYv7E2pr X-Proofpoint-GUID: GJtZzEbfflFSyc-HSU0tQVqFSYv7E2pr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 suspectscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180101 The patch here attempts to run tests per-family loading their respective kernel test modules based on the environment variable set by the meson scripts. The skip_PAPR.js file is added to ensure there are no false negatives from PAPR family. The behaviour can be overridden by configure option -Dtest-families=INTEL Or PAPR to run the tests for the specific family. When not running the "meson test" but running tests individually the patch takes precaution to set the default settings to INTEL to keep the current behaviour unaffected on individual tests. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Vaibhav Jain --- meson.build | 10 +++++++++ meson_options.txt | 2 ++ test/common | 42 ++++++++++++++++++++++++++++++++-------- test/core.c | 17 +++++++++++++++- test/libndctl.c | 2 +- test/meson.build | 56 ++++++++++++++++++++++++++++++----------------------- 6 files changed, 95 insertions(+), 34 deletions(-) diff --git a/meson.build b/meson.build index 42e11aa2..bf44ba4f 100644 --- a/meson.build +++ b/meson.build @@ -14,6 +14,16 @@ project('ndctl', 'c', ], ) +families = [ 'INTEL', 'PAPR' ] +if get_option('test-families') != '' + families_str=get_option('test-families').split(',') + foreach f : families_str + if not families.contains(f.to_upper().strip()) + error('Invalid test_family "@0@" specified.'.format(f)) + endif + endforeach +endif + # rootprefixdir and rootlibdir setup copied from systemd: rootprefixdir = get_option('rootprefix') rootprefix_default = '/usr' diff --git a/meson_options.txt b/meson_options.txt index aa4a6dc8..95dfb395 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -7,6 +7,8 @@ option('keyutils', type : 'feature', value : 'enabled', description : 'enable nvdimm device passphrase management') option('test', type : 'feature', value : 'disabled', description : 'enable shipping tests in ndctl') +option('test-families', type : 'string', value : 'INTEL,PAPR', + description : 'specify command separated test families in ndctl. Default is INTEL,PAPR') option('destructive', type : 'feature', value : 'disabled', description : 'enable tests that may clobber live system resources') option('poison', type : 'feature', value : 'enabled', diff --git a/test/common b/test/common index 31395ece..743f63bf 100644 --- a/test/common +++ b/test/common @@ -124,7 +124,7 @@ _cleanup() { $NDCTL disable-region -b $NFIT_TEST_BUS0 all $NDCTL disable-region -b $NFIT_TEST_BUS1 all - modprobe -r nfit_test + modprobe -r $TEST_MODULE if [ $NDCTL_TEST_FAMILY == "INTEL" ]; then modprobe -r nfit fi @@ -132,14 +132,40 @@ _cleanup() _init() { - set +e - modprobe nfit_test - if [ $? -ne 0 ]; then - echo "Could not load the nfit_test module." - exit 77 + modules=$(awk -F" " 'BEGIN {ORS=" "} {print $1}' /proc/modules) + if [ "$NDCTL_TEST_FAMILY" == "PAPR" ]; then + TEST_MODULE="ndtest" + if [[ " ${modules[*]} " =~ " nfit " ]] || + [[ " ${modules[*]} " =~ " nfit_test " ]]; then + echo "The test module ${TEST_MODULE}.ko conflicts " + echo "with nfit and nfit_test. Unload them and retry.." + exit 77 + fi + NFIT_TEST_BUS0=ndtest.0 + NFIT_TEST_BUS1=ndtest.1 + else + TEST_MODULE="nfit_test" + if [[ " ${modules[*]} " =~ "ndtest" ]]; then + echo "The test module ${TEST_MODULE}.ko conflicts " + echo "with ndtest. Unload it and retry.." + exit 77 + fi + fi + if [ -d "/lib/modules/`uname -r`/extra/test" ]; then + if [ -f "/lib/modules/`uname -r`/extra/test/${TEST_MODULE}.ko" ]; then + set +e + modprobe ${TEST_MODULE} + if [ $? -ne 0 ]; then + echo "Could not load the ${TEST_MODULE} module." + exit 77 + fi + set -e + trap _cleanup EXIT INT TERM HUP PIPE + else + echo "The test module ${TEST_MODULE}.ko not found. Skipping.." + exit 77 + fi fi - set -e - trap _cleanup EXIT INT TERM HUP PIPE } # json2var diff --git a/test/core.c b/test/core.c index f5cf6c82..ee7f5182 100644 --- a/test/core.c +++ b/test/core.c @@ -260,6 +260,18 @@ int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, if (test_env && strcmp(test_env, "PAPR") == 0) family = NVDIMM_FAMILY_PAPR; + if ((family == NVDIMM_FAMILY_INTEL) && + (access("/sys/module/ndtest/initstate", F_OK) == 0)) { + fprintf(stderr, + "PAPR specific ndtest module loaded while attempting to test nfit_test\n"); + return -ENOTSUP; + } else if ((family == NVDIMM_FAMILY_PAPR) && + ((access("/sys/module/nfit_test/initstate", F_OK) == 0) || + (access("/sys/module/nfit/initstate", F_OK) == 0))) { + fprintf(stderr, "nfit/nfit_test module loaded while attempting to test ndtest\n"); + return -ENOTSUP; + } + if (family == -1) { log_err(&log_ctx, "Cannot determine NVDIMM family\n"); return -ENOTSUP; @@ -363,7 +375,10 @@ retry: return -ENXIO; } - rc = kmod_module_new_from_name(*ctx, "nfit_test", mod); + if (family == NVDIMM_FAMILY_INTEL) + rc = kmod_module_new_from_name(*ctx, "nfit_test", mod); + else + rc = kmod_module_new_from_name(*ctx, "ndtest", mod); if (rc < 0) { kmod_unref(*ctx); return rc; diff --git a/test/libndctl.c b/test/libndctl.c index ab9f73c9..a70c1ed7 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -2596,7 +2596,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) err = ndctl_test_init(&kmod_ctx, &mod, ctx, loglevel, test); if (err < 0) { ndctl_test_skip(test); - fprintf(stderr, "nfit_test unavailable skipping tests\n"); + fprintf(stderr, "test module couldnt not be loaded, skipping tests\n"); return 77; } diff --git a/test/meson.build b/test/meson.build index 395b5333..b33fe3b9 100644 --- a/test/meson.build +++ b/test/meson.build @@ -177,6 +177,11 @@ tests = [ [ 'track-uuid.sh', track_uuid, 'ndctl' ], ] +families_string = get_option('test-families') +if families_string != '' + families=families_string.split(',') +endif + if get_option('destructive').enabled() sub_section = find_program('sub-section.sh') dax_ext4 = find_program('dax-ext4.sh') @@ -212,28 +217,31 @@ if get_option('keyutils').enabled() ] endif -foreach t : tests - test(t[0], t[1], - is_parallel : false, - depends : [ - ndctl_tool, - daxctl_tool, - cxl_tool, - smart_notify, - list_smart_dimm, - dax_pmd, - dax_errors, - daxdev_errors, - dax_dev, - mmap, - ], - suite: t[2], - timeout : 0, - env : [ - 'NDCTL=@0@'.format(ndctl_tool.full_path()), - 'DAXCTL=@0@'.format(daxctl_tool.full_path()), - 'TEST_PATH=@0@'.format(meson.current_build_dir()), - 'DATA_PATH=@0@'.format(meson.current_source_dir()), - ], - ) +foreach f : families + foreach t : tests + test(t[0], t[1], + is_parallel : false, + depends : [ + ndctl_tool, + daxctl_tool, + cxl_tool, + smart_notify, + list_smart_dimm, + dax_pmd, + dax_errors, + daxdev_errors, + dax_dev, + mmap, + ], + suite: [ t[2], f ], + timeout : 0, + env : [ + 'NDCTL=@0@'.format(ndctl_tool.full_path()), + 'DAXCTL=@0@'.format(daxctl_tool.full_path()), + 'TEST_PATH=@0@'.format(meson.current_build_dir()), + 'DATA_PATH=@0@'.format(meson.current_source_dir()), + 'NDCTL_TEST_FAMILY=@0@'.format(f.to_upper().strip()), + ], + ) + endforeach endforeach From patchwork Mon Apr 18 17:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivaprasad G Bhat X-Patchwork-Id: 12816972 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 192E8A29 for ; Mon, 18 Apr 2022 17:15:09 +0000 (UTC) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23IF4RVj026791; Mon, 18 Apr 2022 17:15:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pp1; bh=AdElIX/VP8uC7o2Bh7lNtVEQZv3EbvUgi2toCabkMfE=; b=RAoYFUd28ubS/6z5tO5qBezB8bKfnnacog8AaK4fYPWlpsUrPZEQFTwpbxGic6/ElEdT YlYplCDIzyGWf3fAd6tnRxCNa166JTNLd+UHbBcd4Kaj0gp+QbTIAkotuvYjL+c/8wAc 4z1jN/7lAAJMV3SVpfW3jLZApdrA93dwT3kLgJVPSlucqAhJH87p8TgkqpuHSjyHIaCX 2YrPDkWYwaur5F1cB+iFzas74L64IZ9lIQHgFHjA/qnjAfSX4bC19nURKrLG3lF0AVNl swLV3Xvv4+bQgooIVDHvWTCSWZn5DkGhr/nnIzW3yS4kthwrztpRDq1S7jJm+2mdgks4 lA== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg791hnb7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:15:08 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23IHD5Z2025974; Mon, 18 Apr 2022 17:15:06 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 3ffne8k1q9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:15:05 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23IHF2ML20513160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Apr 2022 17:15:02 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7C6D552057; Mon, 18 Apr 2022 17:15:02 +0000 (GMT) Received: from lep8c.aus.stglabs.ibm.com (unknown [9.40.192.207]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9468E52051; Mon, 18 Apr 2022 17:15:01 +0000 (GMT) Subject: [ndctl v3 PATCH 7/9] test/libndctl: Enable libndctl tests on ndtest From: Shivaprasad G Bhat To: nvdimm@lists.linux.dev, dan.j.williams@intel.com, vishal.l.verma@intel.com Cc: aneesh.kumar@linux.ibm.com, sbhat@linux.ibm.com, vaibhav@linux.ibm.com Date: Mon, 18 Apr 2022 12:15:00 -0500 Message-ID: <165030187808.3224737.13924358944848090966.stgit@lep8c.aus.stglabs.ibm.com> In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> References: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> User-Agent: StGit/1.1+40.g1b20 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: s5wTJgl3KwaeadcIwLvzUHoOPRaXxxOv X-Proofpoint-GUID: s5wTJgl3KwaeadcIwLvzUHoOPRaXxxOv X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=979 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180101 The ndtest/papr dsm don't have the smart threshold payloads defined and various smart fields like media/ctrl temperatures, spares etc. Test only whats relevant and disable/skip the rest. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Vaibhav Jain --- Depends on the kernel patch - https://patchwork.kernel.org/project/linux-nvdimm/patch/165027233876.3035289.4353747702027907365.stgit@lep8c.aus.stglabs.ibm.com/ Changelog: Since v2: Link: https://patchwork.kernel.org/project/linux-nvdimm/patch/163102901146.260256.6712219128280188987.stgit@99912bbcb4c7/ * Split the patch into libndctl test specific changes. * Rebased to use the global ndctl_test_family variable Since v1: Link: https://patchwork.kernel.org/project/linux-nvdimm/patch/162737350565.3944327.6662473656483436466.stgit@lep8c.aus.stglabs.ibm.com/ * Updated the commit message description test/libndctl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ test/skip_PAPR.js | 3 +-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/test/libndctl.c b/test/libndctl.c index a70c1ed7..15c47211 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -2075,6 +2075,46 @@ struct smart { life_used, shutdown_state, shutdown_count, vendor_size; }; +static int check_smart_ndtest(struct ndctl_bus *bus, struct ndctl_dimm *dimm, + struct check_cmd *check) +{ + static const struct smart smart_data = { + .flags = ND_SMART_HEALTH_VALID | ND_SMART_SHUTDOWN_VALID + | ND_SMART_SHUTDOWN_COUNT_VALID | ND_SMART_USED_VALID, + .health = ND_SMART_NON_CRITICAL_HEALTH, + .life_used = 5, + .shutdown_state = 0, + .shutdown_count = 42, + .vendor_size = 0, + }; + struct ndctl_cmd *cmd = ndctl_dimm_cmd_new_smart(dimm); + int rc; + + if (!cmd) { + fprintf(stderr, "%s: dimm: %#x failed to create cmd\n", + __func__, ndctl_dimm_get_handle(dimm)); + return -ENXIO; + } + + rc = ndctl_cmd_submit(cmd); + if (rc < 0) { + fprintf(stderr, "%s: dimm: %#x failed to submit cmd: %d\n", + __func__, ndctl_dimm_get_handle(dimm), rc); + ndctl_cmd_unref(cmd); + return rc; + } + + __check_smart(dimm, cmd, flags, -1); + __check_smart(dimm, cmd, health, -1); + __check_smart(dimm, cmd, life_used, -1); + __check_smart(dimm, cmd, shutdown_state, -1); + __check_smart(dimm, cmd, shutdown_count, -1); + __check_smart(dimm, cmd, vendor_size, -1); + + check->cmd = cmd; + return 0; +} + static int check_smart(struct ndctl_bus *bus, struct ndctl_dimm *dimm, struct check_cmd *check) { @@ -2299,6 +2339,11 @@ static int check_commands(struct ndctl_bus *bus, struct ndctl_dimm *dimm, unsigned int i, rc = 0; + if (ndctl_test_family == NVDIMM_FAMILY_PAPR) { + dimm_commands &= ~(1 << ND_CMD_SMART_THRESHOLD); + __check_dimm_cmds[ND_CMD_SMART].check_fn = &check_smart_ndtest; + } + /* * The kernel did not start emulating v1.2 namespace spec smart data * until 4.9. diff --git a/test/skip_PAPR.js b/test/skip_PAPR.js index 367257c4..ec967c98 100644 --- a/test/skip_PAPR.js +++ b/test/skip_PAPR.js @@ -26,8 +26,7 @@ "dm.sh", // "" "mmap.sh", // "" "monitor.sh", // To be fixed - "inject-smart.sh", // "" - "libndctl" // "" + "inject-smart.sh" // "" ] // NOTE: The libjson-c doesn't like comments in json files, so keep the file From patchwork Mon Apr 18 17:17:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivaprasad G Bhat X-Patchwork-Id: 12816973 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E80CDA29 for ; Mon, 18 Apr 2022 17:17:40 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23IGZ44J020532; Mon, 18 Apr 2022 17:17:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pp1; bh=Xr9rbaQv5l4JO7u2KQAoWXIrja3MNcKumsbbFm2lyCk=; b=RzUTR4wKerlLBj1/A1FIwrJaXJECySuHGSqjrx8WpBxgXZz3JzruX1sr5Fibr8MWMHtE LJs5W+sBCv+vI2+XB4oInAb9UPj+RoG42mbALrCnvCRWF4Pp9rdib9yVrI9H4jTg0TqY TEyqhwBw1Q2XGAYOgi+XO4Zd1yFiKrbdnQDtRhTsODunRKMvT9zvchFTZnjfPW3N3a2P ZI1XO2+IzqpKQ2b9eag+O9tES6dyp8BDBByB8kztYikeyb4zPt4/v8bji3lJJQQpJGuK b8Op6zaXdtYfmyUTYV5cG9UILKHsp9zURTnAr/ogzLie+ePKw4PM6fJsIoNtxZLOEYif Nw== Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fg75pt03d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:17:38 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23IHE2rW021508; Mon, 18 Apr 2022 17:17:36 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04fra.de.ibm.com with ESMTP id 3ffvt9a1ve-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:17:36 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23IH4nm729295100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Apr 2022 17:04:49 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 50D58A4054; Mon, 18 Apr 2022 17:17:33 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66B4AA405B; Mon, 18 Apr 2022 17:17:32 +0000 (GMT) Received: from lep8c.aus.stglabs.ibm.com (unknown [9.40.192.207]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 18 Apr 2022 17:17:32 +0000 (GMT) Subject: [ndctl v3 PATCH 8/9] test/inject-smart: Enable inject-smart tests on ndtest From: Shivaprasad G Bhat To: nvdimm@lists.linux.dev, dan.j.williams@intel.com, vishal.l.verma@intel.com Cc: aneesh.kumar@linux.ibm.com, sbhat@linux.ibm.com, vaibhav@linux.ibm.com Date: Mon, 18 Apr 2022 12:17:31 -0500 Message-ID: <165030210764.3224737.17752152448193088910.stgit@lep8c.aus.stglabs.ibm.com> In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> References: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> User-Agent: StGit/1.1+40.g1b20 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: prlWRqJyKlhnXf53Izg_zUDz2ncE6EhF X-Proofpoint-GUID: prlWRqJyKlhnXf53Izg_zUDz2ncE6EhF X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180101 The ndtest driver does not have the payloads defined for various smart fields like the media|ctrl temperature, threshold parameters for the current PAPR PDSM. So, the patch makes the below changes to have a valid inject-smart test run on the ndtest driver. test/inject-smart.sh - Test only the shutdown_state and dimm_health as only those are supported on ndtest. Skip rest of the tests. Reorder the code for cleanliness list-list-smart-dimms.c - Separate out filter_dimm implementation for papr family with the relevant check. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Vaibhav Jain --- Depends on the kernel patch - https://patchwork.kernel.org/project/linux-nvdimm/patch/165027233876.3035289.4353747702027907365.stgit@lep8c.aus.stglabs.ibm.com/ Changelog: Since v2: Link: https://patchwork.kernel.org/project/linux-nvdimm/patch/163102901146.260256.6712219128280188987.stgit@99912bbcb4c7/ * Addedd the init_env() call and use the bus name post environment initialization. * Split the patch to have the libndctl test specific fixes separately * Updating the skip file to not skip the test, as it works now with this patch Since v1: Link: https://patchwork.kernel.org/project/linux-nvdimm/patch/162737350565.3944327.6662473656483436466.stgit@lep8c.aus.stglabs.ibm.com/ * Updated the commit message description test/inject-smart.sh | 14 +++++++++----- test/list-smart-dimm.c | 33 ++++++++++++++++++++++++++++++++- test/meson.build | 2 +- test/skip_PAPR.js | 3 +-- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/test/inject-smart.sh b/test/inject-smart.sh index 80af058a..07d04fb6 100755 --- a/test/inject-smart.sh +++ b/test/inject-smart.sh @@ -4,7 +4,6 @@ rc=77 . $(dirname $0)/common -bus="$NFIT_TEST_BUS0" inj_val="42" trap 'err $LINENO' ERR @@ -152,14 +151,18 @@ do_tests() $NDCTL inject-smart -b $bus --uninject-all $dimm # start tests - for field in "${fields_val[@]}"; do - test_field $field $inj_val - done - for field in "${fields_bool[@]}"; do test_field $field done + if [ $NDCTL_TEST_FAMILY == "PAPR" ]; then + return + fi + + for field in "${fields_val[@]}"; do + test_field $field $inj_val + done + for field in "${fields_thresh[@]}"; do test_field $field $inj_val "thresh" done @@ -168,6 +171,7 @@ do_tests() check_min_kver "4.19" || do_skip "kernel $KVER may not support smart (un)injection" check_prereq "jq" _init +bus="$NFIT_TEST_BUS0" rc=1 jlist=$($TEST_PATH/list-smart-dimm -b $bus) diff --git a/test/list-smart-dimm.c b/test/list-smart-dimm.c index f94277e8..7ad6c751 100644 --- a/test/list-smart-dimm.c +++ b/test/list-smart-dimm.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,32 @@ static bool filter_region(struct ndctl_region *region, return true; } +static void filter_ndtest_dimm(struct ndctl_dimm *dimm, + struct ndctl_filter_ctx *ctx) +{ + struct list_filter_arg *lfa = ctx->list; + struct json_object *jdimm; + + if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART)) + return; + + if (!lfa->jdimms) { + lfa->jdimms = json_object_new_array(); + if (!lfa->jdimms) { + fail("\n"); + return; + } + } + + jdimm = util_dimm_to_json(dimm, lfa->flags); + if (!jdimm) { + fail("\n"); + return; + } + + json_object_array_add(lfa->jdimms, jdimm); +} + static void filter_dimm(struct ndctl_dimm *dimm, struct ndctl_filter_ctx *ctx) { struct list_filter_arg *lfa = ctx->list; @@ -92,6 +119,7 @@ int main(int argc, const char *argv[]) struct ndctl_filter_ctx fctx = { 0 }; struct list_filter_arg lfa = { 0 }; + init_env(); rc = ndctl_new(&ctx); if (rc < 0) return EXIT_FAILURE; @@ -102,7 +130,10 @@ int main(int argc, const char *argv[]) usage_with_options(u, options); fctx.filter_bus = filter_bus; - fctx.filter_dimm = filter_dimm; + if (ndctl_test_family == NVDIMM_FAMILY_PAPR) + fctx.filter_dimm = filter_ndtest_dimm; + else + fctx.filter_dimm = filter_dimm; fctx.filter_region = filter_region; fctx.filter_namespace = NULL; fctx.list = &lfa; diff --git a/test/meson.build b/test/meson.build index b33fe3b9..1f804afd 100644 --- a/test/meson.build +++ b/test/meson.build @@ -76,7 +76,7 @@ daxdev_errors = executable('daxdev-errors', [ include_directories : root_inc, ) -list_smart_dimm = executable('list-smart-dimm', [ +list_smart_dimm = executable('list-smart-dimm', testcore + [ 'list-smart-dimm.c', '../ndctl/filter.c', '../util/json.c', diff --git a/test/skip_PAPR.js b/test/skip_PAPR.js index ec967c98..97ceda82 100644 --- a/test/skip_PAPR.js +++ b/test/skip_PAPR.js @@ -25,8 +25,7 @@ "align.sh", // "" "dm.sh", // "" "mmap.sh", // "" - "monitor.sh", // To be fixed - "inject-smart.sh" // "" + "monitor.sh" // To be fixed ] // NOTE: The libjson-c doesn't like comments in json files, so keep the file From patchwork Mon Apr 18 17:19:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivaprasad G Bhat X-Patchwork-Id: 12816976 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 794FBA29 for ; Mon, 18 Apr 2022 17:19:37 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23IFTjca029938; Mon, 18 Apr 2022 17:19:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pp1; bh=Y2lrYGiJZJ4T/KOxbN/w0LFjWIn2VAB+XKuT+3drux0=; b=QnJZT4RNZ/fhgA0BvKNmfMGFYz/UFTSapXUGKW4hK1VlEcbI/kHOnjzCS7gk3Ctiaumi M20hGXKw98xwrqgRx8PMsvlO+6SK+M1keZI5lBjeCnv9P3xdi3GshSfWKZ1zRpmd7TR0 XEzM3DgVvOu2YGq/DAVJ44xsjOs013l8x3vPTEh5m0jpBzoASR5YVeMthpn/V+aFRcXh iQC+iGyxGMC/kMhs0IFA3EeyiVQgpXwfVOCE71odjah4VEb6WpnsKTcKE/X4N5Pc4qJp JdjqcaK4kRo6H30OnxY1Jd0XFFM5UidpI/d8KZH2i0wrQZNpDqEXrMRnaxJQmFhiorin 9w== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fg7fjsusb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:19:35 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23IHCrGa025948; Mon, 18 Apr 2022 17:19:33 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3ffne8k1tq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 17:19:32 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23IHJOeX55837060 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Apr 2022 17:19:29 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5B9F25204F; Mon, 18 Apr 2022 17:19:24 +0000 (GMT) Received: from lep8c.aus.stglabs.ibm.com (unknown [9.40.192.207]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 6BDD85204E; Mon, 18 Apr 2022 17:19:23 +0000 (GMT) Subject: [ndctl v3 PATCH 9/9] test/monitor.sh: Partially skip monitor test on ndtest From: Shivaprasad G Bhat To: nvdimm@lists.linux.dev, dan.j.williams@intel.com, vishal.l.verma@intel.com Cc: aneesh.kumar@linux.ibm.com, sbhat@linux.ibm.com, vaibhav@linux.ibm.com Date: Mon, 18 Apr 2022 12:19:22 -0500 Message-ID: <165030225848.3224737.13035309277759398287.stgit@lep8c.aus.stglabs.ibm.com> In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> References: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com> User-Agent: StGit/1.1+40.g1b20 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: TpzcVgjtApFEEEcR_KsQ4sswlJBv9EbL X-Proofpoint-ORIG-GUID: TpzcVgjtApFEEEcR_KsQ4sswlJBv9EbL X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 spamscore=0 clxscore=1015 impostorscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180101 The ndtest/papr pdsm has the unclean shutdown inject support. Rest of the tests in monitor.sh are injecting temperature, spares with thresholds and monitoring on them. These test cases are irrelevant on papr, skip them. Its convenient/cleaner to reorder the tests than selectively adding test environment checks for each of the tests. So, reordering to call the dimm events test first. Signed-off-by: Shivaprasad G Bhat --- Depends on the kernel patch posted at - https://patchwork.kernel.org/project/linux-nvdimm/patch/165027233876.3035289.4353747702027907365.stgit@lep8c.aus.stglabs.ibm.com/ Depends on the ndctl monitor regression fix patch posted at - https://patchwork.kernel.org/project/linux-nvdimm/patch/164750955519.2000193.16903542741359443926.stgit@LAPTOP-TBQTPII8/ Changelog: Since v2: Link: https://patchwork.kernel.org/project/linux-nvdimm/patch/163102905777.260256.5004593912307267155.stgit@99912bbcb4c7/ * Removing the entry from skip file as the test works on ndtest with the patch test/monitor.sh | 11 ++++++++++- test/skip_PAPR.js | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/monitor.sh b/test/monitor.sh index 10e65374..7c5d316d 100755 --- a/test/monitor.sh +++ b/test/monitor.sh @@ -136,6 +136,10 @@ test_filter_dimmevent() check_result "$monitor_dimms" stop_monitor + if [ $NDCTL_TEST_FAMILY == "PAPR" ]; then + return + fi + inject_value=$($NDCTL list -H -d $monitor_dimms | jq -r .[]."health"."spares_threshold") inject_value=$((inject_value - 1)) start_monitor "-d $monitor_dimms -D dimm-spares-remaining" @@ -153,12 +157,17 @@ test_filter_dimmevent() do_tests() { + test_filter_dimmevent + + if [ $NDCTL_TEST_FAMILY == "PAPR" ]; then + return + fi + test_filter_dimm test_filter_bus test_filter_region test_filter_namespace test_conf_file - test_filter_dimmevent } _init diff --git a/test/skip_PAPR.js b/test/skip_PAPR.js index 97ceda82..52bb5f33 100644 --- a/test/skip_PAPR.js +++ b/test/skip_PAPR.js @@ -24,8 +24,7 @@ "revoke_devmem", // "" "align.sh", // "" "dm.sh", // "" - "mmap.sh", // "" - "monitor.sh" // To be fixed + "mmap.sh" // "" ] // NOTE: The libjson-c doesn't like comments in json files, so keep the file