ndctl, test: add a new unit test for max_available_extent namespace
PATCH v2 1/1 ndctl, test: add a new unit test for max_available_extent namespace
From: Masayoshi Mizuma <[email protected]>
Add a new unit test to test max_available_extent namespace. This feature is implemented by the following patches.
kernel side:
https://lists.01.org/pipermail/linux-nvdimm/2018-July/016731.html https://lists.01.org/pipermail/linux-nvdimm/2018-July/016732.html
ndctl side:
https://lists.01.org/pipermail/linux-nvdimm/2018-July/017176.html
--- test/Makefile.am | 3 ++- test/max_available_extent_ns.sh | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 test/max_available_extent_ns.sh
test/Makefile.am +2 -1
@@ -22,7 +22,8 @@ TESTS =\ firmware-update.sh \ ack-shutdown-count-set \ rescan-partitions.sh \ - monitor.sh + monitor.sh \ + max_available_extent_ns.sh check_PROGRAMS =\ libndctl \
test/max_available_extent_ns.sh new file +43 -0
43 lines not on this page · raw message
Signature · 6 lines
2.18.0 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Verma, Vishal L
maintainerQuoted 52 lines · Masayoshi Mizuma
From: Masayoshi Mizuma <[email protected]>
Add a new unit test to test
max_available_extentnamespace. This feature is implemented by the following patches.kernel side:
https://lists.01.org/pipermail/linux-nvdimm/2018-July/016731.html https://lists.01.org/pipermail/linux-nvdimm/2018-July/016732.htmlndctl side:
https://lists.01.org/pipermail/linux-nvdimm/2018-July/017176.htmlSigned-off-by Masayoshi Mizuma <[email protected]>--- test/Makefile.am | 3 ++- test/max_available_extent_ns.sh | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 test/max_available_extent_ns.shtest/Makefile.am +2
-1@@ -22,7 +22,8 @@ TESTS =\ firmware-update.sh \ ack-shutdown-count-set \ rescan-partitions.sh \ - monitor.sh + monitor.sh \ + max_available_extent_ns.sh check_PROGRAMS =\ libndctl \test/max_available_extent_ns.sh new file +13
-0@@ -0,0 +1,43 @@ +#!/bin/bash -Ex + +# SPDX-License-Identifier: GPL-2.0 +# Copyright(c) 2018, FUJITSU LIMITED. All rights reserved. + +rc=77 + +. ./common + +trap 'err $LINENO' ERR + +check_min_kver "4.19" || do_skip "kernel $KVER may not support max_available_size" +
test/max_available_extent_ns.sh line 23
Quoted 10 lines
test/max_available_extent_ns.sh new file +10
-0+init() +{ + $NDCTL disable-region -b $NFIT_TEST_BUS0 all + $NDCTL zero-labels -b $NFIT_TEST_BUS0 all + $NDCTL enable-region -b $NFIT_TEST_BUS0 all +} + +do_test() +{ + region=$($NDCTL list -b $NFIT_TEST_BUS0 -R -t pmem | jq -r .[].dev | head -1)
On my test setup, this fails because the region returned is the 32M one. This causes the namespaces requested to be 8M sized, which is too small, and hence rejected (16M minimum).
The following jq query sorts it in descending size order and lets it choose the 64M region:
jq -r 'sort_by(-.size) | .[].dev'
test/max_available_extent_ns.sh line 30
Quoted 7 lines
test/max_available_extent_ns.sh new file +7
-0+ + available_sz=$($NDCTL list -r $region | jq -r .[].available_size) + size=$(( available_sz/4 )) + + NS1=$($NDCTL create-namespace -r $region -t pmem -s $size | jq -r .dev) + NS2=$($NDCTL create-namespace -r $region -t pmem -s $size | jq -r .dev) + NS3=$($NDCTL create-namespace -r $region -t pmem -s $size | jq -r .dev)
Since these happen in a subshell, errors are lost. Running in a subshell is fine, but we should test that the variables weren't blank:
test -n "$NS1"
And so on.
test/max_available_extent_ns.sh line 43
Quoted 13 lines
test/max_available_extent_ns.sh new file +13
-0+ + $NDCTL disable-namespace $NS2 + $NDCTL destroy-namespace $NS2 + + $NDCTL create-namespace -r $region -t pmem +} + +modprobe nfit_test +rc=1 +init +do_test +_cleanup +exit 0
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Hi Vishal,
Thank you for your review! I'll fix and send v3.
Thanks,
Masa
Quoted 90 lines · Vishal L
Quoted 52 lines · Masayoshi Mizuma
From: Masayoshi Mizuma <[email protected]>
Add a new unit test to test
max_available_extentnamespace. This feature is implemented by the following patches.kernel side:
https://lists.01.org/pipermail/linux-nvdimm/2018-July/016731.html https://lists.01.org/pipermail/linux-nvdimm/2018-July/016732.htmlndctl side:
https://lists.01.org/pipermail/linux-nvdimm/2018-July/017176.htmlSigned-off-by Masayoshi Mizuma <[email protected]>--- test/Makefile.am | 3 ++- test/max_available_extent_ns.sh | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 test/max_available_extent_ns.shtest/Makefile.am +2
-1@@ -22,7 +22,8 @@ TESTS =\ firmware-update.sh \ ack-shutdown-count-set \ rescan-partitions.sh \ - monitor.sh + monitor.sh \ + max_available_extent_ns.sh check_PROGRAMS =\ libndctl \test/max_available_extent_ns.sh new file +13
-0@@ -0,0 +1,43 @@ +#!/bin/bash -Ex + +# SPDX-License-Identifier: GPL-2.0 +# Copyright(c) 2018, FUJITSU LIMITED. All rights reserved. + +rc=77 + +. ./common + +trap 'err $LINENO' ERR + +check_min_kver "4.19" || do_skip "kernel $KVER may not support max_available_size" +test/max_available_extent_ns.sh line 23
Quoted 10 lines
test/max_available_extent_ns.sh new file +10
-0+init() +{ + $NDCTL disable-region -b $NFIT_TEST_BUS0 all + $NDCTL zero-labels -b $NFIT_TEST_BUS0 all + $NDCTL enable-region -b $NFIT_TEST_BUS0 all +} + +do_test() +{ + region=$($NDCTL list -b $NFIT_TEST_BUS0 -R -t pmem | jq -r .[].dev | head -1)On my test setup, this fails because the region returned is the 32M one. This causes the namespaces requested to be 8M sized, which is too small, and hence rejected (16M minimum).
The following jq query sorts it in descending size order and lets it choose the 64M region:
jq -r 'sort_by(-.size) | .[].dev'test/max_available_extent_ns.sh line 30
Quoted 7 lines
test/max_available_extent_ns.sh new file +7
-0+ + available_sz=$($NDCTL list -r $region | jq -r .[].available_size) + size=$(( available_sz/4 )) + + NS1=$($NDCTL create-namespace -r $region -t pmem -s $size | jq -r .dev) + NS2=$($NDCTL create-namespace -r $region -t pmem -s $size | jq -r .dev) + NS3=$($NDCTL create-namespace -r $region -t pmem -s $size | jq -r .dev)Since these happen in a subshell, errors are lost. Running in a subshell is fine, but we should test that the variables weren't blank:
test -n "$NS1"And so on.
Quoted 13 lines
test/max_available_extent_ns.sh line 43
Quoted 13 lines
test/max_available_extent_ns.sh new file +13
-0+ + $NDCTL disable-namespace $NS2 + $NDCTL destroy-namespace $NS2 + + $NDCTL create-namespace -r $region -t pmem +} + +modprobe nfit_test +rc=1 +init +do_test +_cleanup +exit 0
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm