Skip to contentSkip to conversation

ndctl, test: add a unit test for partition rescanning

PATCH In review Vishal Verma 2 participants 7 messages Mar 5, 2018 – Mar 6, 2018 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/1 ndctl, test: add a unit test for partition rescanning

pre-4.16 kernels had a bug where BTT partitions wouldn't come up on driver probe because we were adding a zero-sized disk. Add a unit test that creates partitions, and cycles the namespace to ensure the partitions are automatically brought up. This performs the test for raw, memory, and sector modes.

---
 test/Makefile.am          |   3 +-
 test/rescan-partitions.sh | 106 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100755 test/rescan-partitions.sh
test/Makefile.am +2 -1
index 749055c..496a663 100644
@@ -20,7 +20,8 @@ TESTS =\
 	hugetlb \
 	btt-pad-compat.sh \
 	firmware-update.sh \
-	ack-shutdown-count-set
+	ack-shutdown-count-set \
+	rescan-partitions.sh
 
 check_PROGRAMS =\
 	libndctl \
test/rescan-partitions.sh new file +106 -0

106 lines not on this page · raw message

Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 68 lines · Vishal Verma

pre-4.16 kernels had a bug where BTT partitions wouldn't come up on driver probe because we were adding a zero-sized disk. Add a unit test that creates partitions, and cycles the namespace to ensure the partitions are automatically brought up. This performs the test for raw, memory, and sector modes.

---
 test/Makefile.am          |   3 +-
 test/rescan-partitions.sh | 106 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100755 test/rescan-partitions.sh
test/Makefile.am +2 -1
index 749055c..496a663 100644
@@ -20,7 +20,8 @@ TESTS =\
        hugetlb \
        btt-pad-compat.sh \
        firmware-update.sh \
-       ack-shutdown-count-set
+       ack-shutdown-count-set \
+       rescan-partitions.sh
 
 check_PROGRAMS =\
        libndctl \
