bad_blocks¶
Source code: bad_blocks.py
Tests a storage device by running the badblocks command.
Description¶
This test uses badblocks(8)
command to search for badblocks on a device. By
default the unused portion of the stateful partition is used
(mode=stateful_partition_free_space
). (For instance, on
a device with a 32 GB hard drive, cgpt reports that partition 1 is about 25 GB,
but the size of the filesystem is only about 1 GB. We run the test on the
unused 24 GB.)
Alternatively one can specify the use of a file in the filesystem allocated by
the test, or raw mode where a specific file/partition must be provided.
(mode=file
or mode=raw
)
When mode=stateful_partition_free_space
, unused portion after stateful
partition must exist. An error message 'There is no unused space after
stateful partition.'
will be shown if it cannot find any extra space.
(If you install the image by chromeos-install
, by default, there will be no
free space after stateful partition.)
Default Behavior¶
The test will use 1GB of unused portion of the stateful partition for
testing by default. On most devices, badblocks
takes ~0.5s/MB (for four
passes). So the default setup will take about 9 minutes.
The test skips badblocks and only runs smartctl for SSD storage by default.
Test Procedure¶
This test does not require operator interaction. An UI will be shown to indicate the process of testing.
Dependency¶
This pytest depends on badblocks(8)
.
Examples¶
To run default test:
{
"pytest_name": "bad_blocks",
"label": "Bad Blocks",
"related_components": [
"test_tags.TestCategory.BRIDGE_PCIE_EMMC",
"test_tags.TestCategory.STORAGE"
],
"args": {
"timeout_secs": 120,
"log_threshold_secs": 10,
"max_bytes": 1073741824
}
}
To change the portion of disk to 2 GB:
{
"pytest_name": "bad_blocks",
"label": "Bad Blocks 2GB",
"related_components": [
"test_tags.TestCategory.BRIDGE_PCIE_EMMC",
"test_tags.TestCategory.STORAGE"
],
"args": {
"timeout_secs": 120,
"log_threshold_secs": 10,
"max_bytes": 2147483648
}
}
To force running badblocks:
{
"pytest_name": "bad_blocks",
"label": "Bad Blocks Force badblocks On SSD",
"related_components": [
"test_tags.TestCategory.BRIDGE_PCIE_EMMC",
"test_tags.TestCategory.STORAGE"
],
"args": {
"timeout_secs": 120,
"log_threshold_secs": 10,
"max_bytes": 1073741824,
"force_badblocks_on_ssd": true
}
}
Troubleshooting¶
If the test image is installed by chromeos-install and pytest complains there’s no unused space to be checked, re-install the image via factory shim or netboot. You can find different ways to install images at here: https://chromium.googlesource.com/chromiumos/platform/factory/+/HEAD/README.md#Imaging-methods
Test Arguments¶
Name |
Type |
Description |
---|---|---|
mode |
[‘file’, ‘raw’, ‘stateful_partition_free_space’] |
(optional; default: |
device_path |
str, None |
(optional; default: |
max_bytes |
int, None |
(optional; default: |
max_errors |
int |
(optional; default: |
timeout_secs |
int, float |
(optional; default: |
extra_log_cmd |
str, None |
(optional; default: |
log_threshold_secs |
int, float |
(optional; default: |
log_interval_secs |
int |
(optional; default: |
drop_caches_interval_secs |
int |
(optional; default: |
destructive |
bool |
(optional; default: |
force_badblocks_on_ssd |
bool |
(optional; default: |