numam-spdk/test/spdkcli/spdkcli_job.py
Pawel Wodkowski b96f97cf29 scripts: use python3 in all scripts
This it to prepare for RPM package. Also lower number of dependencies
needed by SPDK tools.

Update changelog to deprecate Python 2 and explicit interpeter invoking
in scripts.

Change-Id: I2497cca721cbcbadc1c99c675f8b8b7f682d5efa
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/425233
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-09-14 22:24:30 +00:00

39 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
import pexpect
import os
import sys
def execute_command(cmd, element=None, element_exists=False):
child.sendline(cmd)
child.expect("/>")
if "error response" in child.before.decode():
print("Error in cmd: %s" % cmd)
exit(1)
ls_tree = cmd.split(" ")[0]
if ls_tree and element:
child.sendline("ls %s" % ls_tree)
child.expect("/>")
print("child: %s" % child.before.decode())
if element_exists:
if element not in child.before.decode():
print("Element %s not in list" % element)
exit(1)
else:
if element in child.before.decode():
print("Element %s is in list" % element)
exit(1)
if __name__ == "__main__":
socket = "/var/tmp/spdk.sock"
if len(sys.argv) == 5:
socket = sys.argv[4]
testdir = os.path.dirname(os.path.realpath(sys.argv[0]))
child = pexpect.spawn(os.path.join(testdir, "../../scripts/spdkcli.py") + " -s %s" % socket)
child.expect(">")
child.sendline("cd /")
child.expect("/>")
execute_command(*sys.argv[1:4])