blob: b1e280b4ac0e5b3fdffe591b4e93e0ee710c53f2 [file] [log] [blame]
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import re
from autotest_lib.client.bin import test, utils
from autotest_lib.client.common_lib import error
class hardware_SsdDetection(test.test):
version = 1
def setup(self):
# create a empty srcdir to prevent the error that checks .version file
if not os.path.exists(self.srcdir):
utils.system('mkdir %s' % self.srcdir)
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')
if"mmcblk", device):
hdparm ='/sbin/hdparm -I %s' % device)
# Check if device is a SSD
match ='Nominal Media Rotation Rate: (.+)$',
hdparm.stdout, re.MULTILINE)
if match and
if != 'Solid State Device':
raise error.TestFail('The main disk is not a SSD, '
'Rotation Rate: %s' %
raise error.TestFail(
'Rotation Rate not reported from the device, '
'unable to ensure it is a SSD')
# Check if SSD is > 8GB in size
match ="device size with M = 1000\*1000: (.+) MBytes",
hdparm.stdout, re.MULTILINE)
if match and
size = int(
self.write_perf_keyval({"mb_ssd_device_size" : size})
raise error.TestFail(
'Device size info missing from the device')
# Check supported link speed.
# check_link_speed is an empty tuple by default, which does not perform
# link speed checking. You can run the test while specifying
# check_link_speed=('1.5Gb/s', '3.0Gb/s') to check the 2 signaling
# speeds are both supported.
for link_speed in check_link_speed:
if not'Gen. signaling speed \(%s\)' % link_speed,
hdparm.stdout, re.MULTILINE):
raise error.TestFail('Link speed %s not supported' % link_speed)