You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/07/13 18:50:07 UTC

[1/2] incubator-mynewt-core git commit: adding more test to os_eventq_poll

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 509df9d49 -> b7f6a33b1


adding more test to os_eventq_poll


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/c3f9495c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c3f9495c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c3f9495c

Branch: refs/heads/develop
Commit: c3f9495cd00855908d7d5a22fcd06d1ebe28a49f
Parents: 2f2db14
Author: NgesB <ng...@gmail.com>
Authored: Thu Jun 30 07:23:03 2016 +0100
Committer: NgesB <ng...@gmail.com>
Committed: Thu Jun 30 07:23:03 2016 +0100

----------------------------------------------------------------------
 libs/os/src/test/eventq_test.c | 256 +++++++++++++++++++++++++++++++++++-
 1 file changed, 253 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c3f9495c/libs/os/src/test/eventq_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/eventq_test.c b/libs/os/src/test/eventq_test.c
index 29e5fe3..f17e5e4 100644
--- a/libs/os/src/test/eventq_test.c
+++ b/libs/os/src/test/eventq_test.c
@@ -24,14 +24,14 @@
 #include "os/os_eventq.h"
 
 #define MY_STACK_SIZE        (5120)
-
-/*Task 1 sending task*/
+#define POLL_STACK_SIZE        (4096)
+/* Task 1 sending task */
 /* Define task stack and task object */
 #define SEND_TASK_PRIO        (1)
 struct os_task eventq_task_s;
 os_stack_t eventq_task_stack_s[MY_STACK_SIZE];
 
-/*Task 2 receiving task*/
+/* Task 2 receiving task */
 #define RECEIVE_TASK_PRIO     (2)
 struct os_task eventq_task_r;
 os_stack_t eventq_task_stack_r[MY_STACK_SIZE];
@@ -48,6 +48,51 @@ struct os_event m_event[SIZE_MULTI_EVENT];
 /* Setting the event to send and receive multiple data */
 uint8_t my_event_type = 1;
 
+/* Setting up data for the poll */
+/* Define the task stack for the eventq_task_poll_send */
+#define SEND_TASK_POLL_PRIO        (3)
+struct os_task eventq_task_poll_s;
+os_stack_t eventq_task_stack_poll_s[POLL_STACK_SIZE];
+
+/* Define the task stack for the eventq_task_poll_receive */
+#define RECEIVE_TASK_POLL_PRIO     (4)
+struct os_task eventq_task_poll_r;
+os_stack_t eventq_task_stack_poll_r[POLL_STACK_SIZE ];
+
+struct os_eventq *poll_eventq[POLL_STACK_SIZE];
+struct os_eventq p_event[POLL_STACK_SIZE];
+struct os_event poll_event[POLL_STACK_SIZE];
+
+/* Setting the data for the poll timeout */
+/* Define the task stack for the eventq_task_poll_timeout_send */
+#define SEND_TASK_POLL_TIMEOUT_PRIO        (5)
+struct os_task eventq_task_poll_timeout_s;
+os_stack_t eventq_task_stack_poll_timeout_s[POLL_STACK_SIZE];
+
+/* Define the task stack for the eventq_task_poll_receive */
+#define RECEIVE_TASK_POLL_TIMEOUT_PRIO     (6)
+struct os_task eventq_task_poll_timeout_r;
+os_stack_t eventq_task_stack_poll_timeout_r[POLL_STACK_SIZE];
+
+struct os_eventq *poll_eventq_timeout[POLL_STACK_SIZE];
+struct os_eventq p_event_timeout[POLL_STACK_SIZE];
+struct os_event poll_event_timeout[POLL_STACK_SIZE];
+
+/* Setting the data for the poll single */
+/* Define the task stack for the eventq_task_poll_single_send */
+#define SEND_TASK_POLL_SINGLE_PRIO        (7)
+struct os_task eventq_task_poll_single_s;
+os_stack_t eventq_task_stack_poll_single_s[POLL_STACK_SIZE];
+
+/* Define the task stack for the eventq_task_poll_single_receive */
+#define RECEIVE_TASK_POLL_SINGLE_PRIO     (8)
+struct os_task eventq_task_poll_single_r;
+os_stack_t eventq_task_stack_poll_single_r[POLL_STACK_SIZE];
+
+struct os_eventq *poll_eventq_single[POLL_STACK_SIZE];
+struct os_eventq p_event_single[POLL_STACK_SIZE];
+struct os_event poll_event_single[POLL_STACK_SIZE];
+
 /* This is the task function  to send data */
 void
 eventq_task_send(void *arg)
