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 49 forks source link

Umount the device first during mount_usb_storage() (#1587) (BugFix) #1599

Open Jefferyyen opened 1 week ago

Jefferyyen commented 1 week ago

Description

To prevent the inserted storage from failing to mount twice, first ensure it is unmounted.

Because the OS will auto-mount the inserted storage, the existing subprocess.call(["mount", device_to_mount, FOLDER_TO_MOUNT]) command will cause an error if the format of inserted storage is NTFS.

Perform an umount on device_to_mount (e.g., for the media card in #1587, it would be umount /dev/mmcblk0p1) before attempting to mount it again to avoid this issue.

Resolved issues

Fix (#1587)

Documentation

Tests

  1. Run checkbox-cli run com.canonical.certification::mediacard/sdhc-storage-manual
  2. Insert mediacard as prompt:

--------- Testing insertion ---------

INSERT NOW

Timeout: 30 seconds

3. After detectd the card, checkbox will do the read/write test.

### With the above change, it shows:

--------- Testing insertion --------

INSERT NOW

Timeout: 30 seconds INFO: usable partition: mmcblk0p1 INFO: Device: ultra high speed SDR104 SDHC INFO: Address: 59b4 INFO: Mediacard insertion test passed.

------- Insertion test passed -------

--------- Testing read/write -------- DEBUG:generating a random file DEBUG:try to mount usb storage for testing DEBUG:mount /dev/mmcblk0p1 on /tmp/tmpp76jsgp1 successfully. DEBUG:=================== DEBUG:writing test begins DEBUG:=================== DEBUG:Apply command: ['dd', 'if=/tmp/tmphkvvfmg9', 'of=/tmp/tmpp76jsgp1/tmphkvvfmg90', 'bs=1M', 'oflag=sync'] DEBUG:['100+1 records in', '100+1 records out', '104858730 bytes (105 MB, 100 MiB) copied, 7.43403 s, 14.1 MB/s', ''] DEBUG:No I/O errors found in dmesg

### Without the change, it shows:

--------- Testing insertion --------

INSERT NOW

Timeout: 30 seconds INFO: usable partition: mmcblk0p1 INFO: Device: ultra high speed SDR104 SDHC INFO: Address: 59b4 INFO: Mediacard insertion test passed.

------- Insertion test passed -------

--------- Testing read/write -------- DEBUG:generating a random file DEBUG:try to mount usb storage for testing Mount is denied because the NTFS volume is already exclusively opened. The volume may be already mounted, or another software may use it which could be identified for example by the help of the 'fuser' command. ERROR:mount /dev/mmcblk0p1 on /tmp/tmph37fxtlq failed. INFO:context manager exit: unmount USB storage umount: /tmp/tmph37fxtlq: not mounted. WARNING:umount /tmp/tmph37fxtlq failed. INFO:Remove temporary folders and files.