All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Subject: [ndctl PATCH 5/6] test, daxctl: test dax region apis
Date: Sat, 10 Dec 2016 22:35:02 -0800	[thread overview]
Message-ID: <148143810220.11895.9642149313511155250.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <148143807638.11895.3823811556889353622.stgit@dwillia2-desk3.amr.corp.intel.com>

Spot check the new dax_region attributes available starting with kernel
v4.10.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/libndctl.c |   35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/test/libndctl.c b/test/libndctl.c
index 840376c34d32..c6e199dbb078 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -625,9 +625,12 @@ static int validate_dax(struct ndctl_dax *dax)
 	struct ndctl_namespace *ndns = ndctl_dax_get_namespace(dax);
 	const char *devname = ndctl_namespace_get_devname(ndns);
 	struct ndctl_region *region = ndctl_dax_get_region(dax);
-	struct daxctl_region *dax_region = NULL;
+	struct ndctl_ctx *ctx = ndctl_dax_get_ctx(dax);
+	struct ndctl_test *test = ndctl_get_private_data(ctx);
+	struct daxctl_region *dax_region = NULL, *found;
 	int rc = -ENXIO, fd, count, dax_expect;
 	struct daxctl_dev *dax_dev, *seed;
+	struct daxctl_ctx *dax_ctx;
 	uuid_t uuid, region_uuid;
 	char devpath[50];
 
@@ -638,6 +641,35 @@ static int validate_dax(struct ndctl_dax *dax)
 		return -ENXIO;
 	}
 
+	dax_ctx = ndctl_get_daxctl_ctx(ctx);
+	count = 0;
+	daxctl_region_foreach(dax_ctx, found)
+		if (found == dax_region)
+			count++;
+	if (count != 1) {
+		fprintf(stderr, "%s: failed to iterate to single region instance\n",
+				devname);
+		return -ENXIO;
+	}
+
+	if (ndctl_test_attempt(test, KERNEL_VERSION(4, 10, 0))) {
+		if (daxctl_region_get_size(dax_region)
+				!= ndctl_dax_get_size(dax)) {
+			fprintf(stderr, "%s: expect size: %llu != %llu\n",
+					devname, ndctl_dax_get_size(dax),
+					daxctl_region_get_size(dax_region));
+			return -ENXIO;
+		}
+
+		if (daxctl_region_get_align(dax_region)
+				!= ndctl_dax_get_align(dax)) {
+			fprintf(stderr, "%s: expect align: %lu != %lu\n",
+					devname, ndctl_dax_get_align(dax),
+					daxctl_region_get_align(dax_region));
+			return -ENXIO;
+		}
+	}
+
 	rc = -ENXIO;
 	ndctl_dax_get_uuid(dax, uuid);
 	daxctl_region_get_uuid(dax_region, region_uuid);
@@ -2646,6 +2678,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
 	ndctl_set_log_priority(ctx, loglevel);
 	daxctl_ctx = ndctl_get_daxctl_ctx(ctx);
 	daxctl_set_log_priority(daxctl_ctx, loglevel);
+	ndctl_set_private_data(ctx, test);
 
 	kmod_ctx = kmod_new(NULL, NULL);
 	if (!kmod_ctx)

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  parent reply	other threads:[~2016-12-11  6:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-11  6:34 [ndctl PATCH 0/6] updates for device-dax sub-division support Dan Williams
2016-12-11  6:34 ` [ndctl PATCH 1/6] util, sysfs: convert add_dev_fn to return the device Dan Williams
2016-12-11  6:34 ` [ndctl PATCH 2/6] libdaxctl: add daxctl_region_get_{id, size, align} apis Dan Williams
2016-12-11  6:34 ` [ndctl PATCH 3/6] daxctl: add dax region iteration apis Dan Williams
2016-12-11  6:34 ` [ndctl PATCH 4/6] ndctl: add per-context private data Dan Williams
2016-12-11  6:35 ` Dan Williams [this message]
2016-12-11  6:35 ` [ndctl PATCH 6/6] daxctl: add daxctl_dev_set_size() 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=148143810220.11895.9642149313511155250.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.