diff mbox

[ndctl,3/5] test, libndctl: gate ndctl_namespace_get_mode() on v4.5+

Message ID 149272195485.23427.477956361004200064.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit 263708cdfa3e
Headers show

Commit Message

Dan Williams April 20, 2017, 8:59 p.m. UTC
This support was added upstream with commit 0731de0dd95b "libnvdimm, pfn:
move 'memory mode' indication to sysfs".

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/libndctl.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/test/libndctl.c b/test/libndctl.c
index f5a6abe50edd..38a0bb746905 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -1033,6 +1033,8 @@  static int check_btt_size(struct ndctl_btt *btt)
 static int check_btt_create(struct ndctl_region *region, struct ndctl_namespace *ndns,
 		struct namespace *namespace)
 {
+	struct ndctl_ctx *ctx = ndctl_region_get_ctx(region);
+	struct ndctl_test *test = ndctl_get_private_data(ctx);
 	struct btt *btt_s = namespace->btt_settings;
 	int i, fd, retry = 10;
 	struct ndctl_btt *btt;
@@ -1070,10 +1072,13 @@  static int check_btt_create(struct ndctl_region *region, struct ndctl_namespace
 			goto err;
 		}
 
-		mode = ndctl_namespace_get_mode(ndns);
-		if (mode >= 0 && mode != NDCTL_NS_MODE_SAFE)
-			fprintf(stderr, "%s: expected safe mode got: %d\n",
-					devname, mode);
+		/* prior to v4.5 the mode attribute did not exist */
+		if (ndctl_test_attempt(test, KERNEL_VERSION(4, 5, 0))) {
+			mode = ndctl_namespace_get_mode(ndns);
+			if (mode >= 0 && mode != NDCTL_NS_MODE_SAFE)
+				fprintf(stderr, "%s: expected safe mode got: %d\n",
+						devname, mode);
+		}
 
 		rc = check_btt_size(btt);
 		if (rc)