summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNgesBrian <nges.brian@gmail.com>2016-07-20 01:17:41 +0100
committerMarko Kiiskila <marko@runtime.io>2016-08-18 09:20:59 -0700
commitbc4c0a83f752e0b2113f8fb1ed001ec45ddc7c5c (patch)
treee419664dad2bd11f6f754fa4dce1694712e12c3f
parent40c072ebdde316339581823525b5237d4c5565f4 (diff)
basic os_callout
-rw-r--r--libs/os/src/test/callout_test.c82
-rw-r--r--libs/os/src/test/os_test.c2
-rw-r--r--libs/os/src/test/os_test_priv.h2
3 files changed, 84 insertions, 2 deletions
diff --git a/libs/os/src/test/callout_test.c b/libs/os/src/test/callout_test.c
new file mode 100644
index 00000000..034c2f4b
--- /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();
+}
diff --git a/libs/os/src/test/os_test.c b/libs/os/src/test/os_test.c
index 1b3af1ab..48f07206 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;
}
diff --git a/libs/os/src/test/os_test_priv.h b/libs/os/src/test/os_test_priv.h
index 5193c33b..e923a6fa 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