Modified sample apps for easier and automated testing.
authorMandeep Shetty <mandeep.shetty@intel.com>
Wed, 29 Apr 2015 00:01:51 +0000 (17:01 -0700)
committerErich Keane <erich.keane@intel.com>
Wed, 29 Apr 2015 16:27:27 +0000 (16:27 +0000)
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 <mandeep.shetty@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/861
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Mark Tung <mark.y.tung@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp
resource/examples/presenceserver.cpp
resource/examples/simpleclient.cpp
resource/examples/simpleclientHQ.cpp
resource/examples/simpleserver.cpp
resource/examples/simpleserverHQ.cpp

index 3b8260e..c5c09d6 100644 (file)
@@ -666,7 +666,7 @@ void *ChangeLightRepresentation (void *param)
 
     while (!gQuitFlag)
     {
-        sleep(10);
+        sleep(3);
         Light.power += 5;
         if (gLightUnderObservation)
         {
index ffa84fa..4931dfc 100644 (file)
@@ -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();
 
index 4e3f820..b345368 100644 (file)
@@ -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..."<<std::endl;
                 OCStackResult result = curResource->cancelObserve();
index 4f041ce..ceddb32 100644 (file)
@@ -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..."<<std::endl;
             OCStackResult result = curResource->cancelObserve(OC::QualityOfService::HighQos);
index 885bfc7..f1a1e28 100644 (file)
@@ -394,7 +394,7 @@ void * ChangeLightRepresentation (void *param)
     // This function continuously monitors for the changes
     while (1)
     {
-        sleep (5);
+        sleep (3);
 
         if (gObservation)
         {
index f5efacc..d80d0ed 100644 (file)
@@ -363,7 +363,7 @@ void * ChangeLightRepresentation (void *param)
     // This function continuously monitors for the changes
     while (1)
     {
-        sleep (5);
+        sleep (3);
 
         if (gObservation)
         {