Skip to content
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

virtio_fs:compare symbolic link info in host and guest #3895

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions qemu/tests/cfg/virtio_fs_share_data.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,13 @@
- with_symbolic_link:
only with_cache..default.default
folder_test = 'no'
cmd_symblic_file = 'ln -s ${test_file} ${test_file}_link'
cmd_symblic_folder = 'ln -s ${test_folder} ${test_folder}_link'
file_link = ${test_file}_link
folder_link = ${test_folder}_link
cmd_symblic_file = 'ln -s ${test_file} ${file_link}'
cmd_symblic_folder = 'ln -s ${test_folder} ${folder_link}'
Windows:
cmd_symblic_file = 'mklink ${test_file}_link ${test_file}'
cmd_symblic_folder = 'mklink /d ${test_folder}_link ${test_folder}'
cmd_symblic_file = 'mklink ${file_link} ${test_file}'
cmd_symblic_folder = 'mklink /d ${folder_link} ${test_folder}'
- case_insensitive:
only Windows
only with_cache..default.default
Expand Down
20 changes: 20 additions & 0 deletions qemu/tests/virtio_fs_share_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def start_multifs_instance():
# soft link config
cmd_symblic_file = params.get('cmd_symblic_file')
cmd_symblic_folder = params.get('cmd_symblic_folder')
file_link = params.get('file_link')
folder_link = params.get('folder_link')

# pjdfs test config
cmd_pjdfstest = params.get('cmd_pjdfstest')
Expand Down Expand Up @@ -533,6 +535,24 @@ def file_check(cmd):
if session.cmd_status(cmd_symblic_folder):
test.fail("Creat symbolic folders failed.")
if os_type == "linux":
error_context.context("Compare symbolic link info in "
"the host and guest", test.log.info)

def __file_check(file, guest=None):
if guest:
o = session.cmd_output("ls -l %s" % file)
else:
o = process.run("ls -l %s" % file).stdout_text
return o.strip().split()[-1]

if (__file_check(file_link, 'guest') !=
__file_check(os.path.join(fs_source, file_link))):
test.fail("Symbolic file configured in host "
"and guest are inconsistent")
if (__file_check(folder_link, 'guest') !=
__file_check(os.path.join(fs_source, folder_link))):
test.fail("Symbolic folder configured in "
"host and guest are inconsistent")
session.cmd("cd -")
else:
session.cmd("cd /d C:\\")
Expand Down