@@ -95,6 +140,146 @@ eventq_task_receive(void *arg)
     os_test_restart();
 }
 
+void
+eventq_task_poll_send(void *arg)
+{
+    int i;
+
+    /* Assigning the *poll_eventq[] */
+    for (i = 0; i < SIZE_MULTI_EVENT; i++){
+        poll_eventq[i] = &p_event[i];
+    }
+
+    /* Initializing the *poll_eventq */
+    for (i = 0; i < SIZE_MULTI_EVENT; i++){
+        os_eventq_init(poll_eventq[i]);
+    }
+
+    for (i = 0; i < SIZE_MULTI_EVENT; i++){
+        poll_event[i].ev_type = i + 10;
+        poll_event[i].ev_arg = NULL;
+
+        /* Put and send */
+        os_eventq_put(poll_eventq[i], &poll_event[i]);
+        os_time_delay(OS_TICKS_PER_SEC / 2);
+    }
+
+    /* This task sleeps until the receive task completes the test. */
+    os_time_delay(1000000);
+}
+
+void
+eventq_task_poll_receive(void *arg)
+{
+    struct os_event *event;
+    int i;
+
+    /* Recieving using the os_eventq_poll*/
+    for (i = 0; i < SIZE_MULTI_EVENT; i++) {
+        event = os_eventq_poll(poll_eventq, SIZE_MULTI_EVENT, OS_WAIT_FOREVER);
+        TEST_ASSERT(event->ev_type == i +10);
+    }
+
+    /* Finishes the test when OS has been started */
+    os_test_restart();
+
+}
+
+/* Sending with a time failure */
+void
+eventq_task_poll_timeout_send(void *arg)
+{
+    int i;
+
+    /* Assigning the *poll_eventq_timeout[] */
+    for (i = 0; i < SIZE_MULTI_EVENT; i++){
+        poll_eventq_timeout[i] = &p_event_timeout[i];
+    }
+
+    /* Initializing the *poll_eventq_timeout */
+    for (i = 0; i < SIZE_MULTI_EVENT; i++){
+        os_eventq_init(poll_eventq_timeout[i]);
+    }
+
+    for (i = 0; i < SIZE_MULTI_EVENT; i++){
+         os_time_delay(1000);
+
+        poll_event_timeout[i].ev_type = i + 10;
+        poll_event_timeout[i].ev_arg = NULL;
+
+        /* Put and send */
+        os_eventq_put(poll_eventq_timeout[i], &poll_event_timeout[i]);
+        os_time_delay(OS_TICKS_PER_SEC / 2);
+    }
+
+    /* This task sleeps until the receive task completes the test. */
+    os_time_delay(1000000);
+    
+}
+
+/* Receiving multiple event queues with a time failure */
+void
+eventq_task_poll_timeout_receive(void *arg)
+{
+     struct os_event *event;
+    int i;
+
+    /* Recieving using the os_eventq_poll_timeout*/
+    for (i = 0; i < SIZE_MULTI_EVENT; i++) {
+        event = os_eventq_poll(poll_eventq_timeout, SIZE_MULTI_EVENT, 200);
+        TEST_ASSERT(event == NULL);
+    }
+
+    /* Finishes the test when OS has been started */
+    os_test_restart();
+
+}
+
+/* Sending a single event to poll */
+void
+eventq_task_poll_single_send(void *arg)
+{
+    int i;
+    int position = 2;
+
+    /* Assigning the *poll_eventq_single */
+    for (i = 0; i < SIZE_MULTI_EVENT; i++){
+        poll_eventq_single[i] = &p_event_single[i];
+    }
+
+    /* Initializing the *poll_eventq_single */
+    for (i = 0; i < SIZE_MULTI_EVENT; i++){
+        os_eventq_init(poll_eventq_single[i]);
+    }
+
+    poll_event_single[position].ev_type = 20;
+    poll_event_single[position].ev_arg = NULL;
+
+        /* Put and send */
+        os_eventq_put(poll_eventq_single[position],
+            &poll_event_single[position]);
+        os_time_delay(OS_TICKS_PER_SEC / 2);
+
+    /* This task sleeps until the receive task completes the test. */
+    os_time_delay(1000000);
+
+}
+
+/* Recieving the single event */
+void
+eventq_task_poll_single_receive(void *arg)
+{
+    struct os_event *event;
+
+    /* Recieving using the os_eventq_poll*/
+    event = os_eventq_poll(poll_eventq_single, SIZE_MULTI_EVENT,  OS_WAIT_FOREVER);
+    TEST_ASSERT(event->ev_type == 20);
+
+    /* Finishes the test when OS has been started */
+    os_test_restart();
+
+}
+
 TEST_CASE(event_test_sr)
 {
     int i;
@@ -121,7 +306,72 @@ TEST_CASE(event_test_sr)
 
 }
 
