removable_storage¶
Source code: removable_storage.py
Tests accessing to a removable storage.
Description¶
Perform following tests on a removable storage device: 1. Random read/write test 2. Sequential read/write test 3. Lock (write protection) test
Test Procedure¶
Insert device (with lock switch off if there’s a one)
Read/write test should now start. Wait for completion.
Remove the device
If perform_locktest is set, continue these steps: 4. Insert device with lock switch is on 5. Lock test should now start. Wait for completion. 6. Remove the device
If skip_insert_remove is set, the device should be inserted before running this test, and the above steps 1,3,4,6 should be skipped.
Dependency¶
Use udev to monitor media insertion.
Use parted to initialize partitions on SD cards.
Use dd to perform read/write test.
Use blockdev to get block size and RO status.
Use ectool to check USB polarity.
Examples¶
To do a random read/write test on 3 blocks (each for 1024 bytes) on an USB stick, add this in test list:
{
"pytest_name": "removable_storage",
"args": {
"media": "USB",
"sysfs_path": "/sys/devices/s5p-ehci/usb1/1-1/1-1:1.0"
}
}
To do a sequential read/write test on another USB port:
{
"pytest_name": "removable_storage",
"args": {
"media": "USB",
"sysfs_path": "/sys/devices/s5p-ehci/usb1/1-2/1-2.3",
"perform_sequential_test": true,
"sequential_block_count": 8,
"block_size": 524288,
"perform_random_test": false
}
}
Similarly, to test a SD card:
{
"pytest_name": "removable_storage",
"args": {
"media": "SD",
"sysfs_path": "/path/to/sd/device",
"perform_sequential_test": true,
"sequential_block_count": 8,
"block_size": 524288,
"perform_random_test": false
}
}
If this test can not properly find the device with a specific sysfs_path, try:
Replace sysfs_path with its real path which comes from realpath command. For example:
(on DUT) $ realpath -m /sys/bus/usb/devices/usb1/1-1/1-1.1 > /sys/devices/platform/soc/11201000.usb/11200000.xhci/usb1/1-1/1-1.1
Run udevadm monitor on DUT, plug / unplug USB devices and use paths shown on the screen. For example:
(on DUT) $ udevadm monitor (plug USB disk in) ... > UDEV [20949.971277] add /devices/platform/soc/11201000.usb/11200000.xhci/usb1/1-1/1-1.1 (usb) ...
Notice that the path above is not actually a full real path. Please add “/sys” as prefix to get the full path.
Test Arguments¶
Name |
Type |
Description |
---|---|---|
media |
[‘NVME’, ‘SD’, ‘USB’] |
Media type. This is used for several logging messages, and to decide the iconsshown on UI. |
sysfs_path |
str, None |
(optional; default: |
block_size |
int |
(optional; default: |
perform_random_test |
bool |
(optional; default: |
random_read_threshold |
int, float, None |
(optional; default: |
random_write_threshold |
int, float, None |
(optional; default: |
random_block_count |
int |
(optional; default: |
perform_sequential_test |
bool |
(optional; default: |
sequential_read_threshold |
int, float, None |
(optional; default: |
sequential_write_threshold |
int, float, None |
(optional; default: |
sequential_block_count |
int |
(optional; default: |
perform_locktest |
bool |
(optional; default: |
timeout_secs |
int |
(optional; default: |
detect_timeout_secs |
int |
(optional; default: |
bft_fixture |
dict, None |
(optional; default:
The default value of |
skip_insert_remove |
bool |
(optional; default: |
bft_media_device |
str, None |
(optional; default: |
usbpd_port_polarity |
list, None |
(optional; default: |
fail_check_polarity |
bool |
(optional; default: |
create_partition |
bool, None |
(optional; default: |
use_busybox_dd |
bool |
(optional; default: |
expected_max_speed |
int, None |
(optional; default: |
extra_prompt |
str, dict |
(optional; default: |