mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
Fix pingpong test
This fixes outdated uart_printf calls and also put the test behind a console command 'runtest'. The console command returns 'Pass' or 'Fail'. BUG=chrome-os-partner:18598 TEST=Run pingpong test on Spring BRANCH=none Change-Id: Ia2c439685447e42b278556ca66c9f080d4cafe11 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47831 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
||||
/* 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.
|
||||
*
|
||||
@@ -6,24 +6,39 @@
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "uart.h"
|
||||
#include "console.h"
|
||||
#include "task.h"
|
||||
#include "timer.h"
|
||||
#include "util.h"
|
||||
|
||||
#define TEST_COUNT 3000
|
||||
|
||||
static int wake_count[3];
|
||||
|
||||
int TaskAbc(void *data)
|
||||
{
|
||||
char letter = (char)(unsigned)data;
|
||||
char string[2] = {letter, '\0' };
|
||||
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;
|
||||
|
||||
uart_printf("\n[starting Task %c]\n", letter);
|
||||
task_wait_event(-1);
|
||||
|
||||
ccprintf("\n[starting Task %c]\n", ('A' + myid));
|
||||
|
||||
while (1) {
|
||||
uart_puts(string);
|
||||
uart_flush_output();
|
||||
task_set_event(next, TASK_EVENT_WAKE, 1);
|
||||
wake_count[myid]++;
|
||||
if (myid == 2 && wake_count[myid] == TEST_COUNT) {
|
||||
if (wake_count[0] == TEST_COUNT &&
|
||||
wake_count[1] == TEST_COUNT)
|
||||
ccputs("Pass!\n");
|
||||
else
|
||||
ccputs("Fail!\n");
|
||||
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;
|
||||
@@ -31,12 +46,23 @@ int TaskAbc(void *data)
|
||||
|
||||
int TaskTick(void *data)
|
||||
{
|
||||
uart_set_console_mode(1);
|
||||
uart_printf("\n[starting Task T]\n");
|
||||
/* Print T every tick */
|
||||
task_wait_event(-1);
|
||||
ccprintf("\n[starting Task T]\n");
|
||||
|
||||
/* Wake up every tick */
|
||||
while (1) {
|
||||
/* Wait for timer interrupt message */
|
||||
usleep(3000);
|
||||
uart_puts("T\n");
|
||||
}
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int command_run_test(int argc, char **argv)
|
||||
{
|
||||
task_wake(TASK_ID_TICK);
|
||||
task_wake(TASK_ID_TESTA);
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
DECLARE_CONSOLE_COMMAND(runtest, command_run_test,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
#define CONFIG_TEST_TASK_LIST \
|
||||
TASK_TEST(TESTA, TaskAbc, NULL, TASK_STACK_SIZE) \
|
||||
TASK_TEST(TESTB, TaskAbc, NULL, TASK_STACK_SIZE) \
|
||||
TASK_TEST(TESTC, TaskAbc, NULL, TASK_STACK_SIZE)
|
||||
TASK_TEST(TESTC, TaskAbc, NULL, TASK_STACK_SIZE) \
|
||||
TASK_TEST(TICK, TaskTick, NULL, 256)
|
||||
|
||||
Reference in New Issue
Block a user