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"]
get_vector_list_cmd = "cat /proc/interrupts | grep nvme |" \
" cut -d : -f 1 | tr -d ' ' | tr '\n' ' '"
proc = subprocess.Popen(get_vector_list_cmd,
shell=True,
stdout=subprocess.PIPE)
self.vector_list = []
self.vector_list = 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 self.vector_list:
get_feat_cmd = "nvme get-feature " + self.ctrl + \
" --feature-id=" + str(feature_id) + \
" --cdw11=" + str(vector)
proc = subprocess.Popen(get_feat_cmd,
shell=True,
stdout=subprocess.PIPE)
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)
proc = subprocess.Popen(get_feat_cmd,
shell=True,
stdout=subprocess.PIPE)
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)