diff mbox

[ndctl,13/13] ndctl: test create-namespace

Message ID 20160128225306.17855.25271.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit 354fad383347
Headers show

Commit Message

Dan Williams Jan. 28, 2016, 10:53 p.m. UTC
Perform a basic check of the command line interface for creating and
reconfiguring a namespace.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 Makefile.am    |    2 +-
 test/create.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100755 test/create.sh
diff mbox

Patch

diff --git a/Makefile.am b/Makefile.am
index 63e7301e99b8..e613bc418b17 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -124,7 +124,7 @@  pkgconfig_DATA = lib/libndctl.pc
 EXTRA_DIST += lib/libndctl.pc.in
 CLEANFILES += lib/libndctl.pc
 
-TESTS = test/libndctl test/dpa-alloc test/parent-uuid
+TESTS = test/libndctl test/dpa-alloc test/parent-uuid test/create.sh
 check_PROGRAMS = test/libndctl test/dpa-alloc test/parent-uuid
 
 if ENABLE_DESTRUCTIVE
diff --git a/test/create.sh b/test/create.sh
new file mode 100755
index 000000000000..c49d15d455f5
--- /dev/null
+++ b/test/create.sh
@@ -0,0 +1,47 @@ 
+#!/bin/bash -x
+DEV=""
+NDCTL="./ndctl"
+BUS="-b nfit_test.0"
+json2var="s/[{}\",]//g; s/:/=/g"
+SECTOR_SIZE="4096"
+
+set -e
+
+# setup (reset nfit_test dimms)
+modprobe nfit_test
+$NDCTL disable-region $BUS all
+$NDCTL zero-labels $BUS all
+$NDCTL enable-region $BUS all
+
+# create pmem
+dev="x"
+json=$($NDCTL create-namespace -t pmem -m raw)
+eval $(echo $json | sed -e "$json2var")
+[ $dev = "x" ] && echo "fail: $LINENO" && exit 1
+[ $mode != "raw" ] && echo "fail: $LINENO" &&  exit 1
+
+# convert pmem to memory mode
+json=$($NDCTL create-namespace -m memory -f -e $dev)
+eval $(echo $json | sed -e "$json2var")
+[ $mode != "memory" ] && echo "fail: $LINENO" &&  exit 1
+
+# convert pmem to sector mode
+json=$($NDCTL create-namespace -m sector -l $SECTOR_SIZE -f -e $dev)
+eval $(echo $json | sed -e "$json2var")
+[ $sector_size != $SECTOR_SIZE ] && echo "fail: $LINENO" &&  exit 1
+[ $mode != "sector" ] && echo "fail: $LINENO" &&  exit 1
+
+# create blk
+dev="x"
+json=$($NDCTL create-namespace -t blk -m raw)
+eval $(echo $json | sed -e "$json2var")
+[ $dev = "x" ] && echo "fail: $LINENO" && exit 1
+[ $mode != "raw" ] && echo "fail: $LINENO" &&  exit 1
+
+# convert blk to sector mode
+json=$($NDCTL create-namespace -m sector -l $SECTOR_SIZE -f -e $dev)
+eval $(echo $json | sed -e "$json2var")
+[ $sector_size != $SECTOR_SIZE ] && echo "fail: $LINENO" &&  exit 1
+[ $mode != "sector" ] && echo "fail: $LINENO" &&  exit 1
+
+exit 0