Skip to content

Commit

Permalink
virtio_fs:compare symbolic link info in host and guest
Browse files Browse the repository at this point in the history
Compare symbolic link information in the Linux host and
guest to check if they are consistent.

Signed-off-by: zhenyzha <zhenyzha@redhat.com>
  • Loading branch information
zhenyzha committed Dec 5, 2023
1 parent 80f62ea commit d4eec79
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
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

0 comments on commit d4eec79

Please sign in to comment.