|
|
e0018b |
From f149f539e874415c0ec19b43a2c9bf2c56f3aa80 Mon Sep 17 00:00:00 2001
|
|
|
e0018b |
From: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
e0018b |
Date: Wed, 13 Jul 2022 14:37:58 -0600
|
|
|
e0018b |
Subject: [PATCH 187/217] cxl/test: add a test to {read,write,zero}-labels
|
|
|
e0018b |
|
|
|
e0018b |
Add a unit test to test writing, reading, and zeroing LSA aread for
|
|
|
e0018b |
cxl_test based memdevs using ndctl commands, and reading using cxl-cli
|
|
|
e0018b |
commands to exercise that route as much as possible.
|
|
|
e0018b |
|
|
|
e0018b |
Note that writing using cxl-cli requires a bit more enabling to enable,
|
|
|
e0018b |
as the corresponding nvdimm-bridge object will need to be disabled
|
|
|
e0018b |
first.
|
|
|
e0018b |
|
|
|
e0018b |
Link: https://lore.kernel.org/r/20220713203758.519892-1-vishal.l.verma@intel.com
|
|
|
e0018b |
Cc: Dan Williams <dan.j.williams@intel.com>
|
|
|
e0018b |
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
e0018b |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
e0018b |
---
|
|
|
e0018b |
test/cxl-labels.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
e0018b |
test/meson.build | 2 ++
|
|
|
e0018b |
2 files changed, 71 insertions(+)
|
|
|
e0018b |
create mode 100644 test/cxl-labels.sh
|
|
|
e0018b |
|
|
|
e0018b |
diff --git a/test/cxl-labels.sh b/test/cxl-labels.sh
|
|
|
e0018b |
new file mode 100644
|
|
|
e0018b |
index 0000000..e782e2d
|
|
|
e0018b |
--- /dev/null
|
|
|
e0018b |
+++ b/test/cxl-labels.sh
|
|
|
e0018b |
@@ -0,0 +1,69 @@
|
|
|
e0018b |
+#!/bin/bash
|
|
|
e0018b |
+# SPDX-License-Identifier: GPL-2.0
|
|
|
e0018b |
+# Copyright (C) 2022 Intel Corporation. All rights reserved.
|
|
|
e0018b |
+
|
|
|
e0018b |
+. $(dirname $0)/common
|
|
|
e0018b |
+
|
|
|
e0018b |
+rc=1
|
|
|
e0018b |
+
|
|
|
e0018b |
+set -ex
|
|
|
e0018b |
+
|
|
|
e0018b |
+trap 'err $LINENO' ERR
|
|
|
e0018b |
+
|
|
|
e0018b |
+check_prereq "jq"
|
|
|
e0018b |
+
|
|
|
e0018b |
+modprobe -r cxl_test
|
|
|
e0018b |
+modprobe cxl_test
|
|
|
e0018b |
+udevadm settle
|
|
|
e0018b |
+
|
|
|
e0018b |
+test_label_ops()
|
|
|
e0018b |
+{
|
|
|
e0018b |
+ nmem="$1"
|
|
|
e0018b |
+ lsa=$(mktemp /tmp/lsa-$nmem.XXXX)
|
|
|
e0018b |
+ lsa_read=$(mktemp /tmp/lsa-read-$nmem.XXXX)
|
|
|
e0018b |
+
|
|
|
e0018b |
+ # determine LSA size
|
|
|
e0018b |
+ "$NDCTL" read-labels -o "$lsa_read" "$nmem"
|
|
|
e0018b |
+ lsa_size=$(stat -c %s "$lsa_read")
|
|
|
e0018b |
+
|
|
|
e0018b |
+ dd "if=/dev/urandom" "of=$lsa" "bs=$lsa_size" "count=1"
|
|
|
e0018b |
+ "$NDCTL" write-labels -i "$lsa" "$nmem"
|
|
|
e0018b |
+ "$NDCTL" read-labels -o "$lsa_read" "$nmem"
|
|
|
e0018b |
+
|
|
|
e0018b |
+ # compare what was written vs read
|
|
|
e0018b |
+ diff "$lsa" "$lsa_read"
|
|
|
e0018b |
+
|
|
|
e0018b |
+ # zero the LSA and test
|
|
|
e0018b |
+ "$NDCTL" zero-labels "$nmem"
|
|
|
e0018b |
+ dd "if=/dev/zero" "of=$lsa" "bs=$lsa_size" "count=1"
|
|
|
e0018b |
+ "$NDCTL" read-labels -o "$lsa_read" "$nmem"
|
|
|
e0018b |
+ diff "$lsa" "$lsa_read"
|
|
|
e0018b |
+
|
|
|
e0018b |
+ # cleanup
|
|
|
e0018b |
+ rm "$lsa" "$lsa_read"
|
|
|
e0018b |
+}
|
|
|
e0018b |
+
|
|
|
e0018b |
+test_label_ops_cxl()
|
|
|
e0018b |
+{
|
|
|
e0018b |
+ mem="$1"
|
|
|
e0018b |
+ lsa_read=$(mktemp /tmp/lsa-read-$mem.XXXX)
|
|
|
e0018b |
+
|
|
|
e0018b |
+ "$CXL" read-labels -o "$lsa_read" "$mem"
|
|
|
e0018b |
+ rm "$lsa_read"
|
|
|
e0018b |
+}
|
|
|
e0018b |
+
|
|
|
e0018b |
+# test reading labels directly through cxl-cli
|
|
|
e0018b |
+readarray -t mems < <("$CXL" list -b cxl_test -Mi | jq -r '.[].memdev')
|
|
|
e0018b |
+
|
|
|
e0018b |
+for mem in ${mems[@]}; do
|
|
|
e0018b |
+ test_label_ops_cxl "$mem"
|
|
|
e0018b |
+done
|
|
|
e0018b |
+
|
|
|
e0018b |
+# find nmem devices corresponding to cxl memdevs
|
|
|
e0018b |
+readarray -t nmems < <("$NDCTL" list -b cxl_test -Di | jq -r '.[].dev')
|
|
|
e0018b |
+
|
|
|
e0018b |
+for nmem in ${nmems[@]}; do
|
|
|
e0018b |
+ test_label_ops "$nmem"
|
|
|
e0018b |
+done
|
|
|
e0018b |
+
|
|
|
e0018b |
+modprobe -r cxl_test
|
|
|
e0018b |
diff --git a/test/meson.build b/test/meson.build
|
|
|
e0018b |
index 3203d9c..b382f46 100644
|
|
|
e0018b |
--- a/test/meson.build
|
|
|
e0018b |
+++ b/test/meson.build
|
|
|
e0018b |
@@ -152,6 +152,7 @@ pfn_meta_errors = find_program('pfn-meta-errors.sh')
|
|
|
e0018b |
track_uuid = find_program('track-uuid.sh')
|
|
|
e0018b |
cxl_topo = find_program('cxl-topology.sh')
|
|
|
e0018b |
cxl_sysfs = find_program('cxl-region-sysfs.sh')
|
|
|
e0018b |
+cxl_labels = find_program('cxl-labels.sh')
|
|
|
e0018b |
|
|
|
e0018b |
tests = [
|
|
|
e0018b |
[ 'libndctl', libndctl, 'ndctl' ],
|
|
|
e0018b |
@@ -178,6 +179,7 @@ tests = [
|
|
|
e0018b |
[ 'track-uuid.sh', track_uuid, 'ndctl' ],
|
|
|
e0018b |
[ 'cxl-topology.sh', cxl_topo, 'cxl' ],
|
|
|
e0018b |
[ 'cxl-region-sysfs.sh', cxl_sysfs, 'cxl' ],
|
|
|
e0018b |
+ [ 'cxl-labels.sh', cxl_labels, 'cxl' ],
|
|
|
e0018b |
]
|
|
|
e0018b |
|
|
|
e0018b |
if get_option('destructive').enabled()
|
|
|
e0018b |
--
|
|
|
e0018b |
2.27.0
|
|
|
e0018b |
|