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 <[email protected]>
---
 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_<action>_namespace() are made without
+        * an intervening exit().
+        */
+       verbose = false;
+       force = false;
+       memset(&param, 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);

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to