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:09 UTC

[4/9] incubator-mynewt-core git commit: basic os_callout

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

Branch: refs/heads/develop
Commit: bc4c0a83f752e0b2113f8fb1ed001ec45ddc7c5c
Parents: 40c072e
Author: NgesBrian <ng...@gmail.com>
Authored: Wed Jul 20 01:17: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 | 82 ++++++++++++++++++++++++++++++++++++
 libs/os/src/test/os_test.c      |  2 +-
 libs/os/src/test/os_test_priv.h |  2 +-
 3 files changed, 84 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bc4c0a83/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
new file mode 100644
index 0000000..034c2f4
--- /dev/null
+++ b/libs/os/src/test/callout_test.c
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ 
+#include "testutil/testutil.h"
+#include "os/os.h"
+#include "os_test_priv.h"
+#include "os/os_eventq.h"
+#include "os/os_callout.h"
+
+/* Task 1 for sending */
+#define CALLOUT_STACK_SIZE        (5120)
+#define SEND_CALLOUT_TASK_PRIO        (1)
+struct os_task callout_task_struct_send;
+os_stack_t callout_task_stack_send[CALLOUT_STACK_SIZE];
+
+/* Initializing the callout 
+struct os_event callout_event;
+struct os_eventq callout_eventq;
+struct os_eventq callout_eventq_delivered;
+struct os_callout struct_callout;
+*/
+
+/* Delearing variables for callout_func */
+struct os_callout_func callout_func;
+struct os_eventq callout_eventq;
+void native_cputimer_cb(void *arg);
+
+/* This is a callout task to send data */
+void
+callout_task_send()
+{
+    int i;
+    /*
+    struct_callout.c_ev = callout_event;
+    struct_callout.c_evq = &callout_eventq;
+    struct_callout.c_ticks = OS_TICKS_PER_SEC / 20;
+    */
+    /* Initialize the callout
+    os_callout_init(&struct_callout, &callout_eventq_delivered, NULL);
+    */
+
+    /* Initialize the callout function */
+    os_callout_func_init(&callout_func, &callout_eventq,
+        native_cputimer_cb, NULL);
+    i = os_callout_queued((struct os_callout )callout_func);
+    TEST_ASSERT(i == 0);
+}
+
+TEST_CASE(callout_test){
+
+    /* Initializing the OS */
+    os_init();
+    
+    /* Initialize the sending task */
+    os_task_init(&callout_task_struct_send, "callout_task_send",
+        callout_task_send, NULL, SEND_CALLOUT_TASK_PRIO, OS_WAIT_FOREVER,
+        callout_task_stack_send, CALLOUT_STACK_SIZE);
+
+    /* Does not return until OS_restart is called */
+    os_start();
+
+}
+
+TEST_SUITE(os_callout_test_suite){   
+    callout_test();
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bc4c0a83/libs/os/src/test/os_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/os_test.c b/libs/os/src/test/os_test.c
index 1b3af1a..48f0720 100644
--- a/libs/os/src/test/os_test.c
+++ b/libs/os/src/test/os_test.c
@@ -31,7 +31,7 @@ os_test_all(void)
     os_sem_test_suite();
     os_mbuf_test_suite();
     os_eventq_test_suite();
-    
+    os_callout_test_suite();
 
     return tu_case_failed;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bc4c0a83/libs/os/src/test/os_test_priv.h
----------------------------------------------------------------------
diff --git a/libs/os/src/test/os_test_priv.h b/libs/os/src/test/os_test_priv.h
index 5193c33..e923a6f 100644
--- a/libs/os/src/test/os_test_priv.h
+++ b/libs/os/src/test/os_test_priv.h
@@ -27,6 +27,6 @@ int os_mbuf_test_suite(void);
 int os_mutex_test_suite(void);
 int os_sem_test_suite(void);
 int os_eventq_test_suite(void);
-
+int os_callout_test_suite(void);
 
 #endif