From patchwork Thu Mar 24 01:16:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 8655521 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9C1F69F3D1 for ; Thu, 24 Mar 2016 01:18:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0C5E201EC for ; Thu, 24 Mar 2016 01:18:03 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id A0FE0200F3 for ; Thu, 24 Mar 2016 01:18:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7C3281A1E95; Wed, 23 Mar 2016 18:18:27 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ml01.01.org (Postfix) with ESMTP id BABA61A1E95 for ; Wed, 23 Mar 2016 18:18:26 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 23 Mar 2016 18:17:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,383,1455004800"; d="scan'208";a="940344669" Received: from dwillia2-desk3.jf.intel.com ([10.54.39.14]) by orsmga002.jf.intel.com with ESMTP; 23 Mar 2016 18:17:37 -0700 Subject: [ndctl PATCH 2/2] ndctl: don't skip bat tests if nfit_test not available From: Dan Williams To: linux-nvdimm@lists.01.org Date: Wed, 23 Mar 2016 18:16:59 -0700 Message-ID: <20160324011658.20651.86424.stgit@dwillia2-desk3.jf.intel.com> In-Reply-To: <20160324011648.20651.33434.stgit@dwillia2-desk3.jf.intel.com> References: <20160324011648.20651.33434.stgit@dwillia2-desk3.jf.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.20 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The 'blk-ns' and 'pmem-ns' tests are meant to fallback to nfit_test, but not require nfit_test. Reported-by: Ross Zwisler Signed-off-by: Dan Williams --- test/blk_namespaces.c | 62 +++++++++++++++++++++++------------------------- test/pmem_namespaces.c | 55 ++++++++++++++++++++----------------------- 2 files changed, 56 insertions(+), 61 deletions(-) diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c index b4d677b4d0d6..0ef5b65fd511 100644 --- a/test/blk_namespaces.c +++ b/test/blk_namespaces.c @@ -213,9 +213,9 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test) char bdev[50]; struct ndctl_ctx *ctx; struct ndctl_bus *bus; - struct kmod_module *mod; struct ndctl_dimm *dimm; - struct kmod_ctx *kmod_ctx; + struct kmod_module *mod = NULL; + struct kmod_ctx *kmod_ctx = NULL; struct ndctl_namespace *ndns[2]; struct ndctl_region *region, *blk_region = NULL; @@ -228,38 +228,34 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test) ndctl_set_log_priority(ctx, log_level); - kmod_ctx = kmod_new(NULL, NULL); - if (!kmod_ctx) - goto err_kmod; - kmod_set_log_priority(kmod_ctx, log_level); - - rc = kmod_module_new_from_name(kmod_ctx, "nfit_test", &mod); - if (rc < 0) - goto err_module; - - rc = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST, - NULL, NULL, NULL, NULL); - if (rc < 0) { - rc = 77; - ndctl_test_skip(test); - fprintf(stderr, "nfit_test unavailable skipping tests\n"); - goto err_module; - } - bus = ndctl_bus_get_by_provider(ctx, "ACPI.NFIT"); - if (!bus) - bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); - if (!bus) { - fprintf(stderr, "%s: failed to find NFIT-provider\n", comm); - ndctl_test_skip(test); - rc = 77; - goto err_cleanup; - } else { - fprintf(stderr, "%s: found provider: %s\n", comm, - ndctl_bus_get_provider(bus)); + fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n"); + kmod_ctx = kmod_new(NULL, NULL); + if (!kmod_ctx) + goto err_kmod; + kmod_set_log_priority(kmod_ctx, log_level); + + rc = kmod_module_new_from_name(kmod_ctx, "nfit_test", &mod); + if (rc < 0) + goto err_module; + + rc = kmod_module_probe_insert_module(mod, + KMOD_PROBE_APPLY_BLACKLIST, + NULL, NULL, NULL, NULL); + ndctl_invalidate(ctx); + bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); + if (rc < 0 || !bus) { + rc = 77; + ndctl_test_skip(test); + fprintf(stderr, "nfit_test unavailable skipping tests\n"); + goto err_module; + } } + fprintf(stderr, "%s: found provider: %s\n", comm, + ndctl_bus_get_provider(bus)); + /* get the system to a clean state */ ndctl_region_foreach(bus, region) ndctl_region_disable_invalidate(region); @@ -345,10 +341,12 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test) if (bus) ndctl_region_foreach(bus, region) ndctl_region_disable_invalidate(region); - kmod_module_remove_module(mod, 0); + if (mod) + kmod_module_remove_module(mod, 0); err_module: - kmod_unref(kmod_ctx); + if (kmod_ctx) + kmod_unref(kmod_ctx); err_kmod: ndctl_unref(ctx); return rc; diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c index 198f8ef0cb37..387c5e011f66 100644 --- a/test/pmem_namespaces.c +++ b/test/pmem_namespaces.c @@ -173,10 +173,10 @@ static const char *comm = "test-pmem-namespaces"; int test_pmem_namespaces(int log_level, struct ndctl_test *test) { struct ndctl_region *region, *pmem_region = NULL; + struct kmod_ctx *kmod_ctx = NULL; + struct kmod_module *mod = NULL; struct ndctl_namespace *ndns; - struct kmod_ctx *kmod_ctx; struct ndctl_dimm *dimm; - struct kmod_module *mod; struct ndctl_ctx *ctx; struct ndctl_bus *bus; char bdev[50]; @@ -191,36 +191,33 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test) ndctl_set_log_priority(ctx, log_level); - kmod_ctx = kmod_new(NULL, NULL); - if (!kmod_ctx) - goto err_kmod; - kmod_set_log_priority(kmod_ctx, log_level); - - rc = kmod_module_new_from_name(kmod_ctx, "nfit_test", &mod); - if (rc < 0) - goto err_module; - - rc = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST, - NULL, NULL, NULL, NULL); - if (rc < 0) { - rc = 77; - ndctl_test_skip(test); - fprintf(stderr, "nfit_test unavailable skipping tests\n"); - goto err_module; - } - bus = ndctl_bus_get_by_provider(ctx, "ACPI.NFIT"); - if (!bus) + if (!bus) { + fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n"); + kmod_ctx = kmod_new(NULL, NULL); + if (!kmod_ctx) + goto err_kmod; + kmod_set_log_priority(kmod_ctx, log_level); + + rc = kmod_module_new_from_name(kmod_ctx, "nfit_test", &mod); + if (rc < 0) + goto err_module; + + rc = kmod_module_probe_insert_module(mod, + KMOD_PROBE_APPLY_BLACKLIST, + NULL, NULL, NULL, NULL); + ndctl_invalidate(ctx); bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); + if (rc < 0 || !bus) { + rc = 77; + ndctl_test_skip(test); + fprintf(stderr, "nfit_test unavailable skipping tests\n"); + goto err_module; + } + } - if (!bus) { - fprintf(stderr, "%s: failed to find NFIT-provider\n", comm); - ndctl_test_skip(test); - rc = 77; - goto err; - } else - fprintf(stderr, "%s: found provider: %s\n", comm, - ndctl_bus_get_provider(bus)); + fprintf(stderr, "%s: found provider: %s\n", comm, + ndctl_bus_get_provider(bus)); /* get the system to a clean state */ ndctl_region_foreach(bus, region)