+/* To test for the basic function of os_eventq_poll() */
+TEST_CASE(event_test_poll_sr)
+{
+    /* Initializing the OS */
+    os_init();
+    /* Initialize the task */
+    os_task_init(&eventq_task_poll_s, "eventq_task_poll_s", eventq_task_poll_send,
+        NULL, SEND_TASK_POLL_PRIO, OS_WAIT_FOREVER, eventq_task_stack_poll_s, 
+        POLL_STACK_SIZE);
+
+    /* Receive events and check whether the eevnts are correctly received */
+    os_task_init(&eventq_task_poll_r, "eventq_task_r", eventq_task_poll_receive,
+        NULL, RECEIVE_TASK_POLL_PRIO, OS_WAIT_FOREVER, eventq_task_stack_poll_r,
+        POLL_STACK_SIZE);
+
+    /* Does not return until OS_restart is called */
+    os_start();
+
+}
+
+/* Test case for poll timeout */
+TEST_CASE(event_test_poll_timeout_sr)
+{
+    /* Initializing the OS */
+    os_init();
+    /* Initialize the task */
+    os_task_init(&eventq_task_poll_timeout_s, "eventq_task_poll_timeout_s", 
+        eventq_task_poll_timeout_send, NULL, SEND_TASK_POLL_TIMEOUT_PRIO,
+        OS_WAIT_FOREVER, eventq_task_stack_poll_timeout_s, POLL_STACK_SIZE);
+
+    /* Receive events and check whether the eevnts are correctly received */
+    os_task_init(&eventq_task_poll_timeout_r, "eventq_task_timeout_r",
+        eventq_task_poll_timeout_receive, NULL, RECEIVE_TASK_POLL_TIMEOUT_PRIO,
+        OS_WAIT_FOREVER, eventq_task_stack_poll_timeout_r, POLL_STACK_SIZE);
+
+    /* Does not return until OS_restart is called */
+    os_start();
+
+}
+
+/* The case for poll single */
+/* Test case for poll timeout */
+TEST_CASE(event_test_poll_single_sr)
+{
+    /* Initializing the OS */
+    os_init();
+    /* Initialize the task */
+    os_task_init(&eventq_task_poll_single_s, "eventq_task_poll_single_s", 
+        eventq_task_poll_single_send, NULL, SEND_TASK_POLL_SINGLE_PRIO,
+        OS_WAIT_FOREVER, eventq_task_stack_poll_single_s, POLL_STACK_SIZE);
+
+    /* Receive events and check whether the eevnts are correctly received */
+    os_task_init(&eventq_task_poll_single_r, "eventq_task_single_r",
+        eventq_task_poll_single_receive, NULL, RECEIVE_TASK_POLL_SINGLE_PRIO,
+        OS_WAIT_FOREVER, eventq_task_stack_poll_single_r, POLL_STACK_SIZE);
+
+    /* Does not return until OS_restart is called */
+    os_start();
+
+}
+
 TEST_SUITE(os_eventq_test_suite)
 {
     event_test_sr();
+    event_test_poll_sr();
+    event_test_poll_timeout_sr();
+    event_test_poll_single_sr();
+
 }


[2/2] incubator-mynewt-core git commit: This closes #70.

Posted by ma...@apache.org.
This closes #70.

Merge branch 'os_eventq_poll_add' of https://github.com/NgesBrian/incubator-mynewt-core into develop


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/b7f6a33b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b7f6a33b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b7f6a33b

Branch: refs/heads/develop
Commit: b7f6a33b101833994a0595207e6be2daad03b2e0
Parents: 509df9d c3f9495
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Jul 13 11:46:55 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Jul 13 11:46:55 2016 -0700

----------------------------------------------------------------------
 libs/os/src/test/eventq_test.c | 256 +++++++++++++++++++++++++++++++++++-
 1 file changed, 253 insertions(+), 3 deletions(-)
----------------------------------------------------------------------