canonical / checkbox

Checkbox is a testing framework used to validate device compatibility with Ubuntu Linux. It’s the testing tool developed for the purposes of the Ubuntu Certification program.
https://checkbox.readthedocs.io
GNU General Public License v3.0
33 stars 50 forks source link

Fix crashes when copying the same file (bugfix) #1539

Closed pseudocc closed 1 month ago

pseudocc commented 1 month ago

Description

From shutil.copy.__doc__

If source and destination are the same file, a SameFileError will be raised.

Use try except to catch and ignore it.

Resolved issues

stdout
------
Save connection /etc/NetworkManager/system-connections/Canonical.nmconnection
  Found file /etc/NetworkManager/system-connections/Canonical.nmconnection

stderr
------
Traceback (most recent call last):
  File "/tmp/nest-gvho97n3.e3cfd3167235d403c10f31edea128da281c47194c161bbd2e146795f65cdfc15/wifi_nmcli_backup.py", line 110, in <module>
    save_connections(get_nm_keyfiles())
  File "/tmp/nest-gvho97n3.e3cfd3167235d403c10f31edea128da281c47194c161bbd2e146795f65cdfc15/wifi_nmcli_backup.py", line 85, in save_connections
    save_f = shutil.copy(f, backup_loc)
  File "/usr/lib/python3.10/shutil.py", line 417, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.10/shutil.py", line 234, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: '/etc/NetworkManager/system-connections/Canonical.nmconnection' and '/etc/NetworkManager/system-connections/Canonical.nmconnection' are the same file
Hook25 commented 1 month ago

Hello, the real question is how you got this result, did you set the PLAINBOX_SESSION_SHARE to that value intentionally? Either way, this can't happen when running the test in a nominal scenarion I dont think. Can you elaborate a bit?

pseudocc commented 1 month ago

@Hook25 Sorry, I did not look into the implementation of this script at the beginning, now I am also totally confused about this result.

You may find the submission here, in which PLAINBOX_SESSION_SHARE=/var/tmp/checkbox-ng/sessions/Automatic_Jenkins_V14-Gen4-1-2024-09-19T03.56.42.session/session-share.