def setUp(self):
"""
Download 'nvme-cli'.
"""
self.device = self.params.get('device', default='/dev/nvme0')
self.disk = self.params.get('disk', default='/dev/nvme0n1')
cmd = 'ls %s' % self.device
if process.system(cmd, ignore_status=True) is not 0:
self.skip("%s does not exist" % self.device)
smm = SoftwareManager()
if not smm.check_installed("nvme-cli") and not \
smm.install("nvme-cli"):
self.skip('nvme-cli is needed for the test to be run')
python_packages = pip.get_installed_distributions()
python_packages_list = [i.key for i in python_packages]
python_pkgs = ['nose', 'nose2', 'pep8', 'flake8', 'pylint', 'epydoc']
for py_pkg in python_pkgs:
if py_pkg not in python_packages_list:
self.skip("python package %s not installed" % py_pkg)
url = 'https://codeload.github.com/linux-nvme/nvme-cli/zip/master'
tarball = self.fetch_asset("nvme-cli-master.zip", locations=[url],
expire='7d')
archive.extract(tarball, self.teststmpdir)
self.nvme_dir = os.path.join(self.teststmpdir, "nvme-cli-master")
print os.listdir(self.nvme_dir)
os.chdir(os.path.join(self.nvme_dir, 'tests'))
msg = ['{']
msg.append(' \"controller\": \"%s\",' % self.device)
msg.append(' \"ns1\": \"%s\",' % self.disk)
msg.append(' \"log_dir\": \"%s\"' % self.outputdir)
msg.append('}')
with open('config.json', 'w') as config_file:
config_file.write("\n".join(msg))
process.system("cat config.json")
nvme_cli_selftests.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录