diff mbox

[ndctl,v2] ndctl, test: unit test updates for the BTT 2.0 format

Message ID 20170630200029.11797-1-vishal.l.verma@intel.com (mailing list archive)
State Accepted
Commit 3a60f3b9fb7a
Headers show

Commit Message

Verma, Vishal L June 30, 2017, 8 p.m. UTC
With the BTT 2.0 update, a couple of minor updates to the unit tests are
needed:
test/libndctl: Update expected BTT sizes
test/libndctl: in btt_autodetect, when wiping an old BTT, wipe the first
two 4K pages instead of one.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---

v2:
 - Move the new BTT size check under a 4.13.0 attempt (Dan)

 test/libndctl.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

Comments

Dan Williams July 1, 2017, 1:59 a.m. UTC | #1
On Fri, Jun 30, 2017 at 1:00 PM, Vishal Verma <vishal.l.verma@intel.com> wrote:
> With the BTT 2.0 update, a couple of minor updates to the unit tests are
> needed:
> test/libndctl: Update expected BTT sizes
> test/libndctl: in btt_autodetect, when wiping an old BTT, wipe the first
> two 4K pages instead of one.
>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>
> v2:
>  - Move the new BTT size check under a 4.13.0 attempt (Dan)

Fair enough, applied.
diff mbox

Patch

diff --git a/test/libndctl.c b/test/libndctl.c
index 24aff36..0f67d54 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -994,16 +994,16 @@  static int check_btt_size(struct ndctl_btt *btt)
 	int size_select, sect_select;
 	unsigned long long expect_table[][2] = {
 		[0] = {
-			[0] = 0x11b4400,
-			[1] = 0x8da2000,
+			[0] = 0x11b5400,
+			[1] = 0x8daa000,
 		},
 		[1] = {
-			[0] = 0x13b0400,
-			[1] = 0x9d82000,
+			[0] = 0x13b1400,
+			[1] = 0x9d8a000,
 		},
 		[2] = {
-			[0] = 0x1aa2600,
-			[1] = 0xd513000,
+			[0] = 0x1aa3600,
+			[1] = 0xd51b000,
 		},
 	};
 
@@ -1107,9 +1107,12 @@  static int check_btt_create(struct ndctl_region *region, struct ndctl_namespace
 						devname, mode);
 		}
 
-		rc = check_btt_size(btt);
-		if (rc)
-			goto err;
+		/* prior to v4.13 the expected sizes were different due to BTT1.1 */
+		if (ndctl_test_attempt(test, KERNEL_VERSION(4, 13, 0))) {
+			rc = check_btt_size(btt);
+			if (rc)
+				goto err;
+		}
 
 		if (btt_seed == ndctl_region_get_btt_seed(region)
 				&& btt == btt_seed) {
@@ -1517,12 +1520,19 @@  static int check_btt_autodetect(struct ndctl_bus *bus,
 	}
 
 	memset(buf, 0, 4096);
+	/* Delete both the first and second 4K pages */
 	rc = pwrite(fd, buf, 4096, 4096);
 	if (rc < 4096) {
 		rc = -ENXIO;
 		fprintf(stderr, "%s: failed to overwrite btt on %s\n",
 				devname, bdev);
 	}
+	rc = pwrite(fd, buf, 4096, 0);
+	if (rc < 4096) {
+		rc = -ENXIO;
+		fprintf(stderr, "%s: failed to overwrite btt on %s\n",
+				devname, bdev);
+	}
  out:
 	ndctl_region_set_ro(region, namespace->ro);
 	ndctl_namespace_set_raw_mode(ndns, 0);