summaryrefslogtreecommitdiff
path: root/cts
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2016-07-08 12:42:45 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-11 21:27:47 -0700
commit36eb325519a46bddaa1a7567c6224fd0e28fd1c4 (patch)
treebb10e67744ea48a0d8fb1bdcfcf26b4ccdcf42fe /cts
parentafa53e3950abd4727eab9b14275b4805495767b7 (diff)
downloadchrome-ec-36eb325519a46bddaa1a7567c6224fd0e28fd1c4.tar.gz
Add pingpong to CTS
cts/pingpong/cts.tasklist contains tasks run only for pingpong. BUG=chromium:624520 BRANCH=none TEST=Ran the followings: make buildall make CTS_MODULE=gpio BOARD=nucleo-f072rb make CTS_MODULE=pingpong BOARD=nucleo-f072rb make CTS_MODULE=gpio BOARD=stm32l476g-eval make CTS_MODULE=pingpong BOARD=stm32l476g-eval Change-Id: I5180c60aed5f7d41363c502df539ea9b25ff5d13 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359446 Reviewed-by: Chris Chen <twothreecc@google.com>
Diffstat (limited to 'cts')
-rw-r--r--cts/pingpong/cts.tasklist22
-rw-r--r--cts/pingpong/dut.c70
-rw-r--r--cts/pingpong/th.c70
3 files changed, 162 insertions, 0 deletions
diff --git a/cts/pingpong/cts.tasklist b/cts/pingpong/cts.tasklist
new file mode 100644
index 0000000000..bb41e4935f
--- /dev/null
+++ b/cts/pingpong/cts.tasklist
@@ -0,0 +1,22 @@
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * List of enabled tasks in the priority order
+ *
+ * The first one has the lowest priority.
+ *
+ * For each task, use the macro TASK_ALWAYS(n, r, d, s) where :
+ * 'n' in the name of the task
+ * 'r' in the main routine of the task
+ * 'd' in an opaque parameter passed to the routine at startup
+ * 's' is the stack size in bytes; must be a multiple of 8
+ */
+#define CONFIG_CTS_TASK_LIST \
+ TASK_ALWAYS(TESTA, task_abc, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(TESTB, task_abc, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(TESTC, task_abc, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(TICK, task_tick, NULL, 256) \
+ TASK_ALWAYS(CTS, cts_task, NULL, TASK_STACK_SIZE)
diff --git a/cts/pingpong/dut.c b/cts/pingpong/dut.c
new file mode 100644
index 0000000000..0dc0320adc
--- /dev/null
+++ b/cts/pingpong/dut.c
@@ -0,0 +1,70 @@
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Tasks for scheduling test.
+ */
+
+#include "common.h"
+#include "console.h"
+#include "task.h"
+#include "test_util.h"
+#include "timer.h"
+#include "util.h"
+
+#define TEST_COUNT 3000
+
+static int wake_count[3];
+
+int task_abc(void *data)
+{
+ int myid = task_get_current() - TASK_ID_TESTA;
+ task_id_t next = task_get_current() + 1;
+
+ if (next > TASK_ID_TESTC)
+ next = TASK_ID_TESTA;
+
+ task_wait_event(-1);
+
+ ccprintf("\n[starting Task %c]\n", ('A' + myid));
+
+ while (1) {
+ wake_count[myid]++;
+ if (myid == 2 && wake_count[myid] == TEST_COUNT) {
+ if (wake_count[0] == TEST_COUNT &&
+ wake_count[1] == TEST_COUNT)
+ test_pass();
+ else
+ test_fail();
+ wake_count[0] = wake_count[1] = wake_count[2] = 0;
+ task_wait_event(-1);
+ } else {
+ task_set_event(next, TASK_EVENT_WAKE, 1);
+ }
+ }
+
+ return EC_SUCCESS;
+}
+
+int task_tick(void *data)
+{
+ task_wait_event(-1);
+ ccprintf("\n[starting Task T]\n");
+
+ /* Wake up every tick */
+ while (1) {
+ /* Wait for timer interrupt message */
+ usleep(3000);
+ }
+
+ return EC_SUCCESS;
+}
+
+void cts_task(void)
+{
+ wait_for_task_started();
+ task_wake(TASK_ID_TICK);
+ task_wake(TASK_ID_TESTA);
+ /* Sleep forever */
+ task_wait_event(-1);
+}
diff --git a/cts/pingpong/th.c b/cts/pingpong/th.c
new file mode 100644
index 0000000000..0dc0320adc
--- /dev/null
+++ b/cts/pingpong/th.c
@@ -0,0 +1,70 @@
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Tasks for scheduling test.
+ */
+
+#include "common.h"
+#include "console.h"
+#include "task.h"
+#include "test_util.h"
+#include "timer.h"
+#include "util.h"
+
+#define TEST_COUNT 3000
+
+static int wake_count[3];
+
+int task_abc(void *data)
+{
+ int myid = task_get_current() - TASK_ID_TESTA;
+ task_id_t next = task_get_current() + 1;
+
+ if (next > TASK_ID_TESTC)
+ next = TASK_ID_TESTA;
+
+ task_wait_event(-1);
+
+ ccprintf("\n[starting Task %c]\n", ('A' + myid));
+
+ while (1) {
+ wake_count[myid]++;
+ if (myid == 2 && wake_count[myid] == TEST_COUNT) {
+ if (wake_count[0] == TEST_COUNT &&
+ wake_count[1] == TEST_COUNT)
+ test_pass();
+ else
+ test_fail();
+ wake_count[0] = wake_count[1] = wake_count[2] = 0;
+ task_wait_event(-1);
+ } else {
+ task_set_event(next, TASK_EVENT_WAKE, 1);
+ }
+ }
+
+ return EC_SUCCESS;
+}
+
+int task_tick(void *data)
+{
+ task_wait_event(-1);
+ ccprintf("\n[starting Task T]\n");
+
+ /* Wake up every tick */
+ while (1) {
+ /* Wait for timer interrupt message */
+ usleep(3000);
+ }
+
+ return EC_SUCCESS;
+}
+
+void cts_task(void)
+{
+ wait_for_task_started();
+ task_wake(TASK_ID_TICK);
+ task_wake(TASK_ID_TESTA);
+ /* Sleep forever */
+ task_wait_event(-1);
+}