Skip to content

Commit 4e7fab1

Browse files
committed
test: add interleave set compatibility test
Per the realization that Linux was incompatible with other implementations of the interleave-set-cookie algorithm [1], add a regression test to check for compatibility with the original Linux implementation. This also serves as a unit test for the new 'write-labels' command. [1]: commit 86ef58a4e35e ("nfit, libnvdimm: fix interleave set cookie calculation") Reported-by: Nicholas Moulin <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent a81bcf7 commit 4e7fab1

File tree

6 files changed

+63
-1
lines changed

6 files changed

+63
-1
lines changed

test/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ TESTS =\
1010
clear.sh \
1111
dax-errors.sh \
1212
daxdev-errors.sh \
13-
btt-check.sh
13+
btt-check.sh \
14+
label-compat.sh
1415

1516
check_PROGRAMS =\
1617
libndctl \

test/label-compat.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash -x
2+
NDCTL="../ndctl/ndctl"
3+
BUS="-b nfit_test.0"
4+
BUS1="-b nfit_test.1"
5+
rc=77
6+
7+
set -e
8+
9+
err() {
10+
echo "test/label-compat.sh: failed at line $1"
11+
exit $rc
12+
}
13+
14+
check_min_kver()
15+
{
16+
local ver="$1"
17+
: "${KVER:=$(uname -r)}"
18+
19+
[ -n "$ver" ] || return 1
20+
[[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
21+
}
22+
23+
check_min_kver "4.11" || { echo "kernel $KVER may not provide reliable isetcookie values"; exit $rc; }
24+
25+
set -e
26+
trap 'err $LINENO' ERR
27+
28+
# setup (reset nfit_test dimms)
29+
modprobe nfit_test
30+
$NDCTL disable-region $BUS all
31+
$NDCTL zero-labels $BUS all
32+
33+
# grab the largest pmem region on $BUS
34+
query=". | sort_by(.available_size) | reverse | .[0].dev"
35+
region=$($NDCTL list $BUS -t pmem -Ri | jq -r "$query")
36+
37+
# we assume that $region is comprised of 4 dimms
38+
query=". | .regions[0].mappings | sort_by(.dimm) | .[].dimm"
39+
dimms=$($NDCTL list -DRi -r $region | jq -r "$query" | xargs)
40+
i=1
41+
for d in $dimms
42+
do
43+
$NDCTL write-labels $d -i nmem${i}.bin
44+
i=$((i+1))
45+
done
46+
47+
$NDCTL enable-region $BUS all
48+
49+
len=$($NDCTL list -r 7 -N | jq -r "length")
50+
51+
if [ -z $len ]; then
52+
rc=1
53+
echo "failed to find legacy isetcookie namespace"
54+
exit 1
55+
fi
56+
57+
$NDCTL disable-region $BUS all
58+
$NDCTL disable-region $BUS1 all
59+
modprobe -r nfit_test
60+
61+
exit 0

test/nmem1.bin

128 KB
Binary file not shown.

test/nmem2.bin

128 KB
Binary file not shown.

test/nmem3.bin

128 KB
Binary file not shown.

test/nmem4.bin

128 KB
Binary file not shown.

0 commit comments

Comments
 (0)