Spdk/test/spdkcli/spdkcli_job.py
paul luse 17538bdc67 add (c) and SPDX header to python files as needed
per Intel policy to include file commit date using git cmd
below.  The policy does not apply to non-Intel (C) notices.

git log --follow -C90% --format=%ad --date default <file> | tail -1

and then pull just the year from the result.

Intel copyrights were not added to files where Intel either had
no contribution ot the contribution lacked substance (ie license
header updates, formatting changes, etc)

Note that several files in this patch didn't end the license/(c)
block with a blank comment line so these were added as the vast
majority of files do have this last blank line.  Simply there for
consistency.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: I6cd3f18d1b469d5ef249d26ddb2923ca6b970bd4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15208
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-11-10 08:28:53 +00:00

65 lines
1.9 KiB
Python
Executable File

#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2018 Intel Corporation
# All rights reserved.
#
import pexpect
import os
import sys
import re
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("/>")
if element_exists:
if element not in child.before.decode():
print("Element %s not in list:\n%s" % (element, child.before.decode()))
exit(1)
else:
if element in child.before.decode():
print("Element %s is in list:\n%s" % (element, child.before.decode()))
exit(1)
if __name__ == "__main__":
socket = "/var/tmp/spdk.sock"
port = None
if len(sys.argv) == 3:
socket = sys.argv[2]
elif len(sys.argv) == 4:
port = sys.argv[3]
testdir = os.path.dirname(os.path.realpath(sys.argv[0]))
if port is None:
child = pexpect.spawn(os.path.join(testdir, "../../scripts/spdkcli.py") + " -s %s" % socket)
else:
child = pexpect.spawn(os.path.join(testdir, "../../scripts/spdkcli.py") + " -s %s -p %s" % (socket, port))
child.expect(">")
child.sendline("cd /")
child.expect("/>")
cmd_lines = sys.argv[1].strip().split("\n")
for line in cmd_lines:
data = line.strip()
p = re.compile('\'(.*?)\'')
cmd = p.findall(data)
if data[-1] != "\'":
cmd.append(data.rsplit(" ", 1)[1].strip())
if cmd[-1] == "False":
cmd[-1] = False
else:
cmd[-1] = True
else:
cmd.append(False)
print("Executing command: %s" % cmd)
execute_command(*cmd[0:3])