-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virttest/utils_test: fixes to virtio serial file transfer #1903
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -433,6 +433,12 @@ def find_python(session, try_binaries=('python3', 'python2', 'python')): | |
if session.cmd_status("which %s" % python) == 0: | ||
return python | ||
|
||
def find_host_python(try_binaries=('python3', 'python2', 'python')): | ||
for python in try_binaries: | ||
out = process.run("which %s" % python, shell=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or simply use |
||
if out.exit_status == 0: | ||
return python | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even use this method, we can improve
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about simply using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, it is available for both linux and windows :) |
||
|
||
@error_context.context_aware | ||
def get_image_version(qemu_image): | ||
|
@@ -742,6 +748,7 @@ def transfer_data(session, host_cmd, guest_cmd, n_time, timeout, | |
|
||
host_data_file = os.path.join(dir_name, | ||
"tmp-%s" % utils_misc.generate_random_string(8)) | ||
session.cmd("mkdir -p %s" % tmp_dir) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this resolves the failure for |
||
guest_data_file = os.path.join(tmp_dir, | ||
"tmp-%s" % utils_misc.generate_random_string(8)) | ||
|
||
|
@@ -775,14 +782,22 @@ def transfer_data(session, host_cmd, guest_cmd, n_time, timeout, | |
host_script = params.get("host_script", "serial_host_send_receive.py") | ||
host_script = os.path.join(data_dir.get_root_dir(), "shared", "deps", | ||
"serial", host_script) | ||
host_cmd = "python %s -s %s -f %s -a %s" % (host_script, host_device, | ||
host_data_file, action) | ||
|
||
host_python = find_host_python() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An alternative approach is using an inline shell statement |
||
if host_python is None: | ||
logging.error("Python not found on host.") | ||
host_cmd = "%s %s -s %s -f %s -a %s" % (host_python, host_script, | ||
host_device, host_data_file, action) | ||
guest_script = params.get("guest_script", | ||
"VirtIoChannel_guest_send_receive.py") | ||
guest_script = os.path.join(guest_path, guest_script) | ||
|
||
guest_cmd = "python %s -d %s -f %s -a %s" % (guest_script, port_name, | ||
guest_data_file, guest_action) | ||
guest_python = find_python(session) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also have windows guests, so that would be a problem.. |
||
if guest_python is None: | ||
logging.error("Python not found on guest.") | ||
guest_cmd = "%s %s -d %s -f %s -a %s" % (guest_python, guest_script, | ||
port_name, guest_data_file, | ||
guest_action) | ||
n_time = int(params.get("repeat_times", 1)) | ||
txt += " for %s times" % n_time | ||
try: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw you should split the patches. Good hint to splitting patches is when you need to use "also" in either description or comment or, as in your case, you need to itemize the changes. They look fairly simple to split (let me suggest my favorited "git cola" ;-) for that)