Home | History | Annotate | Download | only in cellular_GobiPorts
      1 # Copyright (c) 2011 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 logging, os, stat
      6 
      7 from autotest_lib.client.bin import test
      8 from autotest_lib.client.common_lib import error
      9 
     10 
     11 class cellular_GobiPorts(test.test):
     12     version = 1
     13 
     14     def run_once(self):
     15         failed_ports = []
     16 
     17         ports = ['/dev/ttyUSB0', '/dev/ttyUSB1', '/dev/ttyUSB2']
     18 
     19         for port in ports:
     20             if not os.path.exists(port):
     21                 failed_ports.append(port)
     22                 logging.error('Port %s does not exist.' % port)
     23                 continue
     24             mode = os.stat(port).st_mode
     25             if not stat.S_ISCHR(mode):
     26                 logging.error('Port %s is not a character device. mode = %s' % (
     27                     port, mode))
     28                 failed_ports.append(port)
     29                 continue
     30             logging.info('Port %s is a character device.' % port)
     31 
     32         if failed_ports:
     33             raise error.TestFail('Ports [%s] are missing or not char devices' %
     34                                  ', '.join(failed_ports))
     35