From patchwork Sun Dec 11 06:35:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9469677 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 6AC9560761 for ; Sun, 11 Dec 2016 06:39:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B1CF283BA for ; Sun, 11 Dec 2016 06:39:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 500E628402; Sun, 11 Dec 2016 06:39:13 +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 F0181283BA for ; Sun, 11 Dec 2016 06:39:12 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0D7B582096; Sat, 10 Dec 2016 22:39:13 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 61EA682081 for ; Sat, 10 Dec 2016 22:39:11 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 10 Dec 2016 22:39:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,331,1477983600"; d="scan'208";a="41309884" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.14]) by fmsmga006.fm.intel.com with ESMTP; 10 Dec 2016 22:39:10 -0800 Subject: [ndctl PATCH 5/6] test, daxctl: test dax region apis From: Dan Williams To: linux-nvdimm@lists.01.org Date: Sat, 10 Dec 2016 22:35:02 -0800 Message-ID: <148143810220.11895.9642149313511155250.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <148143807638.11895.3823811556889353622.stgit@dwillia2-desk3.amr.corp.intel.com> References: <148143807638.11895.3823811556889353622.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.21 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 Spot check the new dax_region attributes available starting with kernel v4.10. Signed-off-by: Dan Williams --- test/libndctl.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/test/libndctl.c b/test/libndctl.c index 840376c34d32..c6e199dbb078 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -625,9 +625,12 @@ static int validate_dax(struct ndctl_dax *dax) struct ndctl_namespace *ndns = ndctl_dax_get_namespace(dax); const char *devname = ndctl_namespace_get_devname(ndns); struct ndctl_region *region = ndctl_dax_get_region(dax); - struct daxctl_region *dax_region = NULL; + struct ndctl_ctx *ctx = ndctl_dax_get_ctx(dax); + struct ndctl_test *test = ndctl_get_private_data(ctx); + struct daxctl_region *dax_region = NULL, *found; int rc = -ENXIO, fd, count, dax_expect; struct daxctl_dev *dax_dev, *seed; + struct daxctl_ctx *dax_ctx; uuid_t uuid, region_uuid; char devpath[50]; @@ -638,6 +641,35 @@ static int validate_dax(struct ndctl_dax *dax) return -ENXIO; } + dax_ctx = ndctl_get_daxctl_ctx(ctx); + count = 0; + daxctl_region_foreach(dax_ctx, found) + if (found == dax_region) + count++; + if (count != 1) { + fprintf(stderr, "%s: failed to iterate to single region instance\n", + devname); + return -ENXIO; + } + + if (ndctl_test_attempt(test, KERNEL_VERSION(4, 10, 0))) { + if (daxctl_region_get_size(dax_region) + != ndctl_dax_get_size(dax)) { + fprintf(stderr, "%s: expect size: %llu != %llu\n", + devname, ndctl_dax_get_size(dax), + daxctl_region_get_size(dax_region)); + return -ENXIO; + } + + if (daxctl_region_get_align(dax_region) + != ndctl_dax_get_align(dax)) { + fprintf(stderr, "%s: expect align: %lu != %lu\n", + devname, ndctl_dax_get_align(dax), + daxctl_region_get_align(dax_region)); + return -ENXIO; + } + } + rc = -ENXIO; ndctl_dax_get_uuid(dax, uuid); daxctl_region_get_uuid(dax_region, region_uuid); @@ -2646,6 +2678,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) ndctl_set_log_priority(ctx, loglevel); daxctl_ctx = ndctl_get_daxctl_ctx(ctx); daxctl_set_log_priority(daxctl_ctx, loglevel); + ndctl_set_private_data(ctx, test); kmod_ctx = kmod_new(NULL, NULL); if (!kmod_ctx)