From patchwork Tue Aug 16 17:21: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: 9284313 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 2B183600CB for ; Tue, 16 Aug 2016 17:24:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B801285E3 for ; Tue, 16 Aug 2016 17:24:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10864287E0; Tue, 16 Aug 2016 17:24:24 +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 C7BF7285E3 for ; Tue, 16 Aug 2016 17:24:23 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BF7DB1A1E13; Tue, 16 Aug 2016 10:24:23 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by ml01.01.org (Postfix) with ESMTP id C89F41A1E13 for ; Tue, 16 Aug 2016 10:24:22 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP; 16 Aug 2016 10:24:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,529,1464678000"; d="scan'208"; a="1026469893" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.14]) by fmsmga001.fm.intel.com with ESMTP; 16 Aug 2016 10:24:23 -0700 Subject: [ndctl PATCH 6/8] test, create-namespace: reset global data From: Dan Williams To: linux-nvdimm@lists.01.org Date: Tue, 16 Aug 2016 10:21:59 -0700 Message-ID: <147136811941.27902.5105214686399519689.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <147136808681.27902.14029119240021638000.stgit@dwillia2-desk3.amr.corp.intel.com> References: <147136808681.27902.14029119240021638000.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 Before we add unit tests that call cmd_create_namespace() directly, we need to ensure that consecutive calls to cmd_create_namespace() behave the same as consecutive invocations of 'ndctl create-namespace'. I.e. re-initialize global parameter to zero. Signed-off-by: Dan Williams --- ndctl/builtin-xaction-namespace.c | 12 ++++++++++++ test.h | 1 + 2 files changed, 13 insertions(+) diff --git a/ndctl/builtin-xaction-namespace.c b/ndctl/builtin-xaction-namespace.c index 12ade241ff64..13811ea22da1 100644 --- a/ndctl/builtin-xaction-namespace.c +++ b/ndctl/builtin-xaction-namespace.c @@ -51,6 +51,18 @@ static struct parameters { const char *sector_size; } param; +void builtin_xaction_namespace_reset(void) +{ + /* + * Initialize parameter data for the unit test case where + * multiple calls to cmd__namespace() are made without + * an intervening exit(). + */ + verbose = false; + force = false; + memset(¶m, 0, sizeof(param)); +} + #define NSLABEL_NAME_LEN 64 struct parsed_parameters { enum ndctl_pfn_loc loc; diff --git a/test.h b/test.h index 120798f2dd75..331d4131e2c7 100644 --- a/test.h +++ b/test.h @@ -12,6 +12,7 @@ int __ndctl_test_attempt(struct ndctl_test *test, unsigned int kver, void __ndctl_test_skip(struct ndctl_test *test, const char *caller, int line); #define ndctl_test_skip(t) __ndctl_test_skip(t, __func__, __LINE__) struct ndctl_namespace *ndctl_get_test_dev(struct ndctl_ctx *ctx); +void builtin_xaction_namespace_reset(void); struct ndctl_ctx; int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);