import subprocess
from nose.tools import assert_equal
from nvme_test import TestNVMe
class TestNVMeGetMandatoryFeatures(TestNVMe):
def __init__(self):
TestNVMe.__init__(self)
self.setup_log_dir(self.__class__.__name__)
self.feature_id_list = ["0x01", "0x02", "0x04", "0x05", "0x07",
"0x08", "0x09", "0x0A", "0x0B"]
device = self.ctrl.split('/')[-1]
get_vector_list_cmd = "grep " + device + "q /proc/interrupts |" \
" cut -d : -f 1 | tr -d ' ' | tr '\n' ' '"
proc = subprocess.Popen(get_vector_list_cmd,
shell=True,
stdout=subprocess.PIPE,
encoding='utf-8')
self.vector_list_len = len(proc.stdout.read().strip().split(" "))
def __del__(self):
TestNVMe.__del__(self)
def get_mandatory_features(self, feature_id):
if str(feature_id) == "0x09":
for vector in range(self.vector_list_len):
get_feat_cmd = "nvme get-feature " + self.ctrl + \
" --feature-id=" + str(feature_id) + \
" --cdw11=" + str(vector) + " -H"
proc = subprocess.Popen(get_feat_cmd,
shell=True,
stdout=subprocess.PIPE,
encoding='utf-8')
feature_output = proc.communicate()[0]
print(feature_output)
assert_equal(proc.wait(), 0)
else:
get_feat_cmd = "nvme get-feature " + self.ctrl + \
" --feature-id=" + str(feature_id) + " -H"
proc = subprocess.Popen(get_feat_cmd,
shell=True,
stdout=subprocess.PIPE,
encoding='utf-8')
feature_output = proc.communicate()[0]
print(feature_output)
assert_equal(proc.wait(), 0)
def test_get_mandatory_features(self):
for feature_id in self.feature_id_list:
self.get_mandatory_features(feature_id)