From 16b48e5c891009d2089a83478559f79a3afa38de Mon Sep 17 00:00:00 2001 From: Mandeep Shetty Date: Tue, 28 Apr 2015 17:01:51 -0700 Subject: [PATCH] Modified sample apps for easier and automated testing. This addresses IOT-506. Presence sample app required keyboard input which was inconvenient for automated testing. Modified some sleep times and counts to make sample apps more responsive or run quicker. Change-Id: I3ea1ae3be8e06986a78d904619c9f8860216848b Signed-off-by: Mandeep Shetty Reviewed-on: https://gerrit.iotivity.org/gerrit/861 Tested-by: jenkins-iotivity Reviewed-by: Mark Tung Reviewed-by: Erich Keane --- .../samples/linux/SimpleClientServer/ocserver.cpp | 2 +- resource/examples/presenceserver.cpp | 26 +++++++++++++--------- resource/examples/simpleclient.cpp | 2 +- resource/examples/simpleclientHQ.cpp | 2 +- resource/examples/simpleserver.cpp | 2 +- resource/examples/simpleserverHQ.cpp | 2 +- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp index 3b8260e..c5c09d6 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp @@ -666,7 +666,7 @@ void *ChangeLightRepresentation (void *param) while (!gQuitFlag) { - sleep(10); + sleep(3); Light.power += 5; if (gLightUnderObservation) { diff --git a/resource/examples/presenceserver.cpp b/resource/examples/presenceserver.cpp index ffa84fa..4931dfc 100644 --- a/resource/examples/presenceserver.cpp +++ b/resource/examples/presenceserver.cpp @@ -210,29 +210,33 @@ int main() // Invoke createResource function of class light. myLightResource.createResource(); - printf("Created first resource of type \"core.light\""); + std :: cout << "Creating first resource of type \"core.light\"" << std :: endl; - printf("\nEnter a key to create the second resource of type \"core.light\"\n"); - getchar(); + std :: cout << "Will start creating/deleting resources for presence in 10 seconds.\n"; + + sleep(10); + + std :: cout << "\nCreating the second resource of type \"core.light\"" << std :: endl; + sleep(1); myLightResource.createResource2(); - printf("\nEnter a key to stop the presence\n"); - getchar(); + std :: cout << "Stopping presence\n" << std :: endl; + sleep(1); stopPresence(); - printf("\nEnter a key to restart the presence\n"); - getchar(); + std :: cout << "Restarting presence\n" << std :: endl; + sleep(1); startPresence(30); - printf("\nEnter a key to create the third resource of type \"core.light\"\n"); - getchar(); + std :: cout << "Creating a third resource of type \"core.light\"\n" << std :: endl; + sleep(1); myLightResource.createResource3(); - printf("\nEnter a key to create two non-operational resources.\"\n"); - getchar(); + std :: cout << "Creating two non-operational resources.\"\n" << std :: endl; + sleep(1); createPresenceResources(); diff --git a/resource/examples/simpleclient.cpp b/resource/examples/simpleclient.cpp index 4e3f820..b345368 100644 --- a/resource/examples/simpleclient.cpp +++ b/resource/examples/simpleclient.cpp @@ -77,7 +77,7 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep, std::cout << "\tpower: " << mylight.m_power << std::endl; std::cout << "\tname: " << mylight.m_name << std::endl; - if(observe_count() > 30) + if(observe_count() > 10) { std::cout<<"Cancelling Observe..."<cancelObserve(); diff --git a/resource/examples/simpleclientHQ.cpp b/resource/examples/simpleclientHQ.cpp index 4f041ce..ceddb32 100644 --- a/resource/examples/simpleclientHQ.cpp +++ b/resource/examples/simpleclientHQ.cpp @@ -97,7 +97,7 @@ void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep, std::cout << "\tpower: " << mylight.m_power << std::endl; std::cout << "\tname: " << mylight.m_name << std::endl; - if(observe_count() > 30) + if(observe_count() > 10) { std::cout<<"Cancelling Observe..."<cancelObserve(OC::QualityOfService::HighQos); diff --git a/resource/examples/simpleserver.cpp b/resource/examples/simpleserver.cpp index 885bfc7..f1a1e28 100644 --- a/resource/examples/simpleserver.cpp +++ b/resource/examples/simpleserver.cpp @@ -394,7 +394,7 @@ void * ChangeLightRepresentation (void *param) // This function continuously monitors for the changes while (1) { - sleep (5); + sleep (3); if (gObservation) { diff --git a/resource/examples/simpleserverHQ.cpp b/resource/examples/simpleserverHQ.cpp index f5efacc..d80d0ed 100644 --- a/resource/examples/simpleserverHQ.cpp +++ b/resource/examples/simpleserverHQ.cpp @@ -363,7 +363,7 @@ void * ChangeLightRepresentation (void *param) // This function continuously monitors for the changes while (1) { - sleep (5); + sleep (3); if (gObservation) { -- 2.7.4