diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/spdk/test/spdkcli/spdkcli_job.py | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/test/spdkcli/spdkcli_job.py')
-rwxr-xr-x | src/spdk/test/spdkcli/spdkcli_job.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/spdk/test/spdkcli/spdkcli_job.py b/src/spdk/test/spdkcli/spdkcli_job.py new file mode 100755 index 00000000..a2677f6a --- /dev/null +++ b/src/spdk/test/spdkcli/spdkcli_job.py @@ -0,0 +1,38 @@ +#!/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]) |