Skip to content

Commit 5872819

Browse files
authored
Merge pull request avocado-framework-tests#3070 from maramsmurthy/smaram_nvme_sed_dd_fix
Added dd definition to fix error during nvme sed destructive revert
2 parents d82c487 + c88e287 commit 5872819

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

io/disk/ssd/nvme_sedtest.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import time
2525

2626
from avocado import Test
27-
from avocado.utils import disk
2827
from avocado.utils import nvme
2928
from avocado.utils import process
3029
from avocado.utils.software_manager.manager import SoftwareManager
@@ -121,6 +120,17 @@ def is_drive_locked(self, namespace):
121120
lockdown_attr = self.get_nvme_sed_discover_parameters(namespace)
122121
return lockdown_attr.get("Locked").lower() == "yes"
123122

123+
def dd_read_records_device(self, disk, read_records="1", out_file="/tmp/data"):
124+
"""
125+
Reads mentioned number of blocks from device to destination
126+
:param disk: disk absolute path
127+
:param read_records: Numbers of blocks to read from disk
128+
:param out_file: Destination file
129+
:rtype: boolean
130+
"""
131+
cmd = f"dd count={read_records} if={disk} of={out_file}"
132+
return not process.system(cmd, ignore_status=True, sudo=True)
133+
124134
def initialize_sed_locking(self, namespace, password):
125135
"""
126136
Enables and initializes SED feature on nvme disk
@@ -256,21 +266,21 @@ def lock_unlock(self):
256266
Perform lock and unlock of nvme drive
257267
"""
258268
self.lock_drive(self.namespace)
259-
if disk.dd_read_records_device(self.namespace):
269+
if self.dd_read_records_device(self.namespace):
260270
self.log.fail(f"dd read command on {self.namespace} is successful, dd should fail when drive is locked")
261271
self.unlock_drive(self.namespace)
262-
if not disk.dd_read_records_device(self.namespace):
272+
if not self.dd_read_records_device(self.namespace):
263273
self.log.fail(f"dd read command on {self.namespace} is failed, dd should success when drive is unlocked")
264274

265275
def lock_unlock_with_key(self, password):
266276
"""
267277
Perform lock and unlock with provided key
268278
"""
269279
self.lock_drive(self.namespace, with_pass_key=password)
270-
if disk.dd_read_records_device(self.namespace):
280+
if self.dd_read_records_device(self.namespace):
271281
self.log.fail(f"dd read command on {self.namespace} is successful, dd should fail when drive is locked")
272282
self.unlock_drive(self.namespace, with_pass_key=password)
273-
if not disk.dd_read_records_device(self.namespace):
283+
if not self.dd_read_records_device(self.namespace):
274284
self.log.fail(f"dd read command on {self.namespace} is failed, dd should success when drive is unlocked")
275285

276286
def test_initialize_locking(self):

0 commit comments

Comments
 (0)