Check main disk is fixed in hardware_SsdDetection
This CL checks /sys/block/[DEVICE]/removable to make sure that
main disk is fixed in hardware_SsdDetection test.
This is required by partner that we should test more properties of eMMC.
BUG=None
TEST=run hardware_SsdDetection on DUT. I have tested it on snow board and
lumpy and can pass the test.
We plan to test eMMC with hdparm in the future.
Change-Id: I7ab5005866cd4a12189aad18a48c55b6c1df2de4
Reviewed-on: https://gerrit.chromium.org/gerrit/24008
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
diff --git a/client/site_tests/hardware_SsdDetection/hardware_SsdDetection.py b/client/site_tests/hardware_SsdDetection/hardware_SsdDetection.py
index b1e280b..058fa57 100644
--- a/client/site_tests/hardware_SsdDetection/hardware_SsdDetection.py
+++ b/client/site_tests/hardware_SsdDetection/hardware_SsdDetection.py
@@ -20,9 +20,25 @@
def run_once(self, check_link_speed=()):
# Use rootdev to find the underlying block device even if the
# system booted to /dev/dm-0.
- # If it is an mmcbkl device, then it is SSD.
- # Else run hdparm to check for SSD.
+
device = utils.system_output('rootdev -s -d')
+
+ # Check the device is fixed
+
+ def IsFixed(dev):
+ sysfs_path = '/sys/block/%s/removable' % dev
+ return (os.path.exists(sysfs_path) and
+ open(sysfs_path).read().strip() == '0')
+
+ alpha_re = re.compile(r'^/dev/([a-zA-Z]+)$')
+ alnum_re = re.compile(r'^/dev/([a-zA-Z]+[0-9]+)$')
+ dev = alpha_re.findall(device) + alnum_re.findall(device)
+ if len(dev) != 1 or not IsFixed(dev[0]):
+ raise error.TestFail('The main disk %s is not fixed' % dev)
+
+ # If it is an mmcblk device, then it is SSD.
+ # Else run hdparm to check for SSD.
+
if re.search("mmcblk", device):
return