@@ -145,6 +145,14 @@ if test "x$with_bash" = "xyes"; then
[BASH_COMPLETION_DIR=$($PKG_CONFIG --variable=completionsdir bash-completion)], [])
fi
+AC_CANONICAL_HOST
+AS_CASE([$host_cpu],
+ [x86_64|arm*],
+ [
+ AC_DEFINE([ACPI], [1], ["Build for ACPI NFIT"])
+ ]
+)
+
AC_SUBST([BASH_COMPLETION_DIR])
AM_CONDITIONAL([ENABLE_BASH_COMPLETION], [test "x$with_bash" = "xyes"])
@@ -187,7 +187,10 @@ do_tests()
ns_info_wipe
}
-modprobe nfit_test
+if [ -z "$WITHOUT_NFIT" ]; then
+ modprobe nfit_test
+fi
+
check_prereq xxd
rc=1
reset
@@ -22,7 +22,10 @@ check_min_kver "4.6" || do_skip "lacks clear poison support"
trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
-modprobe nfit_test
+if [ -z "$WITHOUT_NFIT" ]; then
+ modprobe nfit_test
+fi
+
$NDCTL disable-region -b $TEST_BUS0 all
$NDCTL zero-labels -b $TEST_BUS0 all
$NDCTL enable-region -b $TEST_BUS0 all
@@ -29,10 +29,17 @@ fi
# TEST_BUS[01]
#
-TEST_BUS0="nfit_test.0"
-TEST_BUS1="nfit_test.1"
-ACPI_BUS="ACPI.NFIT"
-E820_BUS="e820"
+echo $WITHOUT_NFIT
+if [ -n "$WITHOUT_NFIT" ]; then
+ echo $BUS_PROVIDER0
+ TEST_BUS0="$BUS_PROVIDER0"
+ TEST_BUS1="$BUS_PROVIDER1"
+else
+ TEST_BUS0="nfit_test.0"
+ TEST_BUS1="nfit_test.1"
+ ACPI_BUS="ACPI.NFIT"
+ E820_BUS="e820"
+fi
# Functions
@@ -84,7 +91,9 @@ _cleanup()
{
$NDCTL disable-region -b $TEST_BUS0 all
$NDCTL disable-region -b $TEST_BUS1 all
- modprobe -r nfit_test
+ if [ -z "$WITHOUT_NFIT" ]; then
+ modprobe -r nfit_test
+ fi
}
# json2var
@@ -126,7 +126,9 @@ int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
struct ndctl_bus *bus;
struct log_ctx log_ctx;
const char *list[] = {
+#ifdef ACPI
"nfit",
+#endif
"device_dax",
"dax_pmem",
"dax_pmem_core",
@@ -134,7 +136,9 @@ int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
"libnvdimm",
"nd_blk",
"nd_btt",
+#ifdef ACPI
"nd_e820",
+#endif
"nd_pmem",
};
@@ -239,9 +243,11 @@ retry:
ndctl_bus_foreach(nd_ctx, bus) {
struct ndctl_region *region;
+#ifdef ACPI
if (strncmp(ndctl_bus_get_provider(bus),
"nfit_test", 9) != 0)
continue;
+#endif
ndctl_region_foreach(bus, region)
ndctl_region_disable_invalidate(region);
}
@@ -23,7 +23,10 @@ check_min_kver "4.5" || do_skip "may lack namespace mode attribute"
trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
-modprobe nfit_test
+if [ -z "$WITHOUT_NFIT" ]; then
+ modprobe nfit_test
+fi
+
$NDCTL disable-region -b $TEST_BUS0 all
$NDCTL zero-labels -b $TEST_BUS0 all
$NDCTL enable-region -b $TEST_BUS0 all
@@ -45,7 +45,6 @@ struct check_cmd {
static sigjmp_buf sj_env;
static int sig_count;
-static const char *NFIT_PROVIDER0 = "nfit_test.0";
static struct check_cmd *check_cmds;
static void sigbus_hdl(int sig, siginfo_t *siginfo, void *ptr)
@@ -245,7 +244,7 @@ static struct ndctl_dax * get_dax_region(struct ndctl_region *region)
static int test_daxdev_clear_error(const char *bus_name,
const char *region_name)
{
- int rc = 0, i;
+ int rc = 0, i, with_nfit;
struct ndctl_ctx *ctx;
struct ndctl_bus *bus;
struct ndctl_region *region;
@@ -259,6 +258,7 @@ static int test_daxdev_clear_error(const char *bus_name,
};
char path[256];
char buf[SYSFS_ATTR_SIZE];
+ char *bus_provider;
struct log_ctx log_ctx;
log_init(&log_ctx, "test/init", "NDCTL_DAXDEV_TEST");
@@ -266,7 +266,13 @@ static int test_daxdev_clear_error(const char *bus_name,
if (rc)
return rc;
- bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER0);
+ with_nfit = strlen(getenv("WITHOUT_NFIT")) == 0;
+ if (with_nfit)
+ bus_provider = "nfit_test.0";
+ else
+ bus_provider = getenv("BUS_PROVIDER0");
+
+ bus = ndctl_bus_get_by_provider(ctx, bus_provider);
if (!bus) {
rc = -ENODEV;
goto cleanup;
@@ -289,7 +295,7 @@ static int test_daxdev_clear_error(const char *bus_name,
/* get badblocks */
if (snprintf(path, 256,
"/sys/devices/platform/%s/%s/%s/badblocks",
- NFIT_PROVIDER0,
+ bus_provider,
bus_name,
ndctl_region_get_devname(region)) >= 256) {
fprintf(stderr, "%s: buffer too small!\n",
@@ -22,7 +22,10 @@ check_min_kver "4.12" || do_skip "lacks dax dev error handling"
trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
-modprobe nfit_test
+if [ -z "$WITHOUT_NFIT" ]; then
+ modprobe nfit_test
+fi
+
$NDCTL disable-region -b $TEST_BUS0 all
$NDCTL zero-labels -b $TEST_BUS0 all
$NDCTL enable-region -b $TEST_BUS0 all
@@ -30,8 +30,6 @@
#include <ndctl/libndctl.h>
#include <ccan/array_size/array_size.h>
-static const char *NFIT_PROVIDER0 = "nfit_test.0";
-static const char *NFIT_PROVIDER1 = "nfit_test.1";
#define NUM_NAMESPACES 4
struct test_dpa_namespace {
@@ -46,23 +44,34 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
{
unsigned int default_available_slots, available_slots, i;
struct ndctl_region *region, *blk_region = NULL;
+ char *bus_provider0, *bus_provider1;
struct ndctl_namespace *ndns;
struct ndctl_dimm *dimm;
unsigned long size;
+ bool with_nfit;
struct ndctl_bus *bus;
char uuid_str[40];
int round;
int rc;
+ with_nfit = strlen(getenv("WITHOUT_NFIT")) == 0;
+ if (with_nfit) {
+ bus_provider0 = "nfit_test.0";
+ bus_provider1 = "nfit_test.1";
+ } else {
+ bus_provider0 = getenv("BUS_PROVIDER0");
+ bus_provider1 = getenv("BUS_PROVIDER1");
+ }
+
/* disable nfit_test.1, not used in this test */
- bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER1);
+ bus = ndctl_bus_get_by_provider(ctx, bus_provider1);
if (!bus)
return -ENXIO;
ndctl_region_foreach(bus, region)
ndctl_region_disable_invalidate(region);
/* init nfit_test.0 */
- bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER0);
+ bus = ndctl_bus_get_by_provider(ctx, bus_provider0);
if (!bus)
return -ENXIO;
ndctl_region_foreach(bus, region)
@@ -94,8 +94,6 @@
* dimm.
*/
-static const char *NFIT_PROVIDER0 = "nfit_test.0";
-static const char *NFIT_PROVIDER1 = "nfit_test.1";
#define SZ_4K 0x00001000
#define SZ_128K 0x00020000
#define SZ_7M 0x00700000
@@ -2594,11 +2592,18 @@ static void reset_bus(struct ndctl_bus *bus)
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_bus *bus;
struct ndctl_region *region;
struct ndctl_dimm *dimm;
+ bool with_nfit;
int rc;
+ with_nfit = strlen(getenv("WITHOUT_NFIT")) == 0;
+ if (with_nfit)
+ bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
+ else
+ bus = ndctl_bus_get_by_provider(ctx, getenv("BUS_PROVIDER0"));
+
if (!bus)
return -ENXIO;
@@ -2646,9 +2651,17 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
static int do_test1(struct ndctl_ctx *ctx, struct ndctl_test *test)
{
- struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER1);
+ struct ndctl_bus *bus;
+ bool with_nfit;
int rc;
+ with_nfit = strlen(getenv("WITHOUT_NFIT")) == 0;
+ if (with_nfit)
+ bus = ndctl_bus_get_by_provider(ctx, "nfit_test.1");
+ else
+ bus = ndctl_bus_get_by_provider(ctx, getenv("BUS_PROVIDER1"));
+
+
if (!bus)
return -ENXIO;
For QEMU emulated devices and other platforms, nfit drivers are not needed. This patch achieves that by relying upon the environment variable called 'WITHOUT_NFIT'. If 'WITHOUT_NFIT=y', nfit drivers (nfit_test and libnvdimm_test) are not loaded. Signed-off-by: Santosh Sivaraj <santosh@fossix.org> --- configure.ac | 8 ++++++++ test/btt-pad-compat.sh | 5 ++++- test/clear.sh | 5 ++++- test/common | 19 ++++++++++++++----- test/core.c | 6 ++++++ test/create.sh | 5 ++++- test/daxdev-errors.c | 14 ++++++++++---- test/daxdev-errors.sh | 5 ++++- test/dpa-alloc.c | 17 +++++++++++++---- test/libndctl.c | 21 +++++++++++++++++---- 10 files changed, 84 insertions(+), 21 deletions(-)