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/08/18 16:23:08 UTC
[3/9] incubator-mynewt-core git commit: advancement in the callout
advancement in the callout
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/0b7cd2f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/0b7cd2f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/0b7cd2f1
Branch: refs/heads/develop
Commit: 0b7cd2f1f01554fd795b0b9a1116939f5c3cca4e
Parents: 3359c33
Author: NgesBrian <ng...@gmail.com>
Authored: Mon Jul 25 00:14:41 2016 +0100
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Aug 18 09:20:59 2016 -0700
----------------------------------------------------------------------
libs/os/src/test/callout_test.c | 44 +++++++++++++++++++++++-------------
1 file changed, 28 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0b7cd2f1/libs/os/src/test/callout_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/callout_test.c b/libs/os/src/test/callout_test.c
index 350e94d..960a7fd 100644
--- a/libs/os/src/test/callout_test.c
+++ b/libs/os/src/test/callout_test.c
@@ -35,35 +35,44 @@ os_stack_t callout_task_stack_receive[CALLOUT_STACK_SIZE];
/* Delearing variables for callout_func */
struct os_callout_func callout_func_test;
-struct os_eventq *callout_eventq;
-void native_cputimer_cb(void *arg);
/* The event to be sent*/
struct os_eventq callout_evq;
struct os_event callout_ev;
+/* This is the function for callout_init*/
+void my_callout_func(void *arg)
+{
+ int i;
+ i = 4;
+ TEST_ASSERT(i==4);
+}
+
/* This is a callout task to send data */
void
callout_task_send()
{
- int i;
- /* assigning the *callout_eventq */
- callout_eventq = &callout_evq;
-
- /* Initialize the callout function */
- os_callout_func_init(&callout_func_test, callout_eventq,
- native_cputimer_cb, NULL);
-
+ int i;
/* should say whether os is armed or not */
i = os_callout_queued(&callout_func_test.cf_c);
TEST_ASSERT(i == 0);
-
+
/* Arm the OS */
- os_callout_reset(&callout_func_test.cf_c, OS_TICKS_PER_SEC/ 50);
-
+ i = os_callout_reset(&callout_func_test.cf_c, OS_TICKS_PER_SEC/ 50);
+ TEST_ASSERT_FATAL(i == 0);
+
+ /* should say whether os is armed or not */
+ i = os_callout_queued(&callout_func_test.cf_c);
+ TEST_ASSERT(i == 1);
+
/* Send the callout */
- os_time_delay(OS_TICKS_PER_SEC / 50);
+ os_time_delay(OS_TICKS_PER_SEC );
+ TEST_ASSERT(i == 0);
+
+ /* should say whether os is armed or not */
+ i = os_callout_queued(&callout_func_test.cf_c);
TEST_ASSERT(i == 0);
+
}
void
@@ -76,7 +85,6 @@ callout_task_receive(void *arg)
TEST_ASSERT(event->ev_type == OS_EVENT_T_TIMER);
TEST_ASSERT(event->ev_arg == NULL);
-
/* Finishes the test when OS has been started */
os_test_restart();
@@ -98,8 +106,12 @@ TEST_CASE(callout_test)
callout_task_receive, NULL, RECEIVE_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
callout_task_stack_receive, CALLOUT_STACK_SIZE);
- os_eventq_init(callout_eventq);
+ os_eventq_init(&callout_evq);
+ /* Initialize the callout function */
+ os_callout_func_init(&callout_func_test, &callout_evq,
+ my_callout_func, NULL);
+
/* Does not return until OS_restart is called */
os_start();