From: Vishal Verma <vishal.l.verma@intel.com>
To: <linux-cxl@vger.kernel.org>
Cc: <nvdimm@lists.linux.dev>, Dan Williams <dan.j.williams@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>
Subject: [ndctl PATCH] cxl/test: add a test to {read,write,zero}-labels
Date: Wed, 13 Jul 2022 01:51:57 -0600 [thread overview]
Message-ID: <20220713075157.411479-1-vishal.l.verma@intel.com> (raw)
Add a unit test to test writing, reading, and zeroing LSA aread for
cxl_test based memdevs using ndctl commands.
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
test/cxl-labels.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++
test/meson.build | 2 ++
2 files changed, 55 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..ce73963
--- /dev/null
+++ b/test/cxl-labels.sh
@@ -0,0 +1,53 @@
+#!/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"
+}
+
+# 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 fbcfc08..687a71f 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_region = find_program('cxl-region-create.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-create.sh', cxl_region, 'cxl' ],
+ [ 'cxl-labels.sh', cxl_labels, 'cxl' ],
]
if get_option('destructive').enabled()
--
2.36.1
next reply other threads:[~2022-07-13 7:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-13 7:51 Vishal Verma [this message]
2022-07-13 18:50 ` [ndctl PATCH] cxl/test: add a test to {read,write,zero}-labels Davidlohr Bueso
2022-07-13 19:00 ` Verma, Vishal L
2022-07-13 19:47 ` Dan Williams
2022-07-13 20:23 ` Verma, Vishal L
2022-07-13 18:52 ` Dan Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220713075157.411479-1-vishal.l.verma@intel.com \
--to=vishal.l.verma@intel.com \
--cc=dan.j.williams@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).