From: Masayoshi Mizuma <m.miz...@jp.fujitsu.com>

Add following global variable and functions to test/common file.

 - NFIT_TEST_BUS[01] (global variable)
   Buses are created when nfit_test module is loaded.

 - NDCTL (global variable)
   ndctl command path (renamed).

 - _cleanup
   Helper function cleans up nfit_test module.

 - json2var
   Helper function (filter) converts json to var.

Signed-off-by: Masayoshi Mizuma <m.miz...@jp.fujitsu.com>
---
 test/common | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/test/common b/test/common
index 8fafa91..fb4e18e 100644
--- a/test/common
+++ b/test/common
@@ -4,17 +4,23 @@
 
 # Global variables
 
-# ndctl
+# NDCTL
 #
 if [ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ]; then
-       export ndctl=../ndctl/ndctl
+       export NDCTL=../ndctl/ndctl
 elif [ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ]; then
-       export ndctl=./ndctl/ndctl
+       export NDCTL=./ndctl/ndctl
 else
        echo "Couldn't find an ndctl binary"
        exit 1
 fi
 
+# NFIT_TEST_BUS[01]
+#
+NFIT_TEST_BUS0=nfit_test.0
+NFIT_TEST_BUS1=nfit_test.1
+
+
 # Functions
 
 # err
@@ -58,3 +64,20 @@ check_prereq()
                do_skip "missing $1, skipping..."
        fi
 }
+
+# _cleanup
+#
+_cleanup()
+{
+       $NDCTL disable-region -b $NFIT_TEST_BUS0 all
+       $NDCTL disable-region -b $NFIT_TEST_BUS1 all
+       modprobe -r nfit_test
+}
+
+# json2var
+# stdin: json
+#
+json2var()
+{
+       sed -e "s/[{}\",]//g; s/:/=/g"
+}
-- 
2.18.0.rc1

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to