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
32 changes: 32 additions & 0 deletions memory/ndctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ def meson_build_system(self, deps):
self.ndctl = os.path.abspath('/usr/bin/ndctl')
self.daxctl = os.path.abspath('/usr/bin/daxctl')

def get_shutdown_state(self, region):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pavithra1602 please add the docstring

"""
The method returns the shutdown state as a string, which can be either "clean" or "dirty".
"""
cmd = 'ndctl list -DH -r %s | grep shutdown_state' % region
self.output = process.system_output(cmd, sudo=True, shell=True)
return(str(self.output).split("\"")[3])

def setUp(self):
"""
Build 'ndctl' and setup the binary.
Expand Down Expand Up @@ -1149,6 +1157,30 @@ def test_devmap_Optimisation(self):
self.fail("Namespace creation with 1GB alignment"
"must have failed!")

@avocado.fail_on(pmem.PMemException)
def test_inject_SMART_errors(self):
"""
Test to verify the error injection feature of ndctl inject-smart
for a pmem device
"""
region = self.get_default_region()
if self.get_shutdown_state(region) == "clean":
self.log.info("shutdown state is clean")
cmd = 'ndctl list -DH -r %s | grep dev' % region
self.output = process.system_output(cmd, sudo=True, shell=True)
cmd = 'ndctl inject-smart %s -U' % str(self.output).split("\"")[3]
self.output = process.system_output(cmd, sudo=True, shell=True)
if self.get_shutdown_state(region) == "dirty":
self.log.info("shutdown state is dirty Error injection is successful.")
else:
self.fail("Error injection failed")
cmd = 'ndctl list -DH -r %s | grep dev' % region
self.output = process.system_output(cmd, sudo=True, shell=True)
cmd = 'ndctl inject-smart %s -N' % str(self.output).split("\"")[3]
self.output = process.system_output(cmd, sudo=True, shell=True)
if self.get_shutdown_state(region) == "clean":
self.log.info("shutdown state is clean")

@avocado.fail_on(pmem.PMemException)
def tearDown(self):
if hasattr(self, 'part') and self.part:
Expand Down
Loading