示例#1
0
 def testSetUartPropsFailure(self):
     """Test when set_uart_props fails due to bad line_prop."""
     self._initializeBBuartDefault()
     self.mox.ReplayAll()
     uart = bbuart.BBuart(self._interface)
     self.assertRaises(bbuart.BBuartError, uart.set_uart_props,
                       BAD_UART_SETTINGS)
示例#2
0
 def testGetValue(self):
     """Test the _get_value helper function."""
     self._initializeBBuartDefault()
     self.mox.ReplayAll()
     uart = bbuart.BBuart(self._interface)
     uart_speed = uart._get_value(STTY_GET_ATTRIBUTES_OUTPUT,
                                  bbuart.SPEED_RE)
     self.assertEquals(int(uart_speed, 0), 115200)
示例#3
0
 def testGetUartProps(self):
     """Test get_uart_props."""
     self._initializeBBuartDefault()
     bbuart.subprocess.check_output(GET_PROPS_ARGS).AndReturn(
         STTY_GET_ATTRIBUTES_OUTPUT)
     self.mox.ReplayAll()
     uart = bbuart.BBuart(self._interface)
     self.assertEquals(GET_UART_PROPS_EXPECTED_RESULTS,
                       uart.get_uart_props())
示例#4
0
    def testGetValueFailByBadRegex(self):
        """Test the _get_value helper function.

    Fail due to bad regex.
    """
        self._initializeBBuartDefault()
        self.mox.ReplayAll()
        uart = bbuart.BBuart(self._interface)
        self.assertRaises(bbuart.BBuartError, uart._get_value,
                          STTY_GET_ATTRIBUTES_OUTPUT, 'bad_regex')
示例#5
0
    def testGetValueFailByBadOutput(self):
        """Test the _get_value helper function.

    Fail due to bad output.
    """
        self._initializeBBuartDefault()
        self.mox.ReplayAll()
        uart = bbuart.BBuart(self._interface)
        self.assertRaises(bbuart.BBuartError, uart._get_value, '',
                          bbuart.SPEED_RE)
示例#6
0
    def testGetUartPropsFailure(self):
        """Test get_uart_props failure case.

    This can occur when stty returns bad output.
    """
        self._initializeBBuartDefault()
        bbuart.subprocess.check_output(GET_PROPS_ARGS).AndReturn('')
        self.mox.ReplayAll()
        uart = bbuart.BBuart(self._interface)
        self.assertRaises(bbuart.BBuartError, uart.get_uart_props)
示例#7
0
 def testGetParity(self):
     """Test the _get_parity helper function."""
     self._initializeBBuartDefault()
     self.mox.ReplayAll()
     uart = bbuart.BBuart(self._interface)
     # Test no parity.
     self.assertEquals(0, uart._get_parity('speed 115200 baud; -parenb'))
     # Test odd parity.
     self.assertEquals(1, uart._get_parity('speed 115200 baud; parodd'))
     # Test even parity.
     self.assertEquals(1, uart._get_parity('speed 115200 baud; -parodd'))
示例#8
0
 def _init_bb_uart(self, vendor, product, serialname, interface):
     """Initalize beaglebone uart interface."""
     logging.debug('UART INTERFACE: %s', interface)
     return bbuart.BBuart(interface)
示例#9
0
 def testInitParems(self):
     """Initialize and ensure that initializing with parameters works."""
     self._initializeBBuartWithParems()
     self.mox.ReplayAll()
     uart = bbuart.BBuart(self._interface)
     self.mox.VerifyAll()
示例#10
0
 def testInitDefault(self):
     """Initialize and ensure that initializing with default args works."""
     self._initializeBBuartDefault()
     self.mox.ReplayAll()
     uart = bbuart.BBuart(self._interface)
     self.mox.VerifyAll()