예제 #1
0
/*
 * Handle the flash page replies
 */
void FirmwareTransferer::HandleMessage(uint8_t label,
                                       const uint8_t *data,
                                       unsigned int length) {
  if (label != FLASH_PAGE_LABEL || length != FLASH_STATUS_LENGTH)
    return;

  if (0 == memcmp(data, REPLY_SUCCESS, sizeof(FLASH_STATUS_LENGTH))) {
    if (!SendNextChunk() || m_sucessful)
      m_ss->Terminate();
  } else {
    OLA_FATAL << "Bad response from widget:" << string((const char*) data, 4);
    m_ss->Terminate();
  }
}
예제 #2
0
/*
 * Called when a connection completes or times out.
 */
void AdvancedTCPConnectorTest::OnConnect(TCPSocket *socket) {
  OLA_ASSERT_NOT_NULL(socket);

  GenericSocketAddress address = socket->GetPeerAddress();
  OLA_ASSERT_TRUE(address.Family() == AF_INET);
  OLA_ASSERT_EQ(m_localhost, address.V4Addr().Host());

  m_connected_socket = socket;
  m_ss->Terminate();
}
/*
 * Called when a connection completes or times out.
 */
void AdvancedTCPConnectorTest::OnConnect(TcpSocket *socket) {
  CPPUNIT_ASSERT(socket);

  IPV4Address address;
  uint16_t port;
  CPPUNIT_ASSERT(socket->GetPeer(&address, &port));
  CPPUNIT_ASSERT_EQUAL(m_localhost, address);

  m_connected_socket = socket;
  m_ss->Terminate();
}
예제 #4
0
/**
 * Called when a connection completes or times out.
 */
void TCPConnectorTest::OnConnect(int fd, int error) {
  if (error) {
    std::ostringstream str;
    str << "Failed to connect: " << strerror(error);
    OLA_ASSERT_EQ_MSG(0, error, str.str());
    m_ss->Terminate();
  } else {
    OLA_ASSERT_TRUE(fd >= 0);
    close(fd);
  }
}
예제 #5
0
void TestServiceImpl::Stream(RpcController* controller,
                             const ::ola::rpc::EchoRequest* request,
                             STREAMING_NO_RESPONSE* response,
                             CompletionCallback* done) {
  OLA_ASSERT_FALSE(controller);
  OLA_ASSERT_FALSE(response);
  OLA_ASSERT_FALSE(done);
  OLA_ASSERT_TRUE(request);
  OLA_ASSERT_EQ(string("foo"), request->data());
  m_ss->Terminate();
}
예제 #6
0
void LogicReader::DeviceDisconnected(U64 device) {
  OLA_FATAL << "Device " << device << " disconnected";

  MutexLocker lock(&m_mu);
  if (device != m_device_id) {
    return;
  }
  m_device_id = 0;
  m_logic = NULL;

  m_ss->Terminate();
}
예제 #7
0
/*
 * Receive some data and check it.
 */
void SocketTest::UDPReceiveAndTerminate(UDPSocket *socket) {
  IPV4Address expected_address;
  OLA_ASSERT_TRUE(IPV4Address::FromString("127.0.0.1", &expected_address));

  IPV4SocketAddress source;

  uint8_t buffer[sizeof(test_cstring) + 10];
  ssize_t data_read = sizeof(buffer);
  socket->RecvFrom(buffer, &data_read, &source);
  OLA_ASSERT_EQ(static_cast<ssize_t>(sizeof(test_cstring)), data_read);
  OLA_ASSERT_EQ(expected_address, source.Host());
  m_ss->Terminate();
}
예제 #8
0
/*
 * Receive some data and terminate
 */
void SocketTest::ReceiveAndTerminate(ConnectedDescriptor *socket) {
  Receive(socket);
  m_ss->Terminate();
}
예제 #9
0
/**
 * Called when a connection completes or times out.
 */
void TCPConnectorTest::OnConnectFailure(int fd, int error) {
  // The error could be one of many things, right now we just check it's non-0
  OLA_ASSERT_NE(0, error);
  OLA_ASSERT_EQ(-1, fd);
  m_ss->Terminate();
}
예제 #10
0
void RpcChannelTest::FailedEchoComplete() {
  m_ss.Terminate();
  OLA_ASSERT_TRUE(m_controller.Failed());
}
예제 #11
0
void RpcChannelTest::EchoComplete() {
  m_ss.Terminate();
  OLA_ASSERT_FALSE(m_controller.Failed());
  OLA_ASSERT_EQ(m_reply.data(), m_request.data());
}