test/rescan-partitions.sh new file +33 -0
new file mode 100755
index 0000000..6dd289b
@@ -0,0 +1,106 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2018 Intel Corporation. All rights reserved.
+
+[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] && ndctl="../ndctl/ndctl"
+[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl"
+[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1
+bus="nfit_test.0"
+json2var="s/[{}\",]//g; s/:/=/g"
+dev=""
+size=""
+blockdev=""
+rc=77
+
+trap 'err $LINENO' ERR
+
+# sample json:
+#{
+#  "dev":"namespace5.0",
+#  "mode":"sector",
+#  "size":"60.00 MiB (62.92 MB)",
+#  "uuid":"f1baa71a-d165-4da4-bb6a-083a2b0e6469",
+#  "blockdev":"pmem5s",
+#}
+
+# $1: Line number
+# $2: exit code
+err()
+{
+       [ -n "$2" ] && rc="$2"
+       echo "test/rescan-partitions.sh: failed at line $1"
+       exit "$rc"
+}

test/rescan-partitions.sh line 43

Quoted 10 lines
test/rescan-partitions.sh new file +10 -0
+
+check_min_kver()
+{
+       local ver="$1"
+       : "${KVER:=$(uname -r)}"
+
+       [ -n "$ver" ] || return 1
+       [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
+}
+check_min_kver "4.16" || { echo "kernel $KVER may not contain fixes for partition rescanning"; exit "$rc"; }

I have a proposal for kernel version checks going forward. How about tests that fail the kernel version check return SKIP / PASS, and kernels that pass the kernel version check return FAIL / PASS for the test. This way we don't bail out early on backport kernels that could otherwise pass the test.

Thoughts?
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#2 lore raw
Quoted 94 lines · Dan Williams
Quoted 84 lines · Vishal Verma

pre-4.16 kernels had a bug where BTT partitions wouldn't come up on driver probe because we were adding a zero-sized disk. Add a unit test
that creates partitions, and cycles the namespace to ensure the partitions are automatically brought up. This performs the test for raw,
memory, and sector modes.

---
 test/Makefile.am          |   3 +-
 test/rescan-partitions.sh | 106
++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100755 test/rescan-partitions.sh
test/Makefile.am +2 -1
index 749055c..496a663 100644
@@ -20,7 +20,8 @@ TESTS =\
        hugetlb \
        btt-pad-compat.sh \
        firmware-update.sh \
-       ack-shutdown-count-set
+       ack-shutdown-count-set \
+       rescan-partitions.sh
 
 check_PROGRAMS =\
        libndctl \
test/rescan-partitions.sh new file +5 -0
new file mode 100755
index 0000000..6dd289b
@@ -0,0 +1,106 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2018 Intel Corporation. All rights reserved.
+
+[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] &&

ndctl="../ndctl/ndctl"
+[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl"
+[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1

test/rescan-partitions.sh new file +34 -0
+bus="nfit_test.0"
+json2var="s/[{}\",]//g; s/:/=/g"
+dev=""
+size=""
+blockdev=""
+rc=77
+
+trap 'err $LINENO' ERR
+
+# sample json:
+#{
+#  "dev":"namespace5.0",
+#  "mode":"sector",
+#  "size":"60.00 MiB (62.92 MB)",
+#  "uuid":"f1baa71a-d165-4da4-bb6a-083a2b0e6469",
+#  "blockdev":"pmem5s",
+#}
+
+# $1: Line number
+# $2: exit code
+err()
+{
+       [ -n "$2" ] && rc="$2"
+       echo "test/rescan-partitions.sh: failed at line $1"
+       exit "$rc"
+}
+
+check_min_kver()
+{
+       local ver="$1"
+       : "${KVER:=$(uname -r)}"
+
+       [ -n "$ver" ] || return 1
+       [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)"

]]

test/rescan-partitions.sh new file +2 -0
+}
+check_min_kver "4.16" || { echo "kernel $KVER may not contain
Quoted 1 line

fixes for partition rescanning"; exit "$rc"; }

I have a proposal for kernel version checks going forward. How about tests that fail the kernel version check return SKIP / PASS, and kernels that pass the kernel version check return FAIL / PASS for the test. This way we don't bail out early on backport kernels that could otherwise pass the test.

Quoted 1 line

Thoughts?

So do you mean, for example, if a kernel version check fails, don't skip immediately. Instead continue to run the test, and if something actually fails, then return with a SKIP.

And conversely, for a kernel version that passes the included check, no other condition can return a SKIP? (What about something like missing packages?)
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#3 lore raw
Quoted 98 lines · Vishal L
Quoted 94 lines · Dan Williams
Quoted 84 lines · Vishal Verma

pre-4.16 kernels had a bug where BTT partitions wouldn't come up on driver probe because we were adding a zero-sized disk. Add a unit test
that creates partitions, and cycles the namespace to ensure the partitions are automatically brought up. This performs the test for raw,
memory, and sector modes.

---
 test/Makefile.am          |   3 +-
 test/rescan-partitions.sh | 106
++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100755 test/rescan-partitions.sh
test/Makefile.am +2 -1
index 749055c..496a663 100644
@@ -20,7 +20,8 @@ TESTS =\
        hugetlb \
        btt-pad-compat.sh \
        firmware-update.sh \
-       ack-shutdown-count-set
+       ack-shutdown-count-set \
+       rescan-partitions.sh
 
 check_PROGRAMS =\
        libndctl \
test/rescan-partitions.sh new file +5 -0
new file mode 100755
index 0000000..6dd289b
@@ -0,0 +1,106 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2018 Intel Corporation. All rights reserved.
+
+[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] &&

ndctl="../ndctl/ndctl"
+[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl"
+[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1

test/rescan-partitions.sh new file +34 -0
+bus="nfit_test.0"
+json2var="s/[{}\",]//g; s/:/=/g"
+dev=""
+size=""
+blockdev=""
+rc=77
+
+trap 'err $LINENO' ERR
+
+# sample json:
+#{
+#  "dev":"namespace5.0",
+#  "mode":"sector",
+#  "size":"60.00 MiB (62.92 MB)",
+#  "uuid":"f1baa71a-d165-4da4-bb6a-083a2b0e6469",
+#  "blockdev":"pmem5s",
+#}
+
+# $1: Line number
+# $2: exit code
+err()
+{
+       [ -n "$2" ] && rc="$2"
+       echo "test/rescan-partitions.sh: failed at line $1"
+       exit "$rc"
+}
+
+check_min_kver()
+{
+       local ver="$1"
+       : "${KVER:=$(uname -r)}"
+
+       [ -n "$ver" ] || return 1
+       [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)"

]]

test/rescan-partitions.sh new file +2 -0
+}
+check_min_kver "4.16" || { echo "kernel $KVER may not contain
Quoted 1 line

fixes for partition rescanning"; exit "$rc"; }

I have a proposal for kernel version checks going forward. How about tests that fail the kernel version check return SKIP / PASS, and kernels that pass the kernel version check return FAIL / PASS for the test. This way we don't bail out early on backport kernels that could otherwise pass the test.

Quoted 1 line

Thoughts?

Quoted 7 lines

So do you mean, for example, if a kernel version check fails, don't skip immediately. Instead continue to run the test, and if something actually fails, then return with a SKIP.

And conversely, for a kernel version that passes the included check, no other condition can return a SKIP? (What about something like missing packages?)

Yeah, how about an unmet dependency whether it is kernel version or support package results in a SKIP / PASS result, but if all dependencies are met the test becomes FAIL / PASS?
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#4 lore raw
Quoted 121 lines · Dan Williams
Quoted 113 lines · Vishal L
Quoted 104 lines · Dan Williams
Quoted 90 lines · Vishal Verma

pre-4.16 kernels had a bug where BTT partitions wouldn't come up on
driver probe because we were adding a zero-sized disk. Add a unit
test
that creates partitions, and cycles the namespace to ensure the partitions are automatically brought up. This performs the test for
raw,
memory, and sector modes.

---
 test/Makefile.am          |   3 +-
 test/rescan-partitions.sh | 106
++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100755 test/rescan-partitions.sh
test/Makefile.am +2 -1
index 749055c..496a663 100644
@@ -20,7 +20,8 @@ TESTS =\
        hugetlb \
        btt-pad-compat.sh \
        firmware-update.sh \
-       ack-shutdown-count-set
+       ack-shutdown-count-set \
+       rescan-partitions.sh
 
 check_PROGRAMS =\
        libndctl \
test/rescan- renamed from test/rescan-partitions.sh +0 -0

partitions.sh
new file mode 100755
index 0000000..6dd289b

test/rescan-partitions.sh new file +5 -0
@@ -0,0 +1,106 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2018 Intel Corporation. All rights reserved.
+
+[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] &&

ndctl="../ndctl/ndctl"
+[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl"
+[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1

test/rescan-partitions.sh new file +34 -1
+bus="nfit_test.0"
+json2var="s/[{}\",]//g; s/:/=/g"
+dev=""
+size=""
+blockdev=""
+rc=77
+
+trap 'err $LINENO' ERR
+
+# sample json:
+#{
+#  "dev":"namespace5.0",
+#  "mode":"sector",
+#  "size":"60.00 MiB (62.92 MB)",
+#  "uuid":"f1baa71a-d165-4da4-bb6a-083a2b0e6469",
+#  "blockdev":"pmem5s",
+#}
+
+# $1: Line number
+# $2: exit code
+err()
+{
+       [ -n "$2" ] && rc="$2"
+       echo "test/rescan-partitions.sh: failed at line $1"
+       exit "$rc"
+}
+
+check_min_kver()
+{
+       local ver="$1"
+       : "${KVER:=$(uname -r)}"
+
+       [ -n "$ver" ] || return 1
+       [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head
-1)"

]]

test/rescan-partitions.sh new file +2 -0
+}
+check_min_kver "4.16" || { echo "kernel $KVER may not contain
Quoted 1 line

fixes for partition rescanning"; exit "$rc"; }

I have a proposal for kernel version checks going forward. How about
tests that fail the kernel version check return SKIP / PASS, and kernels that pass the kernel version check return FAIL / PASS for the
test. This way we don't bail out early on backport kernels that could
otherwise pass the test.

Quoted 1 line

Thoughts?

So do you mean, for example, if a kernel version check fails, don't skip immediately. Instead continue to run the test, and if something
actually fails, then return with a SKIP.

Quoted 5 lines

And conversely, for a kernel version that passes the included check, no
other condition can return a SKIP? (What about something like missing
packages?)

Quoted 3 lines

Yeah, how about an unmet dependency whether it is kernel version or support package results in a SKIP / PASS result, but if all dependencies are met the test becomes FAIL / PASS?

Yeah that makes sense to me.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#5 lore raw
Quoted 123 lines · Vishal L
Quoted 121 lines · Dan Williams
Quoted 118 lines · Vishal L
Quoted 104 lines · Dan Williams
Quoted 90 lines · Vishal Verma

pre-4.16 kernels had a bug where BTT partitions wouldn't come up on
driver probe because we were adding a zero-sized disk. Add a unit
test
that creates partitions, and cycles the namespace to ensure the partitions are automatically brought up. This performs the test for
raw,
memory, and sector modes.

---
 test/Makefile.am          |   3 +-
 test/rescan-partitions.sh | 106
++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100755 test/rescan-partitions.sh
test/Makefile.am +2 -1
index 749055c..496a663 100644
@@ -20,7 +20,8 @@ TESTS =\
        hugetlb \
        btt-pad-compat.sh \
        firmware-update.sh \
-       ack-shutdown-count-set
+       ack-shutdown-count-set \
+       rescan-partitions.sh
 
 check_PROGRAMS =\
        libndctl \
test/rescan- renamed from test/rescan-partitions.sh +0 -0

partitions.sh
new file mode 100755
index 0000000..6dd289b

test/rescan-partitions.sh new file +5 -0
@@ -0,0 +1,106 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2018 Intel Corporation. All rights reserved.
+
+[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] &&

ndctl="../ndctl/ndctl"
+[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl"
+[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1

test/rescan-partitions.sh new file +34 -1
+bus="nfit_test.0"
+json2var="s/[{}\",]//g; s/:/=/g"
+dev=""
+size=""
+blockdev=""
+rc=77
+
+trap 'err $LINENO' ERR
+
+# sample json:
+#{
+#  "dev":"namespace5.0",
+#  "mode":"sector",
+#  "size":"60.00 MiB (62.92 MB)",
+#  "uuid":"f1baa71a-d165-4da4-bb6a-083a2b0e6469",
+#  "blockdev":"pmem5s",
+#}
+
+# $1: Line number
+# $2: exit code
+err()
+{
+       [ -n "$2" ] && rc="$2"
+       echo "test/rescan-partitions.sh: failed at line $1"
+       exit "$rc"
+}
+
+check_min_kver()
+{
+       local ver="$1"
+       : "${KVER:=$(uname -r)}"
+
+       [ -n "$ver" ] || return 1
+       [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head
-1)"

]]

test/rescan-partitions.sh new file +2 -0
+}
+check_min_kver "4.16" || { echo "kernel $KVER may not contain
Quoted 1 line

fixes for partition rescanning"; exit "$rc"; }

I have a proposal for kernel version checks going forward. How about
tests that fail the kernel version check return SKIP / PASS, and kernels that pass the kernel version check return FAIL / PASS for the
test. This way we don't bail out early on backport kernels that could
otherwise pass the test.

Quoted 1 line

Thoughts?

So do you mean, for example, if a kernel version check fails, don't skip immediately. Instead continue to run the test, and if something
actually fails, then return with a SKIP.

And conversely, for a kernel version that passes the included check, no
other condition can return a SKIP? (What about something like missing
packages?)

Quoted 5 lines
Quoted 3 lines

Yeah, how about an unmet dependency whether it is kernel version or support package results in a SKIP / PASS result, but if all dependencies are met the test becomes FAIL / PASS?

Yeah that makes sense to me.

I also think it's past time that we made check_min_kver() a function in separate source file that all the shell tests import by sourcing.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author maintainer
#6 lore raw
Quoted 143 lines · Dan Williams
Quoted 141 lines · Vishal L
Quoted 138 lines · Dan Williams
Quoted 126 lines · Vishal L
Quoted 116 lines · Dan Williams

On Mon, Mar 5, 2018 at 3:56 PM, Vishal Verma <vishal.l.verma@ inte
l.co

Quoted 96 lines · m> wrote:

pre-4.16 kernels had a bug where BTT partitions wouldn't come
up on
driver probe because we were adding a zero-sized disk. Add a
unit
test
that creates partitions, and cycles the namespace to ensure the
partitions are automatically brought up. This performs the test
for
raw,
memory, and sector modes.

---
 test/Makefile.am          |   3 +-
 test/rescan-partitions.sh | 106
++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100755 test/rescan-partitions.sh
test/Makefile.am +2 -1
index 749055c..496a663 100644
@@ -20,7 +20,8 @@ TESTS =\
        hugetlb \
        btt-pad-compat.sh \
        firmware-update.sh \
-       ack-shutdown-count-set
+       ack-shutdown-count-set \
+       rescan-partitions.sh
 
 check_PROGRAMS =\
        libndctl \
test/rescan- renamed from test/rescan-partitions.sh +0 -0

partitions.sh
new file mode 100755
index 0000000..6dd289b

test/rescan-partitions.sh new file +3 -0
@@ -0,0 +1,106 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2018 Intel Corporation. All rights

reserved.
+
+[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] && ndctl="../ndctl/ndctl"
+[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl"
+[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1

test/rescan-partitions.sh new file +34 -0
+bus="nfit_test.0"
+json2var="s/[{}\",]//g; s/:/=/g"
+dev=""
+size=""
+blockdev=""
+rc=77
+
+trap 'err $LINENO' ERR
+
+# sample json:
+#{
+#  "dev":"namespace5.0",
+#  "mode":"sector",
+#  "size":"60.00 MiB (62.92 MB)",
+#  "uuid":"f1baa71a-d165-4da4-bb6a-083a2b0e6469",
+#  "blockdev":"pmem5s",
+#}
+
+# $1: Line number
+# $2: exit code
+err()
+{
+       [ -n "$2" ] && rc="$2"
+       echo "test/rescan-partitions.sh: failed at line $1"
+       exit "$rc"
+}
+
+check_min_kver()
+{
+       local ver="$1"
+       : "${KVER:=$(uname -r)}"
+
+       [ -n "$ver" ] || return 1
+       [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V |

head
-1)"
]]

test/rescan-partitions.sh new file +2 -0
+}
+check_min_kver "4.16" || { echo "kernel $KVER may not
Quoted 2 lines

contain
fixes for partition rescanning"; exit "$rc"; }

I have a proposal for kernel version checks going forward. How
about
tests that fail the kernel version check return SKIP / PASS, and
kernels that pass the kernel version check return FAIL / PASS for
the
test. This way we don't bail out early on backport kernels that
could
otherwise pass the test.

Quoted 1 line

Thoughts?

So do you mean, for example, if a kernel version check fails, don't
skip immediately. Instead continue to run the test, and if something
actually fails, then return with a SKIP.

Quoted 5 lines

And conversely, for a kernel version that passes the included check, no
other condition can return a SKIP? (What about something like missing
packages?)

Yeah, how about an unmet dependency whether it is kernel version or
support package results in a SKIP / PASS result, but if all dependencies are met the test becomes FAIL / PASS?

Quoted 4 lines
Quoted 1 line

Yeah that makes sense to me.

I also think it's past time that we made check_min_kver() a function in separate source file that all the shell tests import by sourcing.

There are definitely a fair number of boilerplate things that we've been copying around from test to test. I can take a shot at a cleanup.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm