aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-07-02 12:32:13 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-07-02 12:32:13 +0000
commit5f4dbf9ca9ba32bfeefa3dbab412867dc63f0892 (patch)
treea178d1e424124786e3f5e16e8e807a638812ed58 /test
parent8a02a67d832e1c3515f91f97dcb2a2b61be3268f (diff)
downloadChibiOS-5f4dbf9ca9ba32bfeefa3dbab412867dc63f0892.tar.gz
ChibiOS-5f4dbf9ca9ba32bfeefa3dbab412867dc63f0892.tar.bz2
ChibiOS-5f4dbf9ca9ba32bfeefa3dbab412867dc63f0892.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@328 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test')
-rw-r--r--test/test.c37
-rw-r--r--test/test.h2
-rw-r--r--test/testbmk.c18
3 files changed, 32 insertions, 25 deletions
diff --git a/test/test.c b/test/test.c
index f9a185d03..5f78c8526 100644
--- a/test/test.c
+++ b/test/test.c
@@ -167,22 +167,27 @@ void test_cpu_pulse(systime_t ms) {
systime_t test_wait_tick(void) {
- systime_t time = chSysGetTime() + 1;
- if (time) {
- while (chSysGetTime() < time) {
-#if defined(WIN32)
- ChkIntSources();
-#endif
- }
- }
- else {
- while (chSysGetTime() > time) {
-#if defined(WIN32)
- ChkIntSources();
-#endif
- }
- }
- return time;
+ chThdSleep(1);
+ return chSysGetTime();
+}
+
+/*
+ * Timer utils.
+ */
+static VirtualTimer vt;
+bool_t test_timer_done;
+
+static void tmr(void *p) {
+
+ test_timer_done = TRUE;
+}
+
+void test_start_timer(systime_t time) {
+
+ test_timer_done = FALSE;
+ chSysLock();
+ chVTSetI(&vt, time, tmr, NULL);
+ chSysUnlock();
}
/*
diff --git a/test/test.h b/test/test.h
index 468505d01..7a2e86f0b 100644
--- a/test/test.h
+++ b/test/test.h
@@ -53,11 +53,13 @@ extern "C" {
void test_wait_threads(void);
systime_t test_wait_tick(void);
void test_cpu_pulse(systime_t ms);
+ void test_start_timer(systime_t time);
#ifdef __cplusplus
}
#endif
extern Thread *threads[MAX_THREADS];
extern void *wa[MAX_THREADS];
+extern bool_t test_timer_done;
#endif /* _TEST_H_ */
diff --git a/test/testbmk.c b/test/testbmk.c
index 2dc349d92..b0f44f315 100644
--- a/test/testbmk.c
+++ b/test/testbmk.c
@@ -25,9 +25,9 @@ __attribute__((noinline))
static unsigned int msg_loop_test(Thread *tp) {
uint32_t n = 0;
- systime_t start = test_wait_tick();
- systime_t end = start + 1000;
- while (chSysInTimeWindow(start, end)) {
+ test_wait_tick();
+ test_start_timer(1000);
+ while (!test_timer_done) {
(void)chMsgSend(tp, 0);
n++;
#if defined(WIN32)
@@ -164,10 +164,10 @@ static void bmk4_teardown(void) {
static void bmk4_execute(void) {
- systime_t start = test_wait_tick();
- systime_t end = start + 1000;
uint32_t n = 0;
- while (chSysInTimeWindow(start, end)) {
+ test_wait_tick();
+ test_start_timer(1000);
+ while (!test_timer_done) {
threads[0] = chThdCreate(chThdGetPriority()-1, 0, wa[0], STKSIZE, thread2, NULL);
chThdWait(threads[0]);
n++;
@@ -203,10 +203,10 @@ static void bmk5_execute(void) {
static Queue iq;
chIQInit(&iq, ib, sizeof(ib), NULL);
- systime_t start = test_wait_tick();
- systime_t end = start + 1000;
uint32_t n = 0;
- while (chSysInTimeWindow(start, end)) {
+ test_wait_tick();
+ test_start_timer(1000);
+ while (!test_timer_done) {
chIQPutI(&iq, 0);
chIQPutI(&iq, 1);
chIQPutI(&iq, 2);