All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default
@ 2022-04-18 17:09 Shivaprasad G Bhat
  2022-04-18 17:10 ` [RFC ndctl PATCH 1/9] test/common: Ensure to unload test modules Shivaprasad G Bhat
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Shivaprasad G Bhat @ 2022-04-18 17:09 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, vishal.l.verma; +Cc: aneesh.kumar, sbhat, vaibhav

It is possible to have tests run over multiple test families if
the respective modules can be loaded/unloaded serially on a test to
test basis. The kernel patch [1] separated out the PAPR specific
ndtest module on its own as "ndtest.ko".

So with [1], we have two family specific modules(nfit_test & ndtest)
which can be loaded one after the other and have the test results
in one go without a need for kernel recompilation with different
kernel configs.

The series ensures all the known failures/unsupported/irrelevant tests
to be skipped on ndtest to avoid all "known" chances of false negatives.
This is achieved using a skip file containing the list of tests to be
skipped on the given platform. The PAPR specific tests to be skipped
are updated in the skip_PAPR.js file.

A meson config option(-Dtest-families=INTEL,PAPR default) is added.
One can just limit the tests to INTEL or PAPR alone if required.

An example run would look like,
===========================================
 1/72 ndctl:ndctl+INTEL / libndctl                       OK              2.79s
 2/72 ndctl:ndctl+INTEL / dsm-fail                       OK              0.70s
 3/72 ndctl:ndctl+INTEL / create.sh                      OK              0.80s
 4/72 ndctl:ndctl+INTEL / clear.sh                       OK             15.04s
 5/72 ndctl:ndctl+INTEL / pmem-errors.sh                 OK             14.97s
 6/72 ndctl:dax+INTEL / daxdev-errors.sh                 OK             12.33s
 7/72 ndctl:dax+INTEL / multi-dax.sh                     OK              0.67s
 8/72 ndctl:ndctl+INTEL / btt-check.sh                   OK             16.20s
 9/72 ndctl:ndctl+INTEL / label-compat.sh                OK              0.82s
10/72 ndctl:ndctl+INTEL / sector-mode.sh                 OK              1.01s
11/72 ndctl:ndctl+INTEL / inject-error.sh                OK             14.52s
12/72 ndctl:ndctl+INTEL / btt-errors.sh                  OK             24.01s
13/72 ndctl:ndctl+INTEL / hugetlb                        OK              0.09s
14/72 ndctl:ndctl+INTEL / btt-pad-compat.sh              OK              1.78s
15/72 ndctl:ndctl+INTEL / firmware-update.sh             FAIL           10.33s   exit status 1
>>> TEST_PATH=/home/sbhat/code/ndctl/build/test NDCTL_TEST_FAMILY=INTEL DAXCTL=/home/sbhat/code/ndctl/build/daxctl/daxctl NDCTL=/home/sbhat/code/ndctl/build/ndctl/ndctl MALLOC_PERTURB_=181 DATA_PATH=/home/sbhat/code/ndctl/test /home/sbhat
/code/ndctl/test/firmware-update.sh

16/72 ndctl:ndctl+INTEL / ack-shutdown-count-set         OK              0.26s
17/72 ndctl:ndctl+INTEL / rescan-partitions.sh           OK              7.84s
18/72 ndctl:ndctl+INTEL / inject-smart.sh                OK              1.89s
19/72 ndctl:ndctl+INTEL / monitor.sh                     OK             13.22s
20/72 ndctl:ndctl+INTEL / max_extent_ns                  OK              1.10s
21/72 ndctl:ndctl+INTEL / pfn-meta-errors.sh             OK             14.62s
22/72 ndctl:ndctl+INTEL / track-uuid.sh                  OK              0.78s
23/72 ndctl:ndctl+INTEL / pmem-ns                        FAIL            0.26s   (exit status 237 or signal 109 SIGinvalid)
>>> TEST_PATH=/home/sbhat/code/ndctl/build/test MALLOC_PERTURB_=140 NDCTL_TEST_FAMILY=INTEL DAXCTL=/home/sbhat/code/ndctl/build/daxctl/daxctl NDCTL=/home/sbhat/code/ndctl/build/ndctl/ndctl DATA_PATH=/home/sbhat/code/ndctl/test /home/sbhat
/code/ndctl/build/test/pmem-ns

24/72 ndctl:dax+INTEL / sub-section.sh                   SKIP            0.15s   exit status 77
25/72 ndctl:dax+INTEL / dax-dev                          SKIP            0.03s   exit status 77
26/72 ndctl:dax+INTEL / dax-ext4.sh                      SKIP            0.05s   exit status 77
27/72 ndctl:dax+INTEL / dax-xfs.sh                       SKIP            0.05s   exit status 77
28/72 ndctl:ndctl+INTEL / align.sh                       SKIP            0.09s   exit status 77
29/72 ndctl:dax+INTEL / device-dax                       SKIP            0.04s   exit status 77
30/72 ndctl:dax+INTEL / revoke-devmem                    OK              0.03s
31/72 ndctl:dax+INTEL / device-dax-fio.sh                SKIP            0.06s   exit status 77
32/72 ndctl:dax+INTEL / daxctl-devices.sh                SKIP            0.07s   exit status 77
33/72 ndctl:dax+INTEL / daxctl-create.sh                 SKIP            0.02s   exit status 77
34/72 ndctl:dax+INTEL / dm.sh                            FAIL            0.12s   exit status 1
>>> TEST_PATH=/home/sbhat/code/ndctl/build/test NDCTL_TEST_FAMILY=INTEL DAXCTL=/home/sbhat/code/ndctl/build/daxctl/daxctl NDCTL=/home/sbhat/code/ndctl/build/ndctl/ndctl MALLOC_PERTURB_=115 DATA_PATH=/home/sbhat/code/ndctl/test /home/sbhat
/code/ndctl/test/dm.sh
35/72 ndctl:dax+INTEL / mmap.sh                          SKIP            0.05s   exit status 77
36/72 ndctl:ndctl+INTEL / security.sh                    SKIP            0.38s   exit status 77
37/72 ndctl:ndctl+PAPR / libndctl                        OK              2.63s
38/72 ndctl:ndctl+PAPR / dsm-fail                        OK              1.41s
39/72 ndctl:ndctl+PAPR / create.sh                       OK              1.06s
40/72 ndctl:ndctl+PAPR / clear.sh                        SKIP            0.12s   exit status 77
41/72 ndctl:ndctl+PAPR / pmem-errors.sh                  SKIP            0.16s   exit status 77
42/72 ndctl:dax+PAPR / daxdev-errors.sh                  SKIP            0.08s   exit status 77
43/72 ndctl:dax+PAPR / multi-dax.sh                      OK              1.03s
44/72 ndctl:ndctl+PAPR / btt-check.sh                    OK             17.13s
45/72 ndctl:ndctl+PAPR / label-compat.sh                 SKIP            0.26s   exit status 77
46/72 ndctl:ndctl+PAPR / sector-mode.sh                  OK              1.26s
47/72 ndctl:ndctl+PAPR / inject-error.sh                 SKIP            0.20s   exit status 77
48/72 ndctl:ndctl+PAPR / btt-errors.sh                   SKIP            1.42s   exit status 77
49/72 ndctl:ndctl+PAPR / hugetlb                         OK              0.16s
50/72 ndctl:ndctl+PAPR / btt-pad-compat.sh               OK              3.06s
51/72 ndctl:ndctl+PAPR / firmware-update.sh              SKIP            0.90s   exit status 77
52/72 ndctl:ndctl+PAPR / ack-shutdown-count-set          SKIP            0.09s   exit status 77
53/72 ndctl:ndctl+PAPR / rescan-partitions.sh            OK              8.11s
54/72 ndctl:ndctl+PAPR / inject-smart.sh                 OK              1.37s
55/72 ndctl:ndctl+PAPR / monitor.sh                      OK              7.63s
56/72 ndctl:ndctl+PAPR / max_extent_ns                   OK              1.41s
57/72 ndctl:ndctl+PAPR / pfn-meta-errors.sh              SKIP            0.14s   exit status 77
58/72 ndctl:ndctl+PAPR / track-uuid.sh                   OK              1.07s
59/72 ndctl:ndctl+PAPR / pmem-ns                         OK              0.54s
60/72 ndctl:dax+PAPR / sub-section.sh                    SKIP            0.27s   exit status 77
61/72 ndctl:dax+PAPR / dax-dev                           SKIP            0.04s   exit status 77
62/72 ndctl:dax+PAPR / dax-ext4.sh                       SKIP            0.35s   exit status 77
63/72 ndctl:dax+PAPR / dax-xfs.sh                        SKIP            0.39s   exit status 77
64/72 ndctl:ndctl+PAPR / align.sh                        SKIP            0.46s   exit status 77
65/72 ndctl:dax+PAPR / device-dax                        SKIP            0.04s   exit status 77
66/72 ndctl:dax+PAPR / revoke-devmem                     OK              0.04s
67/72 ndctl:dax+PAPR / device-dax-fio.sh                 SKIP            0.32s   exit status 77
68/72 ndctl:dax+PAPR / daxctl-devices.sh                 SKIP            0.40s   exit status 77
69/72 ndctl:dax+PAPR / daxctl-create.sh                  SKIP            0.48s   exit status 77
70/72 ndctl:dax+PAPR / dm.sh                             SKIP            0.48s   exit status 77
71/72 ndctl:dax+PAPR / mmap.sh                           SKIP            0.50s   exit status 77
72/72 ndctl:ndctl+PAPR / security.sh                     SKIP            0.22s   exit status 77


Ok:                 37
Expected Fail:      0
Fail:               3 # Not from PAPR family
Unexpected Pass:    0
Skipped:            32
Timeout:            0
===========================================
Note the meson suite string here "ndctl+INTEL|PAPR" indicating the
test family.

The first 6 patches in the series move the code with little/no change
to current behaviour in isolation while fixing existing bugs in
preparation for running the tests for INTEL and PAPR families one
after the other. The last 3 patches fix the known failures on ndtest
and they depend on the kernel patch [2]. These 3 patches are repost of
previously posted patches with rebase. The last patches are included
here in this series for completeness.

The patches are posted on github repos below
Kernel - https://github.com/shivaprasadbhat/linux/tree/ndtest-runall
ndctl  - https://github.com/shivaprasadbhat/ndctl/tree/ndctl-test-all

References:
[1] - https://patchwork.kernel.org/project/linux-nvdimm/patch/165025849452.2974989.6131145460098517848.stgit@lep8c.aus.stglabs.ibm.com/
[2] - https://patchwork.kernel.org/project/linux-nvdimm/patch/165027233876.3035289.4353747702027907365.stgit@lep8c.aus.stglabs.ibm.com/

---

Shivaprasad G Bhat (9):
      test/common: Ensure to unload test modules
      test: core: Fix module unload failures
      test: Unload the nfit module during cleanup
      test: Introduce skip file to skip irrelevant tests
      test: Assign provider name based on the test family
      test: Enable PAPR test family tests after INTEL family tests
      test/libndctl: Enable libndctl tests on ndtest
      test/inject-smart: Enable inject-smart tests on ndtest
      test/monitor.sh: Partially skip monitor test on ndtest

 meson.build                     |  10 +++
 meson_options.txt               |   2 +
 ndctl/bat.c                     |   4 +-
 ndctl/test.c                    |   4 +-
 test.h                          |  10 ++-
 test/ack-shutdown-count-set.c   |  17 ++--
 test/btt-check.sh               |   3 +-
 test/btt-errors.sh              |   3 +-
 test/btt-pad-compat.sh          |   3 +-
 test/clear.sh                   |   4 +-
 test/common                     |  57 ++++++++++++-
 test/core.c                     | 140 +++++++++++++++++++++++++++++++-
 test/create.sh                  |   4 +-
 test/dax-dev.c                  |   2 +-
 test/dax-pmd.c                  |   2 +-
 test/daxdev-errors.sh           |   6 +-
 test/device-dax.c               |   2 +-
 test/dsm-fail.c                 |  33 +++++---
 test/firmware-update.sh         |   3 +-
 test/inject-error.sh            |   3 +-
 test/inject-smart.sh            |  17 ++--
 test/label-compat.sh            |   4 +-
 test/libndctl.c                 |  60 ++++++++++++--
 test/list-smart-dimm.c          |  33 +++++++-
 test/max_available_extent_ns.sh |   3 +-
 test/meson.build                |  59 ++++++++------
 test/monitor.sh                 |  14 +++-
 test/multi-dax.sh               |   4 +-
 test/pfn-meta-errors.sh         |   3 +-
 test/pmem-errors.sh             |   3 +-
 test/pmem_namespaces.c          |  29 +++----
 test/rescan-partitions.sh       |   3 +-
 test/revoke-devmem.c            |   2 +-
 test/sector-mode.sh             |   4 +-
 test/security.sh                |   3 +-
 test/skip_PAPR.js               |  32 ++++++++
 test/track-uuid.sh              |   3 +-
 37 files changed, 447 insertions(+), 141 deletions(-)
 create mode 100644 test/skip_PAPR.js

--


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [RFC ndctl PATCH 1/9] test/common: Ensure to unload test modules
  2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
@ 2022-04-18 17:10 ` Shivaprasad G Bhat
  2022-04-18 17:10 ` [RFC ndctl PATCH 2/9] test: core: Fix module unload failures Shivaprasad G Bhat
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Shivaprasad G Bhat @ 2022-04-18 17:10 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, vishal.l.verma; +Cc: aneesh.kumar, sbhat, vaibhav

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 <sbhat@linux.ibm.com>
---
 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



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC ndctl PATCH 2/9] test: core: Fix module unload failures
  2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
  2022-04-18 17:10 ` [RFC ndctl PATCH 1/9] test/common: Ensure to unload test modules Shivaprasad G Bhat
@ 2022-04-18 17:10 ` Shivaprasad G Bhat
  2022-04-18 17:10 ` [RFC ndctl PATCH 3/9] test: Unload the nfit module during cleanup Shivaprasad G Bhat
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Shivaprasad G Bhat @ 2022-04-18 17:10 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, vishal.l.verma; +Cc: aneesh.kumar, sbhat, vaibhav

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 <sbhat@linux.ibm.com>
---
 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;
 }
 



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC ndctl PATCH 3/9] test: Unload the nfit module during cleanup
  2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
  2022-04-18 17:10 ` [RFC ndctl PATCH 1/9] test/common: Ensure to unload test modules Shivaprasad G Bhat
  2022-04-18 17:10 ` [RFC ndctl PATCH 2/9] test: core: Fix module unload failures Shivaprasad G Bhat
@ 2022-04-18 17:10 ` Shivaprasad G Bhat
  2022-04-18 17:10 ` [RFC ndctl PATCH 4/9] test: Introduce skip file to skip irrelevant tests Shivaprasad G Bhat
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Shivaprasad G Bhat @ 2022-04-18 17:10 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, vishal.l.verma; +Cc: aneesh.kumar, sbhat, vaibhav

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 <sbhat@linux.ibm.com>
---
 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);
 }
 



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC ndctl PATCH 4/9] test: Introduce skip file to skip irrelevant tests
  2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
                   ` (2 preceding siblings ...)
  2022-04-18 17:10 ` [RFC ndctl PATCH 3/9] test: Unload the nfit module during cleanup Shivaprasad G Bhat
@ 2022-04-18 17:10 ` Shivaprasad G Bhat
  2022-04-18 17:10 ` [RFC ndctl PATCH 5/9] test: Assign provider name based on the test family Shivaprasad G Bhat
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Shivaprasad G Bhat @ 2022-04-18 17:10 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, vishal.l.verma; +Cc: aneesh.kumar, sbhat, vaibhav

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 <sbhat@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 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<length; i++ )); do
+		test=$(cat $(dirname $0)/skip_${NDCTL_TEST_FAMILY}.js |\
+			sed 's|//.*||' | jq -e -r ".[${i}]")
+		[ "$test" == "${0##*/}" ] && exit 77;
+	done
+fi
+
 # NFIT_TEST_BUS[01]
 #
 NFIT_TEST_BUS0="nfit_test.0"
diff --git a/test/core.c b/test/core.c
index bc7542aa..130e4aed 100644
--- a/test/core.c
+++ b/test/core.c
@@ -7,6 +7,8 @@
 #include <errno.h>
 #include <stdio.h>
 #include <test.h>
+#include <unistd.h>
+#include <json-c/json.h>
 
 #include <util/log.h>
 #include <util/sysfs.h>
@@ -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.



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC ndctl PATCH 5/9] test: Assign provider name based on the test family
  2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
                   ` (3 preceding siblings ...)
  2022-04-18 17:10 ` [RFC ndctl PATCH 4/9] test: Introduce skip file to skip irrelevant tests Shivaprasad G Bhat
@ 2022-04-18 17:10 ` Shivaprasad G Bhat
  2022-04-18 17:11 ` [RFC ndctl PATCH 6/9] test: Enable PAPR test family tests after INTEL family tests Shivaprasad G Bhat
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Shivaprasad G Bhat @ 2022-04-18 17:10 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, vishal.l.verma; +Cc: aneesh.kumar, sbhat, vaibhav

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 <sbhat@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 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 <ndctl/ndctl.h>
 #include <test.h>
 
-#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");



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [RFC ndctl PATCH 6/9] test: Enable PAPR test family tests after INTEL family tests
  2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
                   ` (4 preceding siblings ...)
  2022-04-18 17:10 ` [RFC ndctl PATCH 5/9] test: Assign provider name based on the test family Shivaprasad G Bhat
@ 2022-04-18 17:11 ` Shivaprasad G Bhat
  2022-04-18 17:15 ` [ndctl v3 PATCH 7/9] test/libndctl: Enable libndctl tests on ndtest Shivaprasad G Bhat
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Shivaprasad G Bhat @ 2022-04-18 17:11 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, vishal.l.verma; +Cc: aneesh.kumar, sbhat, vaibhav

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 <sbhat@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 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



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [ndctl v3 PATCH 7/9] test/libndctl: Enable libndctl tests on ndtest
  2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
                   ` (5 preceding siblings ...)
  2022-04-18 17:11 ` [RFC ndctl PATCH 6/9] test: Enable PAPR test family tests after INTEL family tests Shivaprasad G Bhat
@ 2022-04-18 17:15 ` Shivaprasad G Bhat
  2022-04-18 17:17 ` [ndctl v3 PATCH 8/9] test/inject-smart: Enable inject-smart " Shivaprasad G Bhat
  2022-04-18 17:19 ` [ndctl v3 PATCH 9/9] test/monitor.sh: Partially skip monitor test " Shivaprasad G Bhat
  8 siblings, 0 replies; 10+ messages in thread
From: Shivaprasad G Bhat @ 2022-04-18 17:15 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, vishal.l.verma; +Cc: aneesh.kumar, sbhat, vaibhav

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 <sbhat@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>

---

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



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [ndctl v3 PATCH 8/9] test/inject-smart: Enable inject-smart tests on ndtest
  2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
                   ` (6 preceding siblings ...)
  2022-04-18 17:15 ` [ndctl v3 PATCH 7/9] test/libndctl: Enable libndctl tests on ndtest Shivaprasad G Bhat
@ 2022-04-18 17:17 ` Shivaprasad G Bhat
  2022-04-18 17:19 ` [ndctl v3 PATCH 9/9] test/monitor.sh: Partially skip monitor test " Shivaprasad G Bhat
  8 siblings, 0 replies; 10+ messages in thread
From: Shivaprasad G Bhat @ 2022-04-18 17:17 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, vishal.l.verma; +Cc: aneesh.kumar, sbhat, vaibhav

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 <sbhat@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>

---

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 <ndctl/libndctl.h>
 #include <util/parse-options.h>
 
+#include <test.h>
 #include <ndctl/filter.h>
 #include <ndctl/ndctl.h>
 #include <ndctl/json.h>
@@ -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



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [ndctl v3 PATCH 9/9] test/monitor.sh: Partially skip monitor test on ndtest
  2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
                   ` (7 preceding siblings ...)
  2022-04-18 17:17 ` [ndctl v3 PATCH 8/9] test/inject-smart: Enable inject-smart " Shivaprasad G Bhat
@ 2022-04-18 17:19 ` Shivaprasad G Bhat
  8 siblings, 0 replies; 10+ messages in thread
From: Shivaprasad G Bhat @ 2022-04-18 17:19 UTC (permalink / raw)
  To: nvdimm, dan.j.williams, vishal.l.verma; +Cc: aneesh.kumar, sbhat, vaibhav

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 <sbhat@linux.ibm.com>

---

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



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-04-18 17:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
2022-04-18 17:10 ` [RFC ndctl PATCH 1/9] test/common: Ensure to unload test modules Shivaprasad G Bhat
2022-04-18 17:10 ` [RFC ndctl PATCH 2/9] test: core: Fix module unload failures Shivaprasad G Bhat
2022-04-18 17:10 ` [RFC ndctl PATCH 3/9] test: Unload the nfit module during cleanup Shivaprasad G Bhat
2022-04-18 17:10 ` [RFC ndctl PATCH 4/9] test: Introduce skip file to skip irrelevant tests Shivaprasad G Bhat
2022-04-18 17:10 ` [RFC ndctl PATCH 5/9] test: Assign provider name based on the test family Shivaprasad G Bhat
2022-04-18 17:11 ` [RFC ndctl PATCH 6/9] test: Enable PAPR test family tests after INTEL family tests Shivaprasad G Bhat
2022-04-18 17:15 ` [ndctl v3 PATCH 7/9] test/libndctl: Enable libndctl tests on ndtest Shivaprasad G Bhat
2022-04-18 17:17 ` [ndctl v3 PATCH 8/9] test/inject-smart: Enable inject-smart " Shivaprasad G Bhat
2022-04-18 17:19 ` [ndctl v3 PATCH 9/9] test/monitor.sh: Partially skip monitor test " Shivaprasad G Bhat

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.