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