@@ -575,7 +575,8 @@ static int check_regions(struct ndctl_bus *bus, struct region *regions, int n,
ndctl_region_get_type_name(region));
return -ENXIO;
}
- if (ndctl_region_get_interleave_ways(region) != regions[i].interleave_ways) {
+ if (ndctl_bus_has_nfit(bus) &&
+ ndctl_region_get_interleave_ways(region) != regions[i].interleave_ways) {
fprintf(stderr, "%s: expected interleave_ways: %d got: %d\n",
devname, regions[i].interleave_ways,
ndctl_region_get_interleave_ways(region));
@@ -2516,20 +2517,21 @@ static int check_dimms(struct ndctl_bus *bus, struct dimm *dimms, int n,
return -ENXIO;
}
- if (ndctl_dimm_has_errors(dimm) != !!dimms[i].flags) {
- fprintf(stderr, "bus: %s dimm%d %s expected%s errors\n",
+ if (ndctl_bus_has_nfit(bus)) {
+ if (ndctl_dimm_has_errors(dimm) != !!dimms[i].flags) {
+ fprintf(stderr, "bus: %s dimm%d %s expected%s errors\n",
ndctl_bus_get_provider(bus), i,
ndctl_dimm_get_devname(dimm),
dimms[i].flags ? "" : " no");
- return -ENXIO;
- }
+ return -ENXIO;
+ }
- if (ndctl_dimm_failed_save(dimm) != dimms[i].f_save
- || ndctl_dimm_failed_arm(dimm) != dimms[i].f_arm
- || ndctl_dimm_failed_restore(dimm) != dimms[i].f_restore
- || ndctl_dimm_smart_pending(dimm) != dimms[i].f_smart
- || ndctl_dimm_failed_flush(dimm) != dimms[i].f_flush) {
- fprintf(stderr, "expected: %s%s%s%s%sgot: %s%s%s%s%s\n",
+ if (ndctl_dimm_failed_save(dimm) != dimms[i].f_save
+ || ndctl_dimm_failed_arm(dimm) != dimms[i].f_arm
+ || ndctl_dimm_failed_restore(dimm) != dimms[i].f_restore
+ || ndctl_dimm_smart_pending(dimm) != dimms[i].f_smart
+ || ndctl_dimm_failed_flush(dimm) != dimms[i].f_flush) {
+ fprintf(stderr, "expected: %s%s%s%s%sgot: %s%s%s%s%s\n",
dimms[i].f_save ? "save_fail " : "",
dimms[i].f_arm ? "not_armed " : "",
dimms[i].f_restore ? "restore_fail " : "",
@@ -2540,24 +2542,25 @@ static int check_dimms(struct ndctl_bus *bus, struct dimm *dimms, int n,
ndctl_dimm_failed_restore(dimm) ? "restore_fail " : "",
ndctl_dimm_smart_pending(dimm) ? "smart_event " : "",
ndctl_dimm_failed_flush(dimm) ? "flush_fail " : "");
- return -ENXIO;
- }
+ return -ENXIO;
+ }
- if (ndctl_test_attempt(test, KERNEL_VERSION(4, 7, 0)) &&
- ndctl_bus_has_nfit(bus)) {
- if (ndctl_dimm_get_formats(dimm) != dimms[i].formats) {
- fprintf(stderr, "dimm%d expected formats: %d got: %d\n",
+ if (ndctl_test_attempt(test, KERNEL_VERSION(4, 7, 0))) {
+ if (ndctl_dimm_get_formats(dimm) != dimms[i].formats) {
+ fprintf(stderr, "dimm%d expected formats: %d got: %d\n",
i, dimms[i].formats,
ndctl_dimm_get_formats(dimm));
- return -ENXIO;
- }
- for (j = 0; j < dimms[i].formats; j++) {
- if (ndctl_dimm_get_formatN(dimm, j) != dimms[i].format[j]) {
- fprintf(stderr,
- "dimm%d expected format[%d]: %d got: %d\n",
+ return -ENXIO;
+ }
+ for (j = 0; j < dimms[i].formats; j++) {
+ if (ndctl_dimm_get_formatN(dimm, j) !=
+ dimms[i].format[j]) {
+ fprintf(stderr,
+ "dimm%d expected format[%d]: %d got: %d\n",
i, j, dimms[i].format[j],
ndctl_dimm_get_formatN(dimm, j));
- return -ENXIO;
+ return -ENXIO;
+ }
}
}
}
@@ -2623,6 +2626,7 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER0);
struct ndctl_region *region;
struct ndctl_dimm *dimm;
+ unsigned num_regions = ARRAY_SIZE(regions0);
int rc;
if (!bus)
@@ -2658,22 +2662,25 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
* ndctl_region_get_interleave_ways(region));
}
+ if (!ndctl_bus_has_nfit(bus))
+ num_regions = 1;
+
/* pfn and dax tests require vmalloc-enabled nfit_test */
if (ndctl_test_attempt(test, KERNEL_VERSION(4, 8, 0))) {
- rc = check_regions(bus, regions0, ARRAY_SIZE(regions0), DAX);
+ rc = check_regions(bus, regions0, num_regions, DAX);
if (rc)
return rc;
reset_bus(bus);
}
if (ndctl_test_attempt(test, KERNEL_VERSION(4, 8, 0))) {
- rc = check_regions(bus, regions0, ARRAY_SIZE(regions0), PFN);
+ rc = check_regions(bus, regions0, num_regions, PFN);
if (rc)
return rc;
reset_bus(bus);
}
- return check_regions(bus, regions0, ARRAY_SIZE(regions0), BTT);
+ return check_regions(bus, regions0, num_regions, BTT);
}
static int do_test1(struct ndctl_ctx *ctx, struct ndctl_test *test)
Signed-off-by: Santosh Sivaraj <santosh@fossix.org> --- test/libndctl.c | 61 +++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 27 deletions(-)