void SuiteAlive::Test() { Environment& env = iDvStack.Env(); Blocker* blocker = new Blocker(env); CpListenerBasic* listener = new CpListenerBasic; NetworkAdapter* nif = env.NetworkAdapterList().CurrentAdapter(kAdapterCookie); SsdpListenerMulticast* listenerMulticast = new SsdpListenerMulticast(env, nif->Address()); nif->RemoveRef(kAdapterCookie); TInt listenerId = listenerMulticast->AddNotifyHandler(listener); listenerMulticast->Start(); DviDevice* device = new DviDeviceStandard(iDvStack, gNameDevice1); device->SetAttribute("Upnp.Domain", "a.b.c"); device->SetAttribute("Upnp.Type", "type1"); device->SetAttribute("Upnp.Version", "1"); AddService(device, new DviService(iDvStack, "a.b.c", "service1", 1)); AddService(device, new DviService(iDvStack, "a.b.c", "service2", 1)); device->SetEnabled(); blocker->Wait(1); /* we expect 5 messages but linux sometimes reports multicast messages from all subnets to listeners on any single subnet so just check that we've received a multiple of 5 messages */ TEST(listener->TotalAlives() > 0); TEST(listener->TotalAlives() == listener->TotalByeByes()); TEST(listener->TotalAlives() % 5 == 0); TUint byebyes = listener->TotalByeByes(); Functor disabled = MakeFunctor(*this, &SuiteAlive::Disabled); device->SetDisabled(disabled); iSem.Wait(); blocker->Wait(1); /* semaphore being signalled implies that the device has been disabled. We may require some extra time to receive the multicast byebye confirming this */ TEST(listener->TotalByeByes() > byebyes); TEST(listener->TotalByeByes() % 5 == 0); TUint alives = listener->TotalAlives(); byebyes = listener->TotalByeByes(); device->SetEnabled(); blocker->Wait(1); TEST(listener->TotalAlives() > alives); TEST(listener->TotalAlives() - alives == listener->TotalByeByes() - byebyes); TEST(listener->TotalAlives() % 5 == 0); // Control point doesn't process ssdp:update notifications // check that updates are basically working by counting the extra alive messages instead alives = listener->TotalAlives(); device->SetAttribute("Upnp.TestUpdate", "1"); blocker->Wait(1); TEST(listener->TotalAlives() > alives); TEST(listener->TotalAlives() % 5 == 0); device->Destroy(); listenerMulticast->RemoveNotifyHandler(listenerId); delete listenerMulticast; delete listener; delete blocker; }
void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams) { OptionParser parser; OptionBool loopback("-l", "--loopback", "Use the loopback adapter only"); parser.AddOption(&loopback); if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) { return; } if (loopback.Value()) { aInitParams->SetUseLoopbackNetworkInterface(); } UpnpLibrary::Initialise(aInitParams); UpnpLibrary::StartCombined(); //Debug::SetLevel(Debug::kDevice/*Debug::kXmlFetch | Debug::kHttp*/); Print("TestDviDeviceList - starting\n"); DvDevices* devices = new DvDevices; CpDevices* deviceList = new CpDevices; FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &CpDevices::Added); FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &CpDevices::Removed); Print("Count devices implementing service1\n"); Brn domainName("a.b.c"); Brn serviceType("service1"); TUint ver = 1; CpDeviceListUpnpServiceType* list = new CpDeviceListUpnpServiceType(domainName, serviceType, ver, added, removed); Blocker* blocker = new Blocker; blocker->Wait(aInitParams->MsearchTimeSecs()); std::vector<const char*> udns; udns.push_back((const char*)gNameDevice1.Ptr()); udns.push_back((const char*)gNameDevice2.Ptr()); deviceList->Validate(udns); udns.clear(); delete list; deviceList->Clear(); Print("Count devices implementing service2\n"); serviceType.Set("service2"); list = new CpDeviceListUpnpServiceType(domainName, serviceType, ver, added, removed); blocker->Wait(aInitParams->MsearchTimeSecs()); udns.push_back((const char*)gNameDevice1_1.Ptr()); udns.push_back((const char*)gNameDevice2.Ptr()); deviceList->Validate(udns); udns.clear(); delete list; delete blocker; delete deviceList; delete devices; Print("TestDviDeviceList - completed\n"); UpnpLibrary::Close(); }
int CDECL main(int aArgc, char* aArgv[]) { InitialisationParams* initParams = InitialisationParams::Create(); OptionParser parser; OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test"); parser.AddOption(&optionDuration); if (!parser.Parse(aArgc, aArgv)) { return (1); } UpnpLibrary::Initialise(initParams); std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList(); TIpAddress subnet = (*subnetList)[0]->Subnet(); UpnpLibrary::DestroySubnetList(subnetList); UpnpLibrary::StartCp(subnet); // Debug::SetLevel(Debug::kTopology); ReceiverManager2Logger* logger = new ReceiverManager2Logger(); Blocker* blocker = new Blocker; blocker->Wait(optionDuration.Value()); delete blocker; delete (logger); UpnpLibrary::Close(); }
int __cdecl main(int aArgc, char* aArgv[]) { InitialisationParams* initParams = InitialisationParams::Create(); OptionParser parser; OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test"); parser.AddOption(&optionDuration); if (!parser.Parse(aArgc, aArgv)) { return (1); } UpnpLibrary::Initialise(initParams); UpnpLibrary::StartCp(); //Debug::SetLevel(Debug::kTopology); ReceiverManager2Logger* logger = new ReceiverManager2Logger(); Blocker* blocker = new Blocker; blocker->Wait(optionDuration.Value()); delete blocker; delete (logger); UpnpLibrary::Close(); }
void TestSubscription(CpStack& aCpStack) { gSubscriptionCount = 0; // reset this here in case we're run multiple times via TestShell Debug::SetLevel(Debug::kNone); Environment& env = aCpStack.Env(); DeviceList* deviceList = new DeviceList(env); FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &DeviceList::Added); FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &DeviceList::Removed); const Brn domainName("upnp.org"); const Brn serviceType("ConnectionManager"); #if 1 const TUint ver = 1; CpDeviceListUpnpServiceType* list = new CpDeviceListUpnpServiceType(aCpStack, domainName, serviceType, ver, added, removed); #else const Brn uuid("896659847466-a4badbeaacbc-737837"); CpDeviceListUpnpUuid* list = new CpDeviceListUpnpUuid(aCpStack, uuid, added, removed); #endif Blocker* blocker = new Blocker(env); blocker->Wait(env.InitParams().MsearchTimeSecs()); delete blocker; deviceList->Stop(); TUint startTime = Os::TimeInMs(env.OsCtx()); deviceList->Poll(); const TUint count = deviceList->Count(); Print("\n%u subscriptions on %u devices (avg %u) in %u seconds\n", gSubscriptionCount, count, (count==0? 0 : gSubscriptionCount/count), (Os::TimeInMs(env.OsCtx())-startTime+500)/1000); delete list; delete deviceList; }
int CDECL main(int aArgc, char* aArgv[]) { InitialisationParams* initParams = InitialisationParams::Create(); OptionParser parser; OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test"); parser.AddOption(&optionDuration); if (!parser.Parse(aArgc, aArgv)) { return (1); } Library* lib = new Library(initParams); std::vector<NetworkAdapter*>* subnetList = lib->CreateSubnetList(); TIpAddress subnet = (*subnetList)[0]->Subnet(); Library::DestroySubnetList(subnetList); CpStack* cpStack = lib->StartCp(subnet); // Debug::SetLevel(Debug::kTopology); ReceiverManager1Logger* logger = new ReceiverManager1Logger(*cpStack); Blocker* blocker = new Blocker(lib->Env()); blocker->Wait(optionDuration.Value()); delete blocker; delete (logger); Print("Closing ... "); delete lib; Print("closed\n"); }
extern "C" void OhNetTestRunner(OhNetHandleInitParams aInitParams) { OhNetLibraryInitialise(aInitParams); OhNetLibraryStartCp(); // Debug::SetLevel(Debug::kService); DeviceList* deviceList = new DeviceList; HandleCpDeviceList dlh = CpDeviceListCreateUpnpServiceType("upnp.org", "ConnectionManager", 1, added, deviceList, removed, deviceList); Blocker* blocker = new Blocker; blocker->Wait(OhNetInitParamsMsearchTimeSecs(aInitParams)); delete blocker; deviceList->Stop(); deviceList->InvokeSync(); Print("\n\n"); const TUint count = deviceList->Count(); TUint startTime = Os::TimeInMs(); deviceList->PollInvoke(); Print("\n%u actions invoked on %u devices (avg %u) in %u seconds\n\n", gActionCount, count, (count==0? 0 : gActionCount/count), (Os::TimeInMs()-startTime+500)/1000); startTime = Os::TimeInMs(); deviceList->PollSubscribe(); Print("\n%u subscriptions on %u devices (avg %u) in %u seconds\n", gSubscriptionCount, count, (count==0? 0 : gSubscriptionCount/count), (Os::TimeInMs()-startTime+500)/1000); CpDeviceListDestroy(dlh); delete deviceList; OhNetLibraryClose(); }
void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams) { OptionParser parser; OptionUint mx("-mx", "--mx", 1, "[1..5] number of second to spread response over"); parser.AddOption(&mx); OptionBool refresh("-f", "--refresh", "Wait mx secs then refresh list"); parser.AddOption(&refresh); if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) { return; } if (mx.Value() != 0) { aInitParams->SetMsearchTime(mx.Value()); } UpnpLibrary::Initialise(aInitParams); std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList(); TIpAddress subnet = (*subnetList)[0]->Subnet(); UpnpLibrary::DestroySubnetList(subnetList); UpnpLibrary::StartCp(subnet); // Debug::SetLevel(Debug::kTopology); // Debug::SetLevel(Debug::kAll); TopologyLogger logger; CpTopology1* topology = new CpTopology1(logger); if (topology != NULL) { Blocker* blocker = new Blocker; blocker->Wait(aInitParams->MsearchTimeSecs()); delete blocker; } if (refresh.Value()) { Blocker* blocker = new Blocker; blocker->Wait(mx.Value()); Print("\nRefreshing...\n\n"); topology->Refresh(); blocker->Wait(mx.Value()); delete blocker; } delete topology; UpnpLibrary::Close(); }
void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams) { OptionParser parser; OptionUint duration("-d", "--duration", 30, "Number of seconds to run the test"); OptionUint adapter("-i", "--interface", 0, "index of network adapter to use"); parser.AddOption(&duration); parser.AddOption(&adapter); if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) { return; } UpnpLibrary::Initialise(aInitParams); std::vector<NetworkAdapter*>* ifs = Os::NetworkListAdapters(false, "TestTopology3"); ASSERT(ifs->size() > 0 && adapter.Value() < ifs->size()); TIpAddress subnet = (*ifs)[adapter.Value()]->Subnet(); for (TUint i=0; i<ifs->size(); i++) { (*ifs)[i]->RemoveRef("TestTopology3"); } delete ifs; UpnpLibrary::StartCp(subnet); Endpoint endpt(0, subnet); Endpoint::AddressBuf buf; endpt.AppendAddress(buf); Print("Using network interface %s\n\n", buf.Ptr()); // Debug::SetLevel(Debug::kTopology); // Debug::SetLevel(Debug::kAll); TopologyLogger logger; CpTopology3* topology = new CpTopology3(logger); if (topology != NULL) { Blocker* blocker = new Blocker; blocker->Wait(duration.Value()); delete blocker; } delete topology; UpnpLibrary::Close(); }
void OpenHome::TestFramework::Runner::Main(TInt /*aArgc*/, TChar* /*aArgv*/[], InitialisationParams* aInitParams) { FunctorAsync dummy; /* Set an empty handler for errors to avoid test output being swamped by expected errors from invocations we interrupt at the end of each device's 1s timeslice */ aInitParams->SetAsyncErrorHandler(dummy); UpnpLibrary::Initialise(aInitParams); std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList(); TIpAddress subnet = (*subnetList)[0]->Subnet(); UpnpLibrary::DestroySubnetList(subnetList); UpnpLibrary::StartCp(subnet); Debug::SetLevel(Debug::kNone); DeviceList* deviceList = new DeviceList; FunctorCpDeviceCpp added = MakeFunctorCpDeviceCpp(*deviceList, &DeviceList::Added); FunctorCpDeviceCpp removed = MakeFunctorCpDeviceCpp(*deviceList, &DeviceList::Removed); std::string domainName("upnp.org"); std::string serviceType("ConnectionManager"); #if 1 const TUint ver = 1; CpDeviceListCppUpnpServiceType* list = new CpDeviceListCppUpnpServiceType(domainName, serviceType, ver, added, removed); #else const std::string uuid("896659847466-8000600fe800-737837"); CpDeviceListCppUpnpUuid* list = new CpDeviceListCppUpnpUuid(uuid, added, removed); #endif Blocker* blocker = new Blocker(*gEnv); blocker->Wait(aInitParams->MsearchTimeSecs()); delete blocker; deviceList->Stop(); TUint startTime = Os::TimeInMs(gEnv->OsCtx()); deviceList->TestSync(); deviceList->Poll(); const TUint count = deviceList->Count(); Print("\n%u actions invoked on %u devices (avg %u) in %u seconds\n", gActionCount, count, (count==0? 0 : gActionCount/count), (Os::TimeInMs(gEnv->OsCtx())-startTime+500)/1000); delete list; delete deviceList; UpnpLibrary::Close(); }
void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams) { UpnpLibrary::Initialise(aInitParams); UpnpLibrary::StartCp(); DimmableLightList* l = new DimmableLightList(); if (l != NULL) { Blocker* blocker = new Blocker; blocker->Wait(aInitParams->MsearchTimeSecs()); delete blocker; } l->Show(); delete l; UpnpLibrary::Close(); }
void TestInvocation(CpStack& aCpStack) { gActionCount = 0; // reset this here in case we're run multiple times via TestShell Environment& env = aCpStack.Env(); FunctorAsync dummy; /* Set an empty handler for errors to avoid test output being swamped by expected errors from invocations we interrupt at the end of each device's 1s timeslice */ env.InitParams()->SetAsyncErrorHandler(dummy); Debug::SetLevel(Debug::kNone); DeviceListTI* deviceList = new DeviceListTI(env); FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &DeviceListTI::Added); FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &DeviceListTI::Removed); const Brn domainName("upnp.org"); const Brn serviceType("ConnectionManager"); #if 1 const TUint ver = 1; CpDeviceListUpnpServiceType* list = new CpDeviceListUpnpServiceType(aCpStack, domainName, serviceType, ver, added, removed); #else const Brn uuid("7076436f-6e65-1063-8074-000da201f542"); CpDeviceListUpnpUuid* list = new CpDeviceListUpnpUuid(aCpStack, uuid, added, removed); #endif Blocker* blocker = new Blocker(env); blocker->Wait(env.InitParams()->MsearchTimeSecs()); delete blocker; deviceList->Stop(); TUint startTime = Os::TimeInMs(env.OsCtx()); //deviceList->TestSync(); deviceList->Poll(); const TUint count = deviceList->Count(); Print("\n%u actions invoked on %u devices (avg %u) in %u seconds\n", gActionCount, count, (count==0? 0 : gActionCount/count), (Os::TimeInMs(env.OsCtx())-startTime+500)/1000); delete list; delete deviceList; }
void SuiteMsearch::Wait() { iBlocker->Wait(iDvStack.Env().InitParams()->MsearchTimeSecs() + 1); }
void TestDeviceList(const std::vector<Brn>& aArgs) { OptionParser parser; OptionUint mx("-mx", "--mx", 1, "[1..5] number of second to spread response over"); parser.AddOption(&mx); OptionBool all("-a", "--all", "Search for all devices and services"); parser.AddOption(&all); OptionBool root("-r", "--root", "Search for root devices only"); parser.AddOption(&root); Brn emptyString(""); OptionString uuid("-u", "--uuid", emptyString, "[uuid string] search for a particular device"); parser.AddOption(&uuid); OptionString urn("-t", "--urn", emptyString, "Search for a device or service of the form [domain:[device|service]:type:ver]"); parser.AddOption(&urn); OptionBool refresh("-f", "--refresh", "Wait mx secs then refresh list"); parser.AddOption(&refresh); if (!parser.Parse(aArgs) || parser.HelpDisplayed()) { return; } // Debug::SetLevel(Debug::kDevice); DeviceListLogger logger; CpDeviceList* deviceList = NULL; FunctorCpDevice added = MakeFunctorCpDevice(logger, &DeviceListLogger::Added); FunctorCpDevice removed = MakeFunctorCpDevice(logger, &DeviceListLogger::Removed); if (all.Value()) { deviceList = new CpDeviceListUpnpAll(added, removed); } else if (root.Value()) { Print("Search root...\n"); deviceList = new CpDeviceListUpnpRoot(added, removed); } else if (uuid.Value().Bytes() > 0) { Print("Search uuid...\n"); deviceList = new CpDeviceListUpnpUuid(uuid.Value(), added, removed); } else if (urn.Value().Bytes() > 0) { Print("Search device/service...\n"); Brn domainName; Brn type; TUint ver; if (OpenHome::Net::Ssdp::ParseUrnDevice(urn.Value(), domainName, type, ver)) { deviceList = new CpDeviceListUpnpDeviceType(domainName, type, ver, added, removed); } else if (OpenHome::Net::Ssdp::ParseUrnService(urn.Value(), domainName, type, ver)) { deviceList = new CpDeviceListUpnpServiceType(domainName, type, ver, added, removed); } else { parser.DisplayHelp(); } } else { parser.DisplayHelp(); } Blocker* blocker = new Blocker; if (deviceList != NULL) { blocker->Wait(Stack::InitParams().MsearchTimeSecs()); } if (refresh.Value()) { Print("\nRefreshing...\n\n"); deviceList->Refresh(); blocker->Wait(Stack::InitParams().MsearchTimeSecs()); } delete blocker; delete deviceList; }
void TestSsdpUListen(Environment& aEnv, const std::vector<Brn>& aArgs) { OptionParser parser; OptionUint mx("-mx", "--mx", 0, "[1..5] number of second to spread response over"); parser.AddOption(&mx); OptionUint adapter("-i", "--interface", 0, "index of network adapter to use"); parser.AddOption(&adapter); OptionBool all("-a", "--all", "Search for all devices and services"); parser.AddOption(&all); OptionBool root("-r", "--root", "Search for root devices only"); parser.AddOption(&root); Brn emptyString(""); OptionString uuid("-u", "--uuid", emptyString, "[uuid string] search for a particular device"); parser.AddOption(&uuid); OptionString urn("-t", "--urn", emptyString, "Search for a device or service of the form [domain:[device|service]:type:ver]"); parser.AddOption(&urn); if (!parser.Parse(aArgs) || parser.HelpDisplayed()) { return; } //Debug::SetLevel(Debug::kSsdpMulticast); TBool block = true; SsdpNotifyLoggerU logger; SsdpListenerUnicast* uListener = new SsdpListenerUnicast(aEnv, logger, NetworkIf(aEnv, adapter.Value())); uListener->Start(); if (all.Value()) { Print("Search all...\n"); uListener->MsearchAll(); } else if (root.Value()) { Print("Search root...\n"); uListener->MsearchRoot(); } else if (uuid.Value().Bytes() > 0) { Print("Search uuid...\n"); uListener->MsearchUuid(uuid.Value()); } else if (urn.Value().Bytes() > 0) { Print("Search device/service...\n"); Brn domainName; Brn deviceType; TUint ver; if (OpenHome::Net::Ssdp::ParseUrnDevice(urn.Value(), domainName, deviceType, ver)) { uListener->MsearchDeviceType(domainName, deviceType, ver); } else if (OpenHome::Net::Ssdp::ParseUrnService(urn.Value(), domainName, deviceType, ver)) { uListener->MsearchServiceType(domainName, deviceType, ver); } else { parser.DisplayHelp(); block = false; } } else { parser.DisplayHelp(); block = false; } if (block) { Blocker* blocker = new Blocker(aEnv); blocker->Wait(aEnv.InitParams()->MsearchTimeSecs()); delete blocker; } delete uListener; }
void SuiteMsearch::Wait() { iBlocker->Wait(Stack::InitParams().MsearchTimeSecs() + 1); }