oic unittest; don't filter out responses to discovery messages
based on source address.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d6ed9cf9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d6ed9cf9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d6ed9cf9

Branch: refs/heads/develop
Commit: d6ed9cf9780b48f8c66b4da96e4d2e8bedc3377e
Parents: e034e17
Author: Marko Kiiskila <[email protected]>
Authored: Thu Jan 12 15:12:09 2017 -0800
Committer: Marko Kiiskila <[email protected]>
Committed: Thu Jan 12 15:12:09 2017 -0800

----------------------------------------------------------------------
 net/oic/test/src/testcases/oic_discover.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d6ed9cf9/net/oic/test/src/testcases/oic_discover.c
----------------------------------------------------------------------
diff --git a/net/oic/test/src/testcases/oic_discover.c 
b/net/oic/test/src/testcases/oic_discover.c
index 8a7a69a..ae2f997 100644
--- a/net/oic/test/src/testcases/oic_discover.c
+++ b/net/oic/test/src/testcases/oic_discover.c
@@ -24,6 +24,11 @@
 #define OIC_TAPP_PRIO       9
 #define OIC_TAPP_STACK_SIZE 1024
 
+/*
+ * How long to wait before declaring discovery process failure.
+ */
+#define OIC_TEST_FAIL_DLY   (OS_TICKS_PER_SEC * 2)
+
 static int oic_test_state;
 
 static struct os_task oic_tapp;
@@ -58,18 +63,9 @@ static oc_discovery_flags_t
 discover_cb(const char *di, const char *uri, oc_string_array_t types,
             oc_interface_mask_t interfaces, oc_server_handle_t *server)
 {
-    uint8_t local_endpoint[] = { 0, 0, 0, 0, 0, 0, 0, 1 };
-
-    /*
-     * Only care about discovery responses from localhost.
-     */
     if ((server->endpoint.oe.flags & IP) == 0) {
         return 0;
     }
-    if (memcmp(&server->endpoint.oe_ip.v6.address[8], local_endpoint, 8)) {
-        return 0;
-    }
-    printf("%d %s %s\n", oic_test_state, di, uri);
     switch (oic_test_state) {
     case 1:
         TEST_ASSERT(!strcmp(uri, "/oic/p"));
@@ -148,13 +144,13 @@ oic_test_next_step(struct os_event *ev)
          * No resources registered yet.
          */
         oc_do_ip_discovery(NULL, discover_cb);
-        os_callout_reset(&oic_test_timer, OS_TICKS_PER_SEC);
+        os_callout_reset(&oic_test_timer, OIC_TEST_FAIL_DLY);
         break;
     case 2:
         oc_add_device("/oic/d", "oic.d.light", "TestDev", "1.0", "1.1",
           NULL, NULL);
         oc_do_ip_discovery(NULL, discover_cb);
-        os_callout_reset(&oic_test_timer, OS_TICKS_PER_SEC);
+        os_callout_reset(&oic_test_timer, OIC_TEST_FAIL_DLY);
         break;
     case 3: {
         oc_resource_t *res = oc_new_resource("/light/test", 1, 0);
@@ -167,7 +163,7 @@ oic_test_next_step(struct os_event *ev)
         oc_resource_set_request_handler(res, OC_GET, oic_light_get);
         oc_add_resource(res);
         oc_do_ip_discovery(NULL, discover_cb);
-        os_callout_reset(&oic_test_timer, OS_TICKS_PER_SEC);
+        os_callout_reset(&oic_test_timer, OIC_TEST_FAIL_DLY);
         break;
     }
     default:

Reply via email to