Home | History | Annotate | Download | only in hardware_RealtekCardReader
      1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import glob, logging, os
      6 
      7 from autotest_lib.client.bin import test, utils
      8 from autotest_lib.client.common_lib import error
      9 
     10 class hardware_RealtekCardReader(test.test):
     11     version = 1
     12 
     13     def run_once(self):
     14         # Look for the Realtek USB card reader.
     15         # This requires a plugged in SD card.
     16         lsusb_output = utils.system_output("lsusb -t")
     17         if not "Driver=ums-realtek" in lsusb_output:
     18             raise error.TestFail("The Realtek card reader USB device was not "
     19                                  "detected.  This test requires an SD card to "
     20                                  "be inserted to detect the USB device.")
     21 
     22         blockdevs = glob.glob("/sys/block/*")
     23         for dev in blockdevs:
     24             removable = utils.read_one_line(os.path.join(dev, "removable"))
     25             if removable == "1":
     26                 logging.info("Found removable block device %s", dev)
     27                 return True
     28 
     29         raise error.TestFail("The card reader USB device was detected, but "
     30                              "no removable block devices are seen.")
     31