From b072c6de512ccd3a7b3b094175b7184526d2cb26 Mon Sep 17 00:00:00 2001 From: batt Date: Sat, 9 Aug 2008 10:08:34 +0000 Subject: [PATCH] Refactor proc_test to comply with new policy. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1586 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/kern/proc.h | 5 ++++- bertos/kern/proc_test.c | 45 ++++++++++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/bertos/kern/proc.h b/bertos/kern/proc.h index 87fed5e1..0071ca13 100644 --- a/bertos/kern/proc.h +++ b/bertos/kern/proc.h @@ -60,7 +60,10 @@ struct Process *proc_new_with_name(const char* name, void (*entry)(void), iptr_t void proc_exit(void); void proc_switch(void); -void proc_test(void); +int proc_testSetup(void); +int proc_testRun(void); +int proc_testTearDown(void); + struct Process *proc_current(void); iptr_t proc_current_user_data(void); void proc_rename(struct Process *proc, const char* name); diff --git a/bertos/kern/proc_test.c b/bertos/kern/proc_test.c index 96c4a9bd..79b7660e 100644 --- a/bertos/kern/proc_test.c +++ b/bertos/kern/proc_test.c @@ -39,8 +39,7 @@ #include #include - -#warning FIXME: Review this test and refactor for all target. +#include /** * Proc scheduling test subthread 1 @@ -71,21 +70,35 @@ static void proc_test_thread2(void) static cpustack_t proc_test_stack1[CONFIG_PROC_DEFSTACKSIZE / sizeof(cpustack_t)]; static cpustack_t proc_test_stack2[CONFIG_PROC_DEFSTACKSIZE / sizeof(cpustack_t)]; + +int proc_testSetup(void) +{ + kdbg_init(); + proc_init(); + IRQ_ENABLE; + timer_init(); + return 0; +} + +int proc_testTearDown(void) +{ + return 0; +} + /** * Process scheduling test */ -void proc_test(void) +int proc_testRun(void) { proc_new(proc_test_thread1, NULL, sizeof(proc_test_stack1), proc_test_stack1); proc_new(proc_test_thread2, NULL, sizeof(proc_test_stack2), proc_test_stack2); kputs("Created tasks\n"); kputs("stack1:\n"); -// #warning FIXME - kdump(proc_test_stack1+sizeof(proc_test_stack1)-64, 64); + kdump(proc_test_stack1 + sizeof(proc_test_stack1) - 64, 64); + kputs("stack2:\n"); -// #warning FIXME - kdump(proc_test_stack2+sizeof(proc_test_stack1)-64, 64); + kdump(proc_test_stack2 + sizeof(proc_test_stack2) - 64, 64); for (int i = 0; i < 30; ++i) { @@ -93,4 +106,22 @@ void proc_test(void) timer_delay(93); proc_switch(); } + return 0; } +#warning Fix test to comply to new policy. +#if 0 +/* + * FIXME: to be compiled as a single file + * the kernel module needs the assembly switch function + * and the idle() that lay in a emulator cpp file. + * How can we fix this? + */ +#include TEST_ONLY(drv/kdebug.c) +#include TEST_ONLY(kern/proc.c) +#include TEST_ONLY(drv/timer.c) +#include TEST_ONLY(mware/formatwr.c) +#include TEST_ONLY(mware/hex.c) +#include TEST_ONLY(os/hptime.c) + +TEST_MAIN(proc); +#endif -- 2.25.1