Esempio n. 1
0
/**
 * Test a responder that can't make up it's mind about it's UID
 */
void DiscoveryAgentTest::testBipolarResponder() {
  UIDSet uids;
  ResponderList responders;
  uids.AddUID(UID(0x7a70, 0x00002002));
  PopulateResponderListFromUIDs(uids, &responders);
  // add the BiPolarResponders
  UID bipolar_uid = UID(0x7a77, 0x00002002);
  UID bipolar_uid2 = UID(0x7a77, 0x00003030);
  responders.push_back(new BiPolarResponder(bipolar_uid));
  responders.push_back(new BiPolarResponder(bipolar_uid2));
  MockDiscoveryTarget target(responders);

  DiscoveryAgent agent(&target);
  OLA_INFO << "starting discovery with BiPolarResponder responder";
  agent.StartFullDiscovery(
      ola::NewSingleCallback(this,
                             &DiscoveryAgentTest::DiscoveryFailed,
                             static_cast<const UIDSet*>(&uids)));
  CPPUNIT_ASSERT(m_callback_run);
  m_callback_run = false;

  // now try incremental, adding one uid and removing another
  OLA_INFO << "starting incremental discovery with modified responder list";
  agent.StartIncrementalDiscovery(
      ola::NewSingleCallback(this,
                             &DiscoveryAgentTest::DiscoveryFailed,
                             static_cast<const UIDSet*>(&uids)));
  CPPUNIT_ASSERT(m_callback_run);
}
Esempio n. 2
0
/**
 * Test a responder that replies with too little data.
 */
void DiscoveryAgentTest::testBriefResponder() {
  UIDSet uids;
  ResponderList responders;
  uids.AddUID(UID(0x7a70, 0x00002002));
  PopulateResponderListFromUIDs(uids, &responders);
  // add the BriefResponder
  UID brief_uid = UID(0x7a77, 0x00002002);
  responders.push_back(new BriefResponder(brief_uid));
  MockDiscoveryTarget target(responders);

  DiscoveryAgent agent(&target);
  OLA_INFO << "starting discovery with brief responder";
  agent.StartFullDiscovery(
      ola::NewSingleCallback(this,
                             &DiscoveryAgentTest::DiscoveryFailed,
                             static_cast<const UIDSet*>(&uids)));
  OLA_ASSERT_TRUE(m_callback_run);
}
Esempio n. 3
0
/**
 * Test a responder that doesn't respond to a mute message.
 */
void DiscoveryAgentTest::testNonMutingResponder() {
  UIDSet uids;
  ResponderList responders;
  uids.AddUID(UID(0x7a70, 0x00002002));
  PopulateResponderListFromUIDs(uids, &responders);
  // add the NonMutingResponders
  UID non_muting_uid = UID(0x7a77, 0x00002002);
  UID non_muting_uid2 = UID(0x7a77, 0x00003030);
  responders.push_back(new NonMutingResponder(non_muting_uid));
  responders.push_back(new NonMutingResponder(non_muting_uid2));
  MockDiscoveryTarget target(responders);

  DiscoveryAgent agent(&target);
  OLA_INFO << "starting discovery with NonMutingResponder responder";
  agent.StartFullDiscovery(
      ola::NewSingleCallback(this,
                             &DiscoveryAgentTest::DiscoveryFailed,
                             static_cast<const UIDSet*>(&uids)));
  CPPUNIT_ASSERT(m_callback_run);
  m_callback_run = false;
}
Esempio n. 4
0
/**
 * Test a responder that replies with responses larger than the DUB size
 */
void DiscoveryAgentTest::testRamblingResponder() {
  const UID normal_responder_uid(0x7a70, 0x00002002);
  const UID rambling_responder_uid(0x7a77, 0x0002002);

  UIDSet uids;
  ResponderList responders;
  uids.AddUID(normal_responder_uid);
  PopulateResponderListFromUIDs(uids, &responders);
  // add the RamblingResponder
  responders.push_back(new RamblingResponder(rambling_responder_uid));
  MockDiscoveryTarget target(responders);

  DiscoveryAgent agent(&target);
  uids.AddUID(rambling_responder_uid);
  OLA_INFO << "starting discovery with rambling responder";
  agent.StartFullDiscovery(
      ola::NewSingleCallback(this,
                             &DiscoveryAgentTest::DiscoverySuccessful,
                             static_cast<const UIDSet*>(&uids)));
  OLA_ASSERT_TRUE(m_callback_run);
}
Esempio n. 5
0
/**
 * Test a responder that only acks a mute request after N attempts.
 */
void DiscoveryAgentTest::testFlakeyResponder() {
  UIDSet uids;
  ResponderList responders;
  uids.AddUID(UID(0x7a70, 0x00002002));
  PopulateResponderListFromUIDs(uids, &responders);
  // add the NonMutingResponders
  UID flakey_uid = UID(0x7a77, 0x00002002);
  UID flakey_uid2 = UID(0x7a77, 0x00003030);
  uids.AddUID(flakey_uid);
  uids.AddUID(flakey_uid2);
  FlakeyMutingResponder *flakey_responder1 = new FlakeyMutingResponder(
      flakey_uid);
  FlakeyMutingResponder *flakey_responder2 = new FlakeyMutingResponder(
      flakey_uid2);
  responders.push_back(flakey_responder1);
  responders.push_back(flakey_responder2);
  MockDiscoveryTarget target(responders);

  DiscoveryAgent agent(&target);
  OLA_INFO << "starting discovery with flakey responder";
  agent.StartFullDiscovery(
      ola::NewSingleCallback(this,
                             &DiscoveryAgentTest::DiscoverySuccessful,
                             static_cast<const UIDSet*>(&uids)));
  CPPUNIT_ASSERT(m_callback_run);
  m_callback_run = false;

  // now try incremental
  flakey_responder1->Reset();
  flakey_responder2->Reset();
  OLA_INFO << "starting incremental discovery with flakey responder list";
  agent.StartIncrementalDiscovery(
      ola::NewSingleCallback(this,
                             &DiscoveryAgentTest::DiscoverySuccessful,
                             static_cast<const UIDSet*>(&uids)));
  CPPUNIT_ASSERT(m_callback_run);
}