Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions tests/nvme_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def create_ns(self, nsze, ncap, flbas, dps):
"""
create_ns_cmd = f"{self.nvme_bin} create-ns {self.ctrl} " + \
f"--nsze={str(nsze)} --ncap={str(ncap)} --flbas={str(flbas)} " + \
f"--dps={str(dps)}"
f"--dps={str(dps)} --verbose"
return self.exec_cmd(create_ns_cmd)

def create_and_validate_ns(self, nsid, nsze, ncap, flbas, dps):
Expand All @@ -392,9 +392,14 @@ def create_and_validate_ns(self, nsid, nsze, ncap, flbas, dps):
err = subprocess.call(id_ns_cmd,
shell=True,
stdout=subprocess.DEVNULL)
if err == 0:
# enumerate new namespace block device
self.nvme_reset_ctrl()
# check if new namespace block device exists
err = 0 if stat.S_ISBLK(os.stat(self.ctrl + "n" + str(nsid)).st_mode) else 1
return err

def attach_ns(self, ctrl_id, ns_id):
def attach_ns(self, ctrl_id, nsid):
""" Wrapper for attaching the namespace.
- Args:
- ctrl_id : controller id to which namespace to be attached.
Expand All @@ -403,15 +408,15 @@ def attach_ns(self, ctrl_id, ns_id):
- 0 on success, error code on failure.
"""
attach_ns_cmd = f"{self.nvme_bin} attach-ns {self.ctrl} " + \
f"--namespace-id={str(ns_id)} --controllers={ctrl_id}"
f"--namespace-id={str(nsid)} --controllers={ctrl_id} --verbose"
err = subprocess.call(attach_ns_cmd,
shell=True,
stdout=subprocess.DEVNULL)
if err == 0:
# enumerate new namespace block device
self.nvme_reset_ctrl()
# check if new namespace block device exists
err = 0 if stat.S_ISBLK(os.stat(self.ns1).st_mode) else 1
err = 0 if stat.S_ISBLK(os.stat(self.ctrl + "n" + str(nsid)).st_mode) else 1
return err

def detach_ns(self, ctrl_id, nsid):
Expand All @@ -423,7 +428,7 @@ def detach_ns(self, ctrl_id, nsid):
- 0 on success, error code on failure.
"""
detach_ns_cmd = f"{self.nvme_bin} detach-ns {self.ctrl} " + \
f"--namespace-id={str(nsid)} --controllers={ctrl_id}"
f"--namespace-id={str(nsid)} --controllers={ctrl_id} --verbose"
return subprocess.call(detach_ns_cmd,
shell=True,
stdout=subprocess.DEVNULL)
Expand All @@ -437,7 +442,7 @@ def delete_and_validate_ns(self, nsid):
"""
# delete the namespace
delete_ns_cmd = f"{self.nvme_bin} delete-ns {self.ctrl} " + \
f"--namespace-id={str(nsid)}"
f"--namespace-id={str(nsid)} --verbose"
err = subprocess.call(delete_ns_cmd,
shell=True,
stdout=subprocess.DEVNULL)
Expand Down
Loading