From patchwork Fri Dec 1 23:25:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10088283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40CDE6035E for ; Fri, 1 Dec 2017 23:33:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EC322A7B3 for ; Fri, 1 Dec 2017 23:33:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 236BA2A816; Fri, 1 Dec 2017 23:33:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 83FB42A7B3 for ; Fri, 1 Dec 2017 23:33:27 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7E30620352AB2; Fri, 1 Dec 2017 15:29:00 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C7FBA21A10961 for ; Fri, 1 Dec 2017 15:28:59 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Dec 2017 15:33:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,347,1508828400"; d="scan'208";a="180336974" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga005.jf.intel.com with ESMTP; 01 Dec 2017 15:33:26 -0800 Subject: [ndctl PATCH 08/17] ndctl, test: reset all nfit_test data for each test/libndctl run From: Dan Williams To: linux-nvdimm@lists.01.org Date: Fri, 01 Dec 2017 15:25:12 -0800 Message-ID: <151217071253.28402.991007933773283137.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <151217066885.28402.7962437173336388439.stgit@dwillia2-desk3.amr.corp.intel.com> References: <151217066885.28402.7962437173336388439.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP In preparation for tests that write smart threshold and injected-smart values arrange for nfit_test to be completely reloaded for each test run. I.e. it is no longer sufficient to just clear label data and reset regions. Signed-off-by: Dan Williams --- test.h | 3 ++- test/blk_namespaces.c | 2 +- test/core.c | 25 ++++++++++++++++++++++++- test/dpa-alloc.c | 2 +- test/dsm-fail.c | 2 +- test/libndctl.c | 2 +- test/multi-pmem.c | 2 +- test/parent-uuid.c | 2 +- test/pmem_namespaces.c | 2 +- 9 files changed, 33 insertions(+), 9 deletions(-) diff --git a/test.h b/test.h index 1ff350a9c1ba..5f2d6293c104 100644 --- a/test.h +++ b/test.h @@ -29,7 +29,8 @@ void builtin_xaction_namespace_reset(void); struct kmod_ctx; struct kmod_module; int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, - int log_level, struct ndctl_test *test); + struct ndctl_ctx *nd_ctx, int log_level, + struct ndctl_test *test); struct ndctl_ctx; int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx); diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c index 7b33bfd0528b..b587ab93fbb8 100644 --- a/test/blk_namespaces.c +++ b/test/blk_namespaces.c @@ -239,7 +239,7 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test, if (!bus) { fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n"); - rc = nfit_test_init(&kmod_ctx, &mod, log_level, test); + rc = nfit_test_init(&kmod_ctx, &mod, NULL, log_level, test); ndctl_invalidate(ctx); bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); if (rc < 0 || !bus) { diff --git a/test/core.c b/test/core.c index e0806ed24058..ca983e4913f7 100644 --- a/test/core.c +++ b/test/core.c @@ -20,6 +20,7 @@ #include #include +#include #include #define KVER_STRLEN 20 @@ -116,11 +117,13 @@ int ndctl_test_get_skipped(struct ndctl_test *test) } int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, - int log_level, struct ndctl_test *test) + struct ndctl_ctx *nd_ctx, int log_level, + struct ndctl_test *test) { int rc; unsigned int i; const char *name; + struct ndctl_bus *bus; struct log_ctx log_ctx; const char *list[] = { "nfit", @@ -219,6 +222,26 @@ retry: return rc; } + if (nd_ctx) { + /* caller wants a full nfit_test reset */ + ndctl_bus_foreach(nd_ctx, bus) { + struct ndctl_region *region; + + if (strncmp(ndctl_bus_get_provider(bus), + "nfit_test", 9) != 0) + continue; + ndctl_region_foreach(bus, region) + ndctl_region_disable_invalidate(region); + } + + rc = kmod_module_remove_module(*mod, 0); + if (rc < 0 && rc != -ENOENT) { + kmod_unref(*ctx); + return rc; + } + ndctl_invalidate(nd_ctx); + } + rc = kmod_module_probe_insert_module(*mod, KMOD_PROBE_APPLY_BLACKLIST, NULL, NULL, NULL, NULL); if (rc) diff --git a/test/dpa-alloc.c b/test/dpa-alloc.c index 9ab10f90293a..7793650699da 100644 --- a/test/dpa-alloc.c +++ b/test/dpa-alloc.c @@ -287,7 +287,7 @@ int test_dpa_alloc(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) return 77; ndctl_set_log_priority(ctx, loglevel); - err = nfit_test_init(&kmod_ctx, &mod, loglevel, test); + err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test); if (err < 0) { ndctl_test_skip(test); fprintf(stderr, "nfit_test unavailable skipping tests\n"); diff --git a/test/dsm-fail.c b/test/dsm-fail.c index b363decc29c8..90d3e074f12b 100644 --- a/test/dsm-fail.c +++ b/test/dsm-fail.c @@ -167,7 +167,7 @@ int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) int result = EXIT_FAILURE, err; ndctl_set_log_priority(ctx, loglevel); - err = nfit_test_init(&kmod_ctx, &mod, loglevel, test); + err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test); if (err < 0) { result = 77; ndctl_test_skip(test); diff --git a/test/libndctl.c b/test/libndctl.c index b534b640cb8d..b10142ebdee4 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -2567,7 +2567,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) daxctl_set_log_priority(daxctl_ctx, loglevel); ndctl_set_private_data(ctx, test); - err = nfit_test_init(&kmod_ctx, &mod, loglevel, test); + err = nfit_test_init(&kmod_ctx, &mod, ctx, loglevel, test); if (err < 0) { ndctl_test_skip(test); fprintf(stderr, "nfit_test unavailable skipping tests\n"); diff --git a/test/multi-pmem.c b/test/multi-pmem.c index b3054f44b5dd..668662cded25 100644 --- a/test/multi-pmem.c +++ b/test/multi-pmem.c @@ -260,7 +260,7 @@ int test_multi_pmem(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx ndctl_set_log_priority(ctx, loglevel); - err = nfit_test_init(&kmod_ctx, &mod, loglevel, test); + err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test); if (err < 0) { result = 77; ndctl_test_skip(test); diff --git a/test/parent-uuid.c b/test/parent-uuid.c index 87ea4d75b5a5..3a63f7244e21 100644 --- a/test/parent-uuid.c +++ b/test/parent-uuid.c @@ -229,7 +229,7 @@ int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ct return 77; ndctl_set_log_priority(ctx, loglevel); - err = nfit_test_init(&kmod_ctx, &mod, loglevel, test); + err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test); if (err < 0) { ndctl_test_skip(test); fprintf(stderr, "nfit_test unavailable skipping tests\n"); diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c index 69e87abc592f..eac56ce25d58 100644 --- a/test/pmem_namespaces.c +++ b/test/pmem_namespaces.c @@ -203,7 +203,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test, if (!bus) { fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n"); - rc = nfit_test_init(&kmod_ctx, &mod, log_level, test); + rc = nfit_test_init(&kmod_ctx, &mod, NULL, log_level, test); ndctl_invalidate(ctx); bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); if (rc < 0 || !bus) {