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)
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)
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())
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')
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)
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)
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'))
def _init_bb_uart(self, vendor, product, serialname, interface): """Initalize beaglebone uart interface.""" logging.debug('UART INTERFACE: %s', interface) return bbuart.BBuart(interface)
def testInitParems(self): """Initialize and ensure that initializing with parameters works.""" self._initializeBBuartWithParems() self.mox.ReplayAll() uart = bbuart.BBuart(self._interface) self.mox.VerifyAll()